How can I generate random floats between X and Y, that are un-equally distributed, so that it's more likely to generate numbers from a specific range, within X to Y?
I did search a lot of keywords to find something like this including: unequally distributed random numbers, or uneven noise distribution, or biased random floats, or weighted random numbers ...
All I could find is to randomly pick from a bag of finite list of values, weighted so that some values are more likely to be chosen, but I'm looking to choose from an infinite range of floats between X and Y.
Also I found a lot of articles about how to NOT generate biased random numbers, which is the opposite of what I want.
As an example of WHAT I'm trying to do with these numbers: If you draw black noise in a white square, each noise dot is in a random location within the square, if you generate enough dots, you'll have a almost black square.
If you distribute the randomness with a higher probability in the middle of the square, you'll draw almost a soft black dot in the middle of the square. This is what I'm trying to generate.
So my questions are:
Thank you in advance!
These are generally called absolutely continuous distributions, and the following are two ways to define this kind of distribution.
std::piecewise_linear_distribution
. See also "Piecewise Linear Distribution".For many popular distributions, such as the normal, beta, and gamma distributions, there are special methods for generating random numbers with those distributions. In fact, there are many different designs of such methods for the normal distribution. For numbers in a bounded range, the beta distribution is an ideal choice; its two parameters (alpha and beta) describe a wide variety of shapes that could suit your purposes. Python has a random.betavariate(alpha, beta)
method for generating beta-distributed random numbers.