andreas_udby
Registered User.
- Local time
- Today, 23:17
- Joined
- May 7, 2001
- Messages
- 76
I could certainly use some input on how to structure this.
I have a table that's 20 rows by 12 columns. Each cell has a particular value that I want to draw by random sample; each run of the sample will pull five random values.
To do this, I set up two columns, each with five cells that contain the =RANDBETWEEN() formula. The Down column cells contain =RANDBETWEEN(1,20) and the Across column cells contain =RANDBETWEEN(1,12).
Then I have five cells that each use the =INDEX() formula to look up the resulting cell. For instance, cell H6 contains =INDEX(Number_Matrix,D6,E6), where column D is the Down column and column E is the Across column.
But I realized that I'm sampling without eliminating replacements. Sure, it only happens once in a while (I ran the sample about 25 times before I came up with a duplicate value), but I'd like to eliminate it entirely.
I've found examples on the web where people use VBA to draw random samples without replacement, but only where the population data is one column only, not in a table or array. True, I could just change my table into a column that's 240 rows long, but that just seems so inelegant.
Does anyone have an idea about how to perform sampling without replacement on a table or array? I've been racking my brain on this for a while, and I just can't think about where to start. I can follow most the VBA code I see online, but the leap of logic from using a single column to using a table for the original data is leaving me behind.
Thanks,
Andreas
I have a table that's 20 rows by 12 columns. Each cell has a particular value that I want to draw by random sample; each run of the sample will pull five random values.
To do this, I set up two columns, each with five cells that contain the =RANDBETWEEN() formula. The Down column cells contain =RANDBETWEEN(1,20) and the Across column cells contain =RANDBETWEEN(1,12).
Then I have five cells that each use the =INDEX() formula to look up the resulting cell. For instance, cell H6 contains =INDEX(Number_Matrix,D6,E6), where column D is the Down column and column E is the Across column.
But I realized that I'm sampling without eliminating replacements. Sure, it only happens once in a while (I ran the sample about 25 times before I came up with a duplicate value), but I'd like to eliminate it entirely.
I've found examples on the web where people use VBA to draw random samples without replacement, but only where the population data is one column only, not in a table or array. True, I could just change my table into a column that's 240 rows long, but that just seems so inelegant.
Does anyone have an idea about how to perform sampling without replacement on a table or array? I've been racking my brain on this for a while, and I just can't think about where to start. I can follow most the VBA code I see online, but the leap of logic from using a single column to using a table for the original data is leaving me behind.
Thanks,
Andreas