+ Reply to Thread
Results 1 to 4 of 4

How to Control the distribution of 0's and 1's using Rand function?

  1. #1
    Registered User
    Join Date
    06-25-2012
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    How to Control the distribution of 0's and 1's using Rand function?

    Hi,

    This is my first forum post. When using the Rand function, it gives an even distribution between the two numbers 0 and 1. I would like to find out how I can control the distribution ratio of 1's to 0's. I do not want it to be an even (~50%) split between the two numbers.
    For example, I would like to be able to set it to 75% of the random mix is 1's while 25% is 0's,
    Or 60% of 1's and 40% of 0's, etc.....

    I am using the following to create a 10 column grid of random 1's and 0's. However, I don't want a ~50% mix. How can I set my own adjustable distribution?

    Please Login or Register  to view this content.
    Thank you very much for any help you can provide.

  2. #2
    Forum Contributor wallyeye's Avatar
    Join Date
    05-06-2011
    Location
    Arizona
    MS-Off Ver
    Office 2010, 2007
    Posts
    308

    Re: How to Control the distribution of 0's and 1's using Rand function?

    There was a similar post a couple days ago here:

    http://www.excelforum.com/excel-prog...html?p=2834079

    My suggestion was to use a bit of code:

    Please Login or Register  to view this content.
    I'm not sure what you are doing with the last loop, deleting extra rows? You could use intRows from this version...

  3. #3
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: How to Control the distribution of 0's and 1's using Rand function?

    Hi,

    Try this

    Please Login or Register  to view this content.
    Please take time to read the forum rules

  4. #4
    Registered User
    Join Date
    06-25-2012
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: How to Control the distribution of 0's and 1's using Rand function?

    Thank you. This works perfectly.
    Yeah that last loop was pretty useless. I took it out.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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