Distribute list of bits into given amount of slots

Given a bitfield like the following (numbers can only be 1 or 0):

const bits = [1, 1, 0, 1, 0, 0, 0, 1]

I want to produce a list of N average values where N is an arbitrary number.

In our example above, given N is 4, the result would be [1, 0.5, 0, 0.5].

I have been using the following code so far:

const average = (...args) => args.reduce((a, b) => a + b) / args.length;

const averageNumbers = splitEvery(Math.floor(bits.length / N)).map(nums => average(nums))

The problem is that the above doesn’t work in case my bits array is composed of 696 values and I need 150 average numbers, because I end up having 174 numbers instead of 150.

What am I doing wrong?