Controlling Random Number Generation

S

Sharkbyte

I am trying to figure out a way to "randomly" generate a number, between 1 &
6; however, the caveat is that I also have percentages that each number
should appear in.

For example: The number five should appear 24.6%, over a 10000 number
sample. (This should allow for some level of standard deviation for 100
number increments.)

The only thing I can think of is to create a table of all the numbers, based
on their percetnages, and then randomly select records from that table.
 
G

George Nicholson

"Randomly" generate numbers within given probabilities.
Create a table similar to:

Num Indv% Cum%
1 0.10 0.10
2 0.14 0.24
3 0.17 0.41
4 0.204 0.614
5 0.246 0.86
6 0.14 1.00

Where Num is your number, Indv% is the probability of that number and Cum%
is the "running total" of all Indv%s (not to exceed 1)
Assuming Rand is between 0 and 1

NewNum = DMin("[Num]","MyTable","[Cum%] >= " & rand)
Translates: Of all the records where Cum% is greater than or equal to Rand,
what is the smallest Num?"
Rand values between 0.6141 and 0.86 (roughly 24.6% of the time) would give
you a 5.

I'm used to doing this in Excel (VLookup on Cum column, return the value
from Num). Never done it in Access, can't think of a reason it wouldn't work
but that doesn't mean there isn't a better way out there. :)

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top