In a small application written in C/C++, I am facing a problem with the rand
function and maybe the seed :
I want to produce a sequence of random numbers th
use
pow(2,rand())
it will give the answers in order of desired magnitude!!
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.
If you want different orders of magnitude, why not simply try pow(2, rand())
? Or perhaps choose the order directly as rand(), as Harold suggested?
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.
If you want to use random numbers from an online service you can use wget for that, you may want to see you can also use services like random.org for your random number generation , you can catch them using wget and then reading the numbers from the downloaded file
wget -q https://www.random.org/integers/?num=100&min=1&max=100&col=5&base=10&format=html&rnd=new -O new.txt
http://programmingconsole.blogspot.in/2013/11/a-better-and-different-way-to-generate.html