Email or username:

Password:

Forgot your password?
Maxim Lebedev

There is an unlimited set of numbers from 1.0 to 3.0 with rounding to one decimal place. You need to construct an array of X numbers where the total average is 2.35 with an error of 0.5. The order of the numbers in the array is not important.

6 comments
Maxim Lebedev

This is a real challenge for the game that I program. But I was always bad at math in school.

ruffni

@toby3d wdym unlimited set of numbers?

Maxim Lebedev

@ruffni in real life a has a 4000+ various numbers, each in range from 1.0 to 3.0: 1.8, 2.6, 3.0, 3.0, 2.8, 1.0, 2.4, 1.2, 2.8, 1.0... and etc.

ruffni

@toby3d so, since there are only 21 distinct numbers from 1.0 to 3.0 i'm guessing you don't mean *set*, since in maths this implies distinct elements.

if you want a list of say x=3 elements to average 2.35. this means you want r[0]+r[1]+r[2]=2.35*3 ±(3*0.5). r[] being the elements of the resulting list.
i'd start with 2.35*3=7.05, choose one element at random (e.g. 1.4), subtract the number 7.05-1.4=5.65, memoize the result.
repeat until the result of the subtrction is between 1.0 and 3.0.

Maxim Lebedev

@ruffni "memorize the result": you mean what I need add random numbers in array and substruct until I got result between 1.0 and 3.0?

ruffni

@toby3d not sure if i understand you correctly, but yes.
altough this might possibly not always render the requested number of elements, but it might work :)

Go Up