Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing upper case characters to upper/lower Richard Zignego Excel Discussion (Misc queries) 1 December 17th 07 10:09 PM
Change from mixed caps and upper lower to all upper lower case Fish''s Mermaid Excel Worksheet Functions 3 October 13th 06 02:15 PM
How to fix lower and upper bounds for data charter_SKR Excel Worksheet Functions 1 April 10th 06 05:29 PM
How do I convert all upper case excel sheet into upper and lower . DebDay Excel Discussion (Misc queries) 1 March 9th 05 08:31 PM
Normal Distrubtions with Upper/Lower Bounds [email protected] Excel Programming 1 January 9th 04 01:04 AM


All times are GMT +1. The time now is 04:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"