"I want the selection to be random but weighted in favor of higher scores, but that's not happening."

Zakaria Mokhtari - Sep 1 - - Dev Community

I have a set of values, and I want to randomly select a smaller subset with weighting, meaning the higher the value, the greater the probability of it being selected. I used a weighted random function, but it didn't work as expected. Then, I applied exponentiation to magnify the larger values, but the weighting wasn't clear. I suspected that the small values were too numerous, which might have overshadowed the weighting effect. So, I applied a logarithm to reduce the differences, then exponentiated the values again to magnify the larger ones, but the selection still wasn't properly weighted. Where could the problem be?
$values = pow(log10($values), $weighting_ratio);
"weightedRandomSelection""

.
Terabox Video Player