+ Reply to Thread
Results 1 to 12 of 12

Random numbers but each number not eqully random.

  1. #1
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    71

    Random numbers but each number not eqully random.

    I would like random numbers between 0 and 7. To go from a2:a10000. But I would like the probability's of each number to not be equally random.

    For example I would the number 7 to appear 1.52%. of the time.


    Here is each number probability of appearing
    0 0.003736695
    1 0.031969498
    2 0.117221491
    3 0.23878452
    4 0.291847746
    5 0.21402168
    6 0.087194018
    7 0.015224352


    Any help is greatly appreciated

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,453

    Re: Random numbers but each number not eqully random.

    1) Add a column =sum(B$1:B1) (note relative and absolute references). You are creating a lookup table to use with the built in RAND() function.
    2) Use lookup function INDEX($A$1:$A$8,MATCH(RAND(),$C$1:$C$8,1)) Note that it is using the "binary" search on an ascending list option for the third argument of the MATCH() function.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Random numbers but each number not eqully random.

    Hi,

    I think you mean that you want the numbers to be DISTRIBUTED randomly. By definition since you are specifiying the number of times the numbers 0-7 should appear they are NOT random numbers.

    So the approach I'd adopt is list the numbers
    0 - 37 times
    1 - 320 times
    2 - 1172 times
    ... etc
    7 - 152 times

    now alongside the 9999 numbers listed add the formula =RAND() in the adjacent column.

    Now sort the two columns using the random number column as the key.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    71

    Re: Random numbers but each number not eqully random.

    Below I attached a example file where I need the random numbers
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    71

    Re: Random numbers but each number not eqully random.

    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    I think you mean that you want the numbers to be DISTRIBUTED randomly. By definition since you are specifiying the number of times the numbers 0-7 should appear they are NOT random numbers.

    So the approach I'd adopt is list the numbers
    0 - 37 times
    1 - 320 times
    2 - 1172 times
    ... etc
    7 - 152 times

    now alongside the 9999 numbers listed add the formula =RAND() in the adjacent column.

    Now sort the two columns using the random number column as the key.


    You are likely right and I actually did that but I had trouble's adding my formulas in above worksheet. Maybe that is the way I need to go but if I could random the 0-7 as I mentioned above my formula's would work as is.

    This was my attempt at this method.
    =Some reason I cannot post my formula ?
    Last edited by richhhh; 09-06-2016 at 11:24 AM.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Random numbers but each number not eqully random.

    As soon as you introduce controls like this, it's not longer an exercise in random number generation. It's now an exercise in randomizing a preset list of numbers.
    Please Login or Register  to view this content.
    So you create a list with numbers in column A repeated the number of times you want calculated in column C, all in one column.
    Then a RAND() formula in the next column to generate a truly random number to associate with your preset list.

    Finally, in a new column, you extract the preset numbers in the order of the adjacent RANDOM numbers. (slow)
    or....
    Sort the two columns using the RAND column as the sort key. Each time you do this your main set of preset numbers will be in a different order. Very fast.

    Attached is an example.
    Attached Files Attached Files
    Last edited by JBeaucaire; 09-06-2016 at 12:00 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  7. #7
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    71

    Re: Random numbers but each number not eqully random.

    Thank you so much!

  8. #8
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    71

    Re: Random numbers but each number not eqully random.

    So if I wanted to change the number probabilitys to say

    0 0.16% 16
    1 1.72% 172
    2 7.74% 774
    3 19.35% 1935
    4 29.03% 2903
    5 26.13% 2613
    6 13.06% 1306
    7 2.80% 280



    How do I get the randomizer to recognize this? I counted the 7's and it still says 152?

    Thank you so much for your help

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Random numbers but each number not eqully random.

    You need to enter 280 number 7s in the list. As well as 16 zeros, 172 1s, 774 2s...etc

  10. #10
    Registered User
    Join Date
    03-08-2016
    Location
    Canada
    MS-Off Ver
    2015
    Posts
    71

    Re: Random numbers but each number not eqully random.

    Quote Originally Posted by Richard Buttrey View Post
    You need to enter 280 number 7s in the list. As well as 16 zeros, 172 1s, 774 2s...etc

    That make total sense. Thank you !

  11. #11
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Random numbers but each number not eqully random.

    Quote Originally Posted by richhhh View Post
    That make total sense. Thank you !
    Glad to have helped, and stating the obvious, if you change the %s again you'll need to also change the list to reflect the changed number of 0-7s

  12. #12
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,453

    Re: Random numbers but each number not eqully random.

    I notice from your file that your probabilities are being generated by the binomdist() function. I suspect that one can use the binom.inv() function to generate these random numbers in the same way that we use the norminv() function to generate random numbers that follow a normal distribution. binom.inv() is not available in my version of Excel, so I cannot test it. If you are interested, and you generally expect to know what distribution you are planning to use to generate your random numbers, it might be worth the research to learn how to use the inverse distribution functions to generate these random numbers:
    http://www.exceluser.com/formulas/statsnormal.htm talks about the normal distribution, eventually getting to the part about using norm.inv() to generate random numbers along a normal distribution.
    http://www.mathwave.com/articles/ran...sheets-p2.html talks about using inverse functions, some caveats and pitfalls, and pushes their product that they claim is superior at generating random numbers for various distributions.
    http://www.real-statistics.com/sampl...ns/simulation/ further discussion about using Excel's built in tools for generating random numbers along different distributions.
    There are almost certainly others out there, if you put the question to your favorite internet search engine.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Generating a list of Random numbers of random length...
    By Growl in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-19-2013, 12:10 PM
  2. Replies: 5
    Last Post: 06-21-2013, 10:40 AM
  3. [SOLVED] Generate random 6-16-byte random hexadecimal number
    By jsamuelshn in forum Excel General
    Replies: 6
    Last Post: 07-20-2012, 10:38 AM
  4. Generating a Random Number of Random Numbers
    By Garrus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2010, 09:39 AM
  5. Non-random numbers generated by excel's data analysis random gener
    By Allie in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-17-2005, 02:05 AM
  6. [SOLVED] Re: Non-random numbers generated by excel's data analysis random gener
    By Harlan Grove in forum Excel General
    Replies: 2
    Last Post: 09-13-2005, 12:05 PM
  7. [SOLVED] How do I find random number in list of random alpha? (Position is.
    By jlahealth-partners in forum Excel General
    Replies: 0
    Last Post: 02-08-2005, 02:06 PM

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