+ Reply to Thread
Results 1 to 8 of 8

random numbers with a probability

  1. #1
    Registered User
    Join Date
    05-15-2008
    Posts
    38

    random numbers with a probability

    Hi!
    I would like to obtain a random number between -15 and +15. And I want in the next row another random number added to the previous number. Till here I have no problem.

    =C2+ALEATORIO.ENTRE(-15;15)
    or in english
    =C2+RAND(-15,15)

    The problem is that I want the result being always over 0, always a positive number.
    And the biggest problem: I want that the probabilities that 1 or -1 appear is 50%. The probabilities of the appearing of 2 or -2 is 25%, etc.

    1---------50%
    2---------25%
    3---------12.5%
    4---------6.25%
    5---------3.12%
    6---------1.56%
    7---------0.78%
    8---------0.39%
    9---------0.19%
    10-------0.09%
    11-------0.04%
    12-------0.02%
    13-------0.01%
    14-------0.006%
    15-------0.003%

    I choose 15 as a limit just to put a limit, but I don’t need it, and could be better if it’s possible all numbers, but with its probability.

    Thank you very much for your help,
    Caldera

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    For positive random numbers with that distribution,

    =INT(-LOG(RAND() / 2, 2))

    For positive and negative numbers with a hole at zero,

    =IF(RAND() >= 0.5, 1, -1) * INT(-LOG(RAND() / 2, 2) )
    Last edited by shg; 07-19-2008 at 04:43 PM. Reason: simplified both formulas

  3. #3
    Registered User
    Join Date
    05-15-2008
    Posts
    38
    Thanks Shg,
    it works in some rows, but other random rows gives me an error #¡NUM!
    I don't know why

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    The formula has no dependence on row, and can only give an error if the value returned by RAND() is exactly zero, which doesn't come up very often. How are you using it?

  5. #5
    Registered User
    Join Date
    05-15-2008
    Posts
    38
    Here is the worksheet as I'm using it.
    Attached Files Attached Files

  6. #6
    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're using RANDBETWEEN(), which is a completely different function than RAND(). Here's the distribution using the second formula for 10,000 random deviates:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-15-2008
    Posts
    38
    Ok, Shg, now works perfectly.
    It was a problem with the traduction. I thought it was the same.

    Thank you very much for your help.

  8. #8
    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're welcome, glad it worked for you.

+ 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