caculate confidence interval from customized pdf
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi
I'm wondering How can I caculate the confidence interval of customized pdf e.g. Gaussian mixture distribution?
pdf=@(x) w1*normpdf(x,mu1,sigma1)+w2*normpdf(x,mu2,sigma2);
cdf=@(x) integral(pdf,-Inf,x);
As icdf function only support specified distribution, I'm wondering how to caculate the shortest confidence interval?
댓글 수: 0
채택된 답변
David Goodmanson
2024년 3월 19일
편집: David Goodmanson
2024년 3월 19일
Hello SX,
Ordinarily to find the cdfs you would have to use numerical integration. In this case for the normal distributions, the cdf function is available. Then you can interpolate using the cdf as the independent variable. Here is an example. In the plot you get a wide minimum which you might expect.
mu1 = 1;
mu2 = 2;
sig1 = 1;
sig2 = 3;
w1 = .3;
w2 = .7;
c = .9; % confidence span, there is probably a better name for this
x = -20:.00001:20;
cdf = w1*normcdf(x,mu1,sig1) +w2*normcdf(x,mu2,sig2);
cdn = linspace(min(cdf),max(cdf)-c,1e4);
xdn = interp1(cdf,x,cdn);
cup = linspace(min(cdf)+c,max(cdf),1e4);
xup = interp1(cdf,x,cup);
figure(1); grid on
plot(xup-xdn)
[x0 ind] = min(xup-xdn);
xdn(ind) % lower end of confidence interval
xup(ind) % upper end of confidence interval
cdn(ind) % lower cdf value
cup(ind) % upper cdf value
% ans = -2.4087
% ans = 6.3858
% ans = 0.0497
% ans = 0.9497
D = xup(ind)-xdn(ind) % the result
cup(ind)-cdn(ind) % check, should be c = confidence span
% D = 8.7945
% ans = 0.9000
% try a different case, get a larger confidence interval
xtest = interp1(cdf,x,[.07 .97]);
Dtest = diff(xtest)
% xtest = -1.8602 7.1554
% Dtest = 9.0156
댓글 수: 3
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Descriptive Statistics and Visualization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!