jeudi 2 juillet 2015

php - one-sided gaussian distribution for randomness

I realize this is complex and specific, but as I'm poor at probability I thought I'd try to get some help on this.

What I essentially want to do is get a random number with weighted probabilities based on the previous random number selection.

The way I'd like it set up is this. (Assume the first selection is random, and forgive my syntax).

$start = 3; 
$next = /* function call to get random value */

I essentially want the probability of 3 to be highest, 4 to be second highest 5 to be third highest, wrapping around (modulo some number) so that 2 has the lowest probability.

How can I do this? I don't want to force the same number to repeat, I just want a higher probability of it doing so (and also a higher probability of it going sequentially than not). Let me know if clarification is needed, but essentially with an initial selection of 3 and a modulo of 6, I'd want the probabilities of the next selection to be something like this:

P(3)=30%
P(4)=25%
P(5)=20%
P(0)=12.5%
P(1)=7.5%
P(2)=5%

I'm not set on those specific probabilities, just the order of them - a one-sided bell curve shape would be nice (especially if there's built in functionality to support it).




Aucun commentaire:

Enregistrer un commentaire