1
$\begingroup$

Let's say I have a function simulate() that returns True with some probability $p$ and False otherwise.

After calling simulate() $N$ times, I get True $x$ times and False $N - x$ times. I then compute $p' = \frac{x}{N}$. How do I measure my error on $p'$? My ultimate goal is to figure out whether $p > 0.5$ for my simulate() function, and I want to know how many trials I have to conduct to be confident in my result.

$\endgroup$
3
  • $\begingroup$ Many answers to questions just like can be found at stats.stackexchange.com/…. $\endgroup$
    – whuber
    Commented Nov 25, 2016 at 18:18
  • $\begingroup$ How many trials depends on the true value of p. If p=1, you can be very confident that p>0,5 after a handful of trials, but if p=0.5000001 you might need some milions of trials before being confident that p>0,5. $\endgroup$
    – Pere
    Commented Nov 25, 2016 at 18:20
  • 1
    $\begingroup$ Sounds like you are after a test of a binomial proportion or a binomial confidence interval. Search for answers to questions about them on this site. $\endgroup$ Commented Nov 25, 2016 at 23:15

3 Answers 3

1
$\begingroup$

Your data are independent binary variables with a fixed probability, so the count value you are seeking is a binomial random variable. You already have a point estimate, so the next step is to use an appropriate interval estimator, such as a confidence interval. This is a very well-known problem, so I recommend you start by reading some textbook presentations of binomial confidence intervals. You can also read Brown et al (2001) for an overview of available methods, and comparison between methods.

$\endgroup$
1
$\begingroup$

By virtue of the fact that $X$ has a binomial distribution, we know that the standard error for $p'$ is $p(1-p)/N$. Now $p$ is the unknown variable we wish to estimate so we get an estimate by replacing $p$ with $p'$. If $N$ is large enough we can use a normal approximation for $p'$ and take $\pm 2$ estimated standard deviations around $p'$ as an approximate 95% confidence interval for $p'$. This would be a two-sided interval. Since you only want to know if $p>0.5$, you might prefer using a one-sided interval.

$\endgroup$
0
$\begingroup$

You are working with a binomial distribution. Its variance for a sample of n observations with a "p" chance of getting a "true result" is np(1-p)

Therefore its standard deviation will be the square root of np(1-p) (use the results you got before to estimate p, ie: use the sample p as "kind-of-the-true-p") You can now calculate confidence intervals and all those cool things you can do with normal distributions (for a large enough sample, it will behaive similarly)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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