<< Conint Conint conint_bernoullipnumber >>

Conint >> Conint > conint_bernoullip

conint_bernoullip

C.I. of the probability of a Bernoulli variable.

Calling Sequence

[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 )

Parameters

pe :

a 1-by-1 matrix of doubles, an estimate of the probability

n :

a 1-by-1 matrix of doubles, integer value, positive, the number of trials

level :

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]

twosided :

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].

method :

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

low :

a 1-by-1 matrix of doubles, the estimated lower bound

up :

a 1-by-1 matrix of doubles, the estimated upper bound

Description

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.

Examples

// From Sheldon Ross, Example 7.5a, p.262
// We experimented with 100 transistors :
// 80 transistors works.
// Compute a 95% confidence interval for p,
// the probability that a transistor works.
pe = 80./100.;
n = 100;
[low, up] = conint_bernoullip ( pe , n , 1.-0.95 )
// Then (0.7216,0.8774) is an approximate 95% C.I. for p.

// From Gilbert Saporta
// Section 13.5.4 Intervalle de confiance
// pour une proportion p
n = 400;
pe = 0.36;
[low, up] = conint_bernoullip ( pe , n , 1.-0.95 )
// Then (0.31,0.41) is an approximate 95% C.I. for p.

// Try various methods
// From Statistics: problems and solutions
// Edward Eryl Bassett,J. M. Bremner,B. J. T. Morgan
// "4C Binomial and Poisson distributions"
// "4C3 Women investors in building societies"
// p.148
pe = 22./80.;
n = 80;
level = 1.-0.90
twosided = %t
[low, up] = conint_bernoullip ( pe , n , level , twosided )
// Then (0.193,0.357) is a 90% C.I. for p.
// The quadratic or Wilson (1927) interval :
method = 2;
[low, up] = conint_bernoullip ( pe , n , level , twosided , method )
// Then (0.201,0.363) is an approximate 90% C.I. for p.
// Invert the Binomial: the Clopper-Pearson interval
method = 3
[low, up] = conint_bernoullip ( pe , n , level , twosided , method )
// Then (0.188,0.352) is an approximate 90% C.I. for p.

Authors

Bibliography

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


Report an issue
<< Conint Conint conint_bernoullipnumber >>