Why does C++ rand() seem to generate only numbers of the same order of magnitude? Why does C++ rand() seem to generate only numbers of the same order of magnitude? c c

Why does C++ rand() seem to generate only numbers of the same order of magnitude?


There are only 3% of numbers between 1 and 230 which are NOT between 225 and 230. So, this sounds pretty normal :)

Because 225 / 230 = 2-5 = 1/32 = 0.03125 = 3.125%


The lighter green is the region between 0 and 225; the darker green is the region between 225 and 230. The ticks are powers of 2.

distribution


You need to be more precise: you want different base 2 logarithm values but what distribution do you want for this? The standard rand() functions generate a uniform distribution, you will need to transform this output using the quantile function associated with the distribution that you want.

If you tell us the distribution then we can tell you the quantile function you need.