samedi 30 janvier 2021

How to generate in python a random number in a range but biased toward some specific numbers?

I would like to choose a range, for example, 60 to 80, and generate a random number from it. However, between 65-72 I'd like a higher probability, while the other ranges aside from this (60-64 and 73 to 80) to have lower. I know there's lots of questions about that issue here, but I coudn't find any that could be expanded to my case, most of them people are just choosing between two things and want some bias upon it.

Also, it would be interesting a scalable solution, so that one could expand its usage for higher ranges, for example, 1000-2000, but biased toward 1400-1600.

Does anyone could help with some ideas?

Thanks beforehand for anyone willing to contribute!




Aucun commentaire:

Enregistrer un commentaire