Anyone remember more of their stats than I do offhand?
I have a distribution function foo() that should return 1..n values in an approximately even random distribution.
To test this, I intend to collect N values returned and produce a histogram of them. This should return exactly n different values, all of which should have at least min instances
(
Read more... )
Comments 11
I remember trying something like this in BASIC on a BBC B about 22 years ago...
I also think something in crypto-analysis has a relevent overlap in such functions?
Reply
Reply
I think you need a one-tailed normal distribution confidence test. Here's why.
Define "success" to be "a specific number is rolled" (say, 3, but it doesn't actually matter). And you want to be 95 % confident of getting at least min of them.
I *think* the total number of successes, S, is distributed binomially (N,1/n) (i.e. number of trials, probability of success in a single trial). The binomial distribution is a tidy one with mean and standard deviation both equal to number of trials * probability of success, which in this case is N/n. You can approximate this with a normal distribution with mean and standard deviation both equal to (N/n) - this is your critical fact.
So now you need to find N such that p(S < (min-N/n)/(N/n)) <= 0.95. (I've normalized the distribution because tables only give distribution for mean and standard deviation 1 ( ... )
Reply
To get min successes you would expect on average to need to roll min * n times. Because on average you get 1 success every n rolls. That's the jolly old binomial distribution for you. So for example with 100 numbers, to get 5 successes on average you need 500 rolls. Yep, that sounds right.
That's a big enough N and small enough 1/n that the normal approximation is valid. Happy with that too, and still pretty sure that mean and sd of binomial is N/n.
One-tailed confidence test threshold is 1.645 * standard deviation away from the mean. That would be 1.645 * N/n. This is all good so far. It's the last bit I'm struggling with.
Doh! Looks it up on wikipedia. Standard deviation of binomial distribution is sqrt(N/n(1-1/n)). Apologies! Told you to check it...everything should start to work from here on in.
Reply
Back at work today, I'll see how I get on with it.
Reply
min = N/n - 1.645 * sqrt(N/n(1 - 1/n))
Reply
min = N/n - 1.645 * sqrt(N/n(1 - N/n))
Give that a go and see if it gives you anything sensible.
Reply
obviously...
Reply
Reply
Reply
Reply
Leave a comment