0
donuts
124d

I want to run a simulation like rolling a dice N times and find out what's the distribution/probability of getting certain SUMs after the rolls. However the dice is more likely to land on a lower number, and/or depends on what the number it landed on previously. Stats wise I think ideally I want to be able to just input the avg, standard deviation, and skewness into a Random class constructor, and then ask it for N "random" numbers.

• 2
How about using a library with true random numbers, which are good enough to be used in encryption stuff?

It looks like u a using pseudo random numbers at the moment
• 3
Of you choose a random element from [1,2,3,4,5,6], they will have equal probability of 1/6 = 16.66%

Now, if you chose from [1,1,2,2,2,3,3,4,5,6], probabilities change to
1: 2/10 = 20%
2: 3/10 = 30%
3: 20%
4, 5 or 6: 10%

Now you need some reverse engineered maths to input avg and stddev, and produce the corresponding array.
• 0
@gosubinit an easier task would be to concatenate [1,2,3,4,5,6] a thousand times into a single array and pick an element randomly, which should be better than rand()%6+1
• 1
@Lensflare if I understood correctly, @donuts wants to be able to skew the results towards a given average and standard deviation, so I illustrated the concept.

I think your suggestion will produce equal probabilities for all results, right?
• 0
@gosubinit yes, this was just a suggestion for a far easier solution :)
• 0
@gosubinit I read afterwards it's like getting the inverse of a CDF function which kind of looks like what a hashing function for a Map usually does.

But then how do you create the right formula based on the parameters... I assume there so lib they already does since it's probably a common problem in the computing math/stats world so wondering if anyone knew existing solutions/libs