Confidence interval using binofit
Afficher commentaires plus anciens
Hello all,
I was doing a test using binofit to calculate the confidence interval for a binomial distribution. I found that the confidence interval corresponds to the desired confidence level only when p is not very small. When p is small the obtained confidence level is higher than desired.
For a 95% I tried:
N=1000;
g=zeros(N,1);
Nb = 1000;
p = 1/5;
for n=1:N
x=binornd(Nb,p);
[phat,pci]=binofit(x,Nb);
g(n)= (p>pci(1)) && (p<pci(2));
end
sum(g)/N
ans =
0.9570
However, if p is decreased by a factor of 100:
N=1000;
g=zeros(N,1);
Nb = 1000;
p = 1/500;
for n=1:N
x=binornd(Nb,p);
[phat,pci]=binofit(x,Nb);
g(n)= (p>pci(1)) && (p<pci(2));
end
sum(g)/N
ans =
0.9900
Any idea of why this happens? Is there a better way to calculate the confidence interval in this case?
Thanks in advance
Réponse acceptée
Plus de réponses (1)
Javier
le 14 Sep 2012
0 votes
Catégories
En savoir plus sur Binomial Distribution dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!