is this an efficient method of creating random numbers?

  • Thread starter Thread starter sokevin
  • Start date Start date
S

sokevin

fot random numbers 0 to 10 =ROUND((RAND()*10),0)

for random numbers 0 - 100 =ROUND((RAND()*100),0)

for rand numbers 0 -1000 =ROUND((RAND()*1000),0)


etc etc


cheers :
 
oh. i am trying to figure out how to creat numbers between a certain
range....

eg between 3 to 9

i can only do 0 - 10 at the moment

any ideas appreciated.

cheers
 
thank you

i have found out that =ROUND((RAND()*10),0) ~ does not work for som
reason

for a sample of 1100 numbers i get approx

0...... 50
1..... 100
2..... 100
3..... 100
4..... 100
5..... 100
6..... 100
7..... 100
8..... 100
9..... 100
10.... 50



:
 
RANDBETWEEN in the Analysis ToolPak does this already. If you have
2003, you will get better results rolling your own, because the RAND
worksheet function is much improved, provided you have the patch
http://support.microsoft.com/?kbid=833618
but the ATP function and therefore RANDBETWEEN have not been upgraded
http://support.microsoft.com/default.aspx?scid=kb;en-us;829208

You are on the right track, but you will only get a value of 10 if RAND
returns a value of exactly 1, which is extremely unlikely. The rest of
the intgers 0-9 would be equally likely. To return integers between A
and B inclusive, use
=ROUND(RAND()*(B-A+1)+A,0)

Jerry
 
the intgers 0-9 would be equally likely. To return integers between A
and B inclusive, use
=ROUND(RAND()*(B-A+1)+A,0)
Say it ain't so!

To return random integers between A and B, both inclusive, the correct
formula is =INT(RAND()*(B-A+1))+A, where B > A

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
Late night replies strike again! Good catch

Tushar said:
Say it ain't so!

To return random integers between A and B, both inclusive, the correct
formula is =INT(RAND()*(B-A+1))+A, where B > A
 
Because
0.0-0.5 -> 0 width 0.5
0.5-1.5 -> 1 width 1.0
1.5-2.5 -> 2 width 1.0
...
8.5-9.5 -> 9 width 1.0
9.5-10. -> 10 width 0.5

Use INT() instead of ROUND, as others have pointed out. That will give you
0.0-1.0 -> 0 width 1.0
1.0-2.0 -> 2 width 1.0
...
9-0-10. -> 9 width 1.0
where the right hand endpoint of the intevals is not inclusive.

Note that due to the late hour of my original reply, I was thinking INT
even as I wrote ROUND.

Jerry
 
Back
Top