Confidence interval using binofit
이전 댓글 표시
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
채택된 답변
추가 답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Binomial Distribution에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!