Get `n` random values between 2 numbers having average `x`
- by Somnath Muluk
I want to get n random numbers(e.g n=16)(whole numbers) between 1 to 5(including both) so that average is x.
x can be any value between (1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5).
I am using PHP.
e.g.
Suppose I have average x= 3.
Then required 16 whole numbers between 1 to 5(including both).
like (1,5,3,3,3,3,2,4,2,4,1,5,1,5,3,3)
Update:
if x=3.5 means average of 16 numbers should be between 3.5 to 4.
and if x=4 means average of 16 numbers should be between 4 to 4.5
and if x=5 means all numbers are 5