+ Reply to Thread
Results 1 to 3 of 3

Random draws of some rows of a column

  1. #1
    Registered User
    Join Date
    02-04-2010
    Location
    ny,ny
    MS-Off Ver
    Excel 2007
    Posts
    10

    Random draws of some rows of a column

    I have a rectangular Boolean matrix M that is say 30x6

    For example, one column of M is:
    1
    0
    0
    1
    0
    1

    For each column, I want to randomly choose a row number of a cell with a 1 in it.

    For the example column, the result would be a 1, 4,or 6

    With M, I’d end up with 30 numbers (one for each column).

    I don’t want to use VBA, and I need the calc to be done in one cell/column without using a second matrix of random numbers to generate indices)..it needs to be done on the fly so to speak.

    If u multiply each column by a 6x1 array of random numbers, and find the position of the largest, that would work, but I’m having trouble with the syntax to get it done in one cell. I suspect it should be a cousin to the syntax for removing blank cells (something like:

    =INDEX($A$1:$A$8,SMALL(IF(ISnumber($A$1:$A$8),ROW($A$1:$A$8),""),ROW(1:8)))

    Does anyone have a way to do something like this. I come across this situation all the time, but don't have a decent way of addressing it. thanks

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Random draws of some rows of a column

    One way:

    =SMALL(IF(A$1:A$6=1, ROW(A$1:A$6)), RANDBETWEEN(1, COUNTIF(A$1:A$6, 1)))

    ... confirmed with Ctrl+Shift+Enter
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    02-04-2010
    Location
    ny,ny
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Random draws of some rows of a column [SOLVED]

    works great...thanks so much...
    Last edited by shg; 09-23-2010 at 08:03 PM. Reason: deleted quote

+ 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