+ Reply to Thread
Results 1 to 10 of 10

Generating random outcomes based on probability

Hybrid View

  1. #1
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Generating random outcomes based on probability

    I think this works
    =IF(RAND()>0.5,"Dog",IF(AND(RAND()>0.2,RAND()<=0.5),"Cat","Rabbit"))
    I tried on 3000 cells and got
    Cat   20
    Dog   51
    Rabbit  29
    Does this work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  2. #2
    Registered User
    Join Date
    02-10-2009
    Location
    London, UK
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Generating random outcomes based on probability

    Hi, thanks for the formula.

    The logic of the formula looks 100% correct but the cat & rabbit results come out the wrong way round. Its something to do with the random function which appears 3 times in the formula, perhaps Excel recalculates as it steps through the formula.

    To test this I took the rand() function out of the calculation and put it into cell D1 so there could only be one random number in each row.

    Changing the formula to

    =IF(D1>0.5,"Dog",IF(AND(D1>0.2,D1<=0.5),"Cat","Rabbit"))

    This does return 500 dog, 300 cat and 200 rabbit

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Generating random outcomes based on probability

    Strange. Oh well, your method will work just fine.

+ 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