Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Upper and Lower Bounds and Rnd
I have been using the following formula to generate a random number
between 1 and 42. I have made my UpperBounds = 42 and my LowerBounds = 1. I ran 1,000 iterations and in several instances, the random number generated equaled 43. How is this? Is there an error in my logic? RandomNumber = Int((UpperBounds - LowerBounds) + 1)* Rnd + LowerBounds TS |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Upper and Lower Bounds and Rnd
I have not used a random number generator but if I understand i
correctly you are adding 1 to what ever RND number generates which could be an number from 1 to 42 Which means that you will never have a 1 but can have a 4 -- Message posted from http://www.ExcelForum.com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Upper and Lower Bounds and Rnd
Terry,
Try RandomNumber = Int((UpperBounds - LowerBounds + 1)* Rnd) + LowerBounds HTH Henry wrote in message om... I have been using the following formula to generate a random number between 1 and 42. I have made my UpperBounds = 42 and my LowerBounds = 1. I ran 1,000 iterations and in several instances, the random number generated equaled 43. How is this? Is there an error in my logic? RandomNumber = Int((UpperBounds - LowerBounds) + 1)* Rnd + LowerBounds TS |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Upper and Lower Bounds and Rnd
Try this
RandomNumber = Int(Rnd * (upperbounds - lowerbounds + 1)) + lowerbounds -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) wrote in message om... I have been using the following formula to generate a random number between 1 and 42. I have made my UpperBounds = 42 and my LowerBounds = 1. I ran 1,000 iterations and in several instances, the random number generated equaled 43. How is this? Is there an error in my logic? RandomNumber = Int((UpperBounds - LowerBounds) + 1)* Rnd + LowerBounds TS |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Changing upper case characters to upper/lower | Excel Discussion (Misc queries) | |||
Change from mixed caps and upper lower to all upper lower case | Excel Worksheet Functions | |||
How to fix lower and upper bounds for data | Excel Worksheet Functions | |||
How do I convert all upper case excel sheet into upper and lower . | Excel Discussion (Misc queries) | |||
Normal Distrubtions with Upper/Lower Bounds | Excel Programming |