Number of experiments for a Bernoulli variable.
n = conint_bernoullipnumber ( len ) n = conint_bernoullipnumber ( len , level ) n = conint_bernoullipnumber ( len , level , pe )
a 1-by-1 matrix of doubles, positive, the length of the required C.I.
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 doubles, an estimate of the probability of success (default pe = 0.5)
a 1-by-1 matrix of doubles, the number of trials
Returns the number of experiments which guarantees that the
length of the confidence interval for the
probability of success of a Bernoulli variable
is less than len
.
In other words, if pe
is the estimate of
the probability of success
with n
trials, then
[low, up] = conint_bernoullip ( pe , n )
is so that
abs(up-low) <= len
To compute n
, we assume that the random variable
has Binomial distribution.
This function makes the assumption that the data
in x
has a binomial distribution with
parameters p
and
n
.
The default value pe=0.5
guarantees that the number of experiments is large enough,
no matter the actual value of the probability p
.
In other words, if pe
is not provided
be the user, the value of the output variable n
is guaranteed, but might be much too large than required.
// From Gilbert Saporta, // Section 13.5.4 Intervalle de confiance // pour une proportion p // p.313 len = 0.05*2 level = 1.-0.90 n = conint_bernoullipnumber ( len , level ) // Therefore, it requires 271 experiments // to make sure that the 90% C.I. for p // has a length no greater than 0.1. // Reproduce the table p 313. mprintf("level = %9s %9s %9s %9s", .. " ", "1.-0.90", "1.-0.95", "1.-0.98") for len = 2*[0.01 0.02 0.05] mprintf("len = %9s, n = ", string(len)) for level = 1.-[0.90 0.95 0.98] n = conint_bernoullipnumber ( len , level ); mprintf("%9s ", string(n)); end mprintf("\n"); end // From Sheldon Ross, // Example 7.5c // Estimate the failure rate of computer chips. len = 0.05 // Compute n for 95% C.I. n = conint_bernoullipnumber ( len ) // Compute n for 99% C.I. level = 1.-0.99 n = conint_bernoullipnumber ( len , level ) // Compute n for 99% C.I. and probability estimate // From 30 sample computer chips, there are // 26. chips which works. pe = 26. / 30. n = conint_bernoullipnumber ( len , level , pe ) // It may require 1227 experiments to get a // 99 C.I. with length less than 0.05. // How many experiments to estimate accurately a // small probability with 95% C.I. ? level = 1.-0.95; for pe = logspace(-1,-7,7) len = pe/10.; n = conint_bernoullipnumber ( len , level , pe ); mprintf("pe = %-9s, len = %-9s, n = %-9s\n", .. string(pe), string(len), string(n)) end | ![]() | ![]() |
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