0
$\begingroup$

If every time a condition is evaluated, there is exactly an x chance of it succeeding (RAND() < x), is there any way to simulate this formula n times, in order to get the number of successes?

I'm not asking about an average, although, if the formula worked as expected, higher values of nwould have results getting closer to the average.

Bit of background info:

I'm addressing this from a programming perspective, so the simple (yet expensive) solution would be to iteration i = 0 to n, evaluate RAND() < x, and count the number of successes.

However, I'll be dealing with quite varied values of n, from very low, to quite high, and performance will be quite critical. Evaluating RAND() 1,000,000 times just to simulate this is quite unideal.

$\endgroup$
0
$\begingroup$

You don't need to simulate. You can compute the probability of $k$ successes in $n$ trials using the binomial formula or the normal approximation (for large $n$).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.