ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Random Number Generator (https://www.excelbanter.com/excel-programming/285735-random-number-generator.html)

Brad[_13_]

Random Number Generator
 
Iım aware of the function ³=RAND()², that produces the numbers between 0 and
1, but Iım just trying to create a cell formula that produces an evenly
distributed number between two arbitrary values ....

Assuming I need between 1 and 10 (i.e., 1,2,3,4,5,6,7,8,9 or 10), how would
I achieve this without getting a skewed result?

I was thinking of =TRUNC((RAND()*10+1),0) ? Now thatıs just for between 1
and 10

Is there a better way of doing this * help!

Brad.)


brettdj[_3_]

Random Number Generator
 
Hi Brad,

Try using the formula

=RANDBETWEEN(1,10)

Enable this formula via
Tools - Addins - Analysis Toolpak

Cheers

Dav

--
Message posted from http://www.ExcelForum.com


Jerry W. Lewis

Random Number Generator
 
Yes, that approach is fine.

Jerry

Brad wrote:

I'm aware of the function "=RAND()", that produces the numbers
between 0 and 1, but I'm just trying to create a cell formula that
produces an evenly distributed number between two arbitrary values ....

Assuming I need between 1 and 10 (i.e., 1,2,3,4,5,6,7,8,9 or 10),
how would I achieve this without getting a skewed result?

I was thinking of =TRUNC((RAND()*10+1),0) ? Now that's just for
between 1 and 10

Is there a better way of doing this - help!

Brad.)



Tom Ogilvy

Random Number Generator
 
Random Number GeneratorTo Add:

Just change the 1 and 10 to reflect the start number and the breadth/width of the range you want to generate

=Trunc(rand()*(end-begin+1)+begin)

As an example:

If i wanted to generate Uppercase letters between A and Z

code("A") = 65
code("Z") = 90
want to generate possible 26 letters starting with 65 (generate integers between 65 and 90 inclusive)

=Char(Trunc(rand()*26+65)

or
=Char(Trunc(rand()*(90-65+1)+65))

or without having to figure it out:
=CHAR(TRUNC(RAND()*(CODE("Z")-CODE("A")+1)+CODE("A")))




--
Regards,
Tom Ogilvy

"Brad" wrote in message ...
I'm aware of the function "=RAND()", that produces the numbers between 0 and 1, but I'm just trying to create a cell formula that produces an evenly distributed number between two arbitrary values ....

Assuming I need between 1 and 10 (i.e., 1,2,3,4,5,6,7,8,9 or 10), how would I achieve this without getting a skewed result?

I was thinking of =TRUNC((RAND()*10+1),0) ? Now that's just for between 1 and 10

Is there a better way of doing this - help!

Brad.)

onedaywhen

Random Number Generator
 
For a random number between a and b inclusive, I use:

=INT(RAND()*(b-a+1))+a

--

Brad wrote in message ...
Iım aware of the function ³RAND()², that produces the numbers between 0 and
1, but Iım just trying to create a cell formula that produces an evenly
distributed number between two arbitrary values ....

Assuming I need between 1 and 10 (i.e., 1,2,3,4,5,6,7,8,9 or 10), how would
I achieve this without getting a skewed result?

I was thinking of TRUNC((RAND()*10+1),0) ? Now thatıs just for between 1
and 10

Is there a better way of doing this * help!

Brad.)

--



All times are GMT +1. The time now is 10:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com