+ Reply to Thread
Results 1 to 7 of 7

How to generate a random number for a normal distribution between a max and min

  1. #1
    Registered User
    Join Date
    12-04-2008
    Location
    Canada
    Posts
    4

    How to generate a random number for a normal distribution between a max and min

    Hello,

    I would appreciate any help that you could give me for the following :

    I would like to generate a random number within a normal distribution but only within a set MAX and MIN value.

    I know the formula for a random number in a normal distribution is NORMINV (RAND(),mean,S.D.) but how can I tell Excel that I only want the value between a set MIN & MAX? I have the same question for a Weibull distribution, however I assume the solution will the similar.

    Thank you for any input.

    Mark

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444
    Hi,

    Could you work out the probabilities of the minimum and maximum values you require, and then use them in a RANDBETWEEN() function?

    eg

    =NORMINV(RANDBETWEEN(5,95)/100,mean,sigma)
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Registered User
    Join Date
    12-04-2008
    Location
    Canada
    Posts
    4
    Sweep,

    Thanks for the reply. I was not aware of a RANDBETWEEN() function. Is this available on all Excel versions? I do not seem to have it.

    Thanks again.

  4. #4
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444
    It's available as part of the Analysis ToolPak add-in.

  5. #5
    Registered User
    Join Date
    12-04-2008
    Location
    Canada
    Posts
    4
    Sweep,

    That worked great for the normal distribution. But I am not sure how to apply the RandBetween to the Weibull.

    The formula that I have for the Weibull is c*(-LN(1-RAND())^(1/m)

    where c is the scale and m is the shape. Since my between range is 0.75 to 1.5, the formula returns an error (LN of a negative number).

    Would you know how to resolve this?

    Thank you.

  6. #6
    Registered User
    Join Date
    12-04-2008
    Location
    Canada
    Posts
    4
    I just checked the distribution of the RANDBETWEEN, and it does not seem to be giving me a normal distribution. When I try with just a RAND(), the distribution is normal but then it is not cut off at my desired limits.

    Formula : =NORMINV(RANDBETWEEN(15,85)/100,4.2,0.38)




    Chart.jpg

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    You could try these UDFs:
    Please Login or Register  to view this content.
    Last edited by shg; 12-05-2008 at 08:28 PM.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1