dimanche 3 mars 2019

Probability density algorythm

I'm not sure that the name for what I need is probability density but anyway.

I'd like to find a function or algorithm for generating random numbers in the specified range with specified chance and linear change.

For example, specified range and chances are:

Chart of chances

Range from -10 to 15.

Chaces are: [[-10, 5], [-5, 0], [3, 5], [10, 30], [15, 0]]

The result after generating a number could be any numbers from that range except -5 and 15. So could be -10, -9, -8, -12 ... 13, 14.

And chance to get -10 is 5 units. -5 is 0 units. 3 is 5 units.

So -9 will appear with 4 units chance and -8 with 3 units chance etc.

And in this case, the most common numbers should appear about 10 because 10 has 30 units chance.

Sorry for my English :)




Aucun commentaire:

Enregistrer un commentaire