C.I. of the probability of a Bernoulli variable.
[low, up] = conint_bernoullip ( pe , n ) [low, up] = conint_bernoullip ( pe , n , level ) [low, up] = conint_bernoullip ( pe , n , level , twosided ) [low, up] = conint_bernoullip ( pe , n , level , twosided , method )
a 1-by-1 matrix of doubles, an estimate of the probability
a 1-by-1 matrix of doubles, integer value, positive, the number of trials
a 1-by-1 matrix of doubles, the confidence level (default level = 1.-0.95=0.05). level is expected to be in the range [0.,0.5]
a 1-by-1 matrix of booleans, the side of the interval (default twosided = %t). If twosided is true, then low and up is a two-sided interval [low,up]. If twosided is false, then the intervals are [-inf,up] and [low,inf].
a 1-by-1 matrix of doubles, integer value, the method to estimate the C.I. Available values are method=1,2,3 (default method = 1). If method=1, then approximates the Binomial distribution with the Normal distribution. If method=2, then
a 1-by-1 matrix of doubles, the estimated lower bound
a 1-by-1 matrix of doubles, the estimated upper bound
Computes a confidence interval of the probability
p
of a Bernoulli variable.
This function makes the assumption that the data
in x
has a binomial distribution with
parameters p
and
n
.
In other words, we consider that the random variable is a "success" with probability
p
and is a "failure" with probability
1-p
.
We assume that we have performed n
trials
of this experiment.
We assume that pe
is the fraction of the n
trials which are successes.
This function computes confidence intervals for p
.
If twosided
is true, then
low
and up
are such that
the probability p
satisfies the equality
P(low < p < up) = 1-level
If twosided
is false, then
low
and up
are such that
the probability p
satisfies the equality
P(p < up) = 1-level
and
P(low < p) = 1-level
The confidence interval that we compute is approximate. It is based on the Central Limit Theorem. We use a Normal distribution to compute the confidence interval.
If method=1, then approximates the Binomial distribution with the Normal distribution. Then computes approximate roots of the quadratic equation. This is the "Textbook" formula.
If method=2, then approximates the Binomial distribution with the Normal distribution. Then computes exact roots of the quadratic equation. This is the Wilson (1927).
If method=3, then invert the quantiles of the Binomial distribution with the Normal distribution. This is the Clopper-Pearson interval.
http://en.wikipedia.org/wiki/Confidence_interval
"Introduction to probability and statistics for engineers and scientists", Sheldon Ross, Third Edition, 2004
"Probabilités, Analyse de Données et Statistique", Gilbert Saporta, 2nd Ed., 2006
http://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval