+ Reply to Thread
Results 1 to 4 of 4

Generating randomly distributed column values

  1. #1
    Registered User
    Join Date
    05-22-2015
    Location
    Munich
    MS-Off Ver
    2013
    Posts
    5

    Unhappy Generating randomly distributed column values

    Hi,
    I would like to generate biased data in Excel. For example, I have 100 lines of total data. 60 of those represent company A, 30 represent company B, and 10 represent company C. The data should look something like in the attached Excel file.

    I want company A's work done to be 1 80% of the time, company B's 65% of the time and company C's 70% of the time.

    The best I have till now is =LOOKUP(RAND();{0;0,2};{0;1}) which generates 1 80% of the time (and I use it for company A), but this works on a cell level.
    How can I make sure that the number of 1s generated (for the work done column) for all the 60 lines of company A averages to 80% and so on so forth for companies B and C?
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Generating randomly distributed column values

    By 'averages to 80%' do you mean 'is equal to 80%'? I ask, since your random number formula should also average out to 80% over many iterations, so it seems like that should work, but you say it does not. To guarantee 80% of the 60 lines (which is 48) are a 1, you could create an array of 48 1s and 12 0s. Put a random number next to each one and then sort by the random number and then copy those newly ordered 1s and 0s over to your work list. Of course, this is assuming you want the 1s and 0s randomized, otherwise, you could just put a 1 in the first 48 work items.
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

  3. #3
    Registered User
    Join Date
    05-22-2015
    Location
    Munich
    MS-Off Ver
    2013
    Posts
    5

    Re: Generating randomly distributed column values

    Hi Pauley,

    Thank you for your response. Yes, I mean that is should be equal to 80%. However, your solution of creating an array of 48 1s and 12 0s would unfortunately only help for a small data set. Let's say that I extend the same case to thousands of lines. I would then need some formula for this to be done nicely

    Could it be done in a better way? I haven't been able to come up with anything. Could the NORM.DIST or NORM.INV functions help in any way?

  4. #4
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Generating randomly distributed column values

    I've been thinking about this, and no simple solution with a formula comes to mind. I thought of something like this:
    =rand()<=(.8-(number of 1s above this cell/total number of cells)
    to reduce the odds of getting a 1 as you approach 80%, and that would kind of work to limit the number of 1s but does not prevent the number of 0's being > 20%. As I tried to counter that issue, it just messed up the other part. Seems like there should be something along those lines, but it never came to me.

    Of course, there are always macro solutions for something like this, and that may be your best one-stop solution. However, I would also argue that even at 1000s of lines, using the fill command to fill the top 80% of cells to a 1, then the bottom 20% to a 0, fill the next column with rand(), and then a sort. Maybe a minute? Actually, I just tried it for 10000 rows and it was 80 seconds. So, if this is something you do every day, then go to the macro forum and make a request. Who knows, someone may come up with a formulaic solution.

+ 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. How do I check if a number of values are normally distributed?
    By dromedar in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-25-2013, 07:21 AM
  2. Randomly selection of an x% of a column values and copy it to another column
    By zizouzidane in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-16-2013, 11:29 AM
  3. [SOLVED] Filtering and generating new tabs based on Unique values based in column
    By amlan009 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-02-2012, 09:40 PM
  4. Randomly placing 5 same alphabet in a range of 20 cells. (Random Generating)
    By Excript in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-12-2009, 09:52 PM
  5. generating normally distributed data
    By maca in forum Excel General
    Replies: 3
    Last Post: 07-19-2005, 10:14 AM

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