Conditional probability in PHP -
i want draw random numbers between 1 , 100 in php. want numbers drawn probability of 20%, odd numbers probability of 80%.
how can implement this?
function wtf_random() { $ret = 2 * rand(1, 50); if (rand(1, 5) !== 1) { --$ret; } return $ret; }
Comments
Post a Comment