java 置信区间_仅从均值和标准差绘制置信区间
我試圖從數據的均值和標準差(std)繪制置信區間 . 這是我寫的代碼片段:
MeanA=1.876; %mean of A
STDA=0.018; % std of A
MeanB=1.821;
STDB=0.039;
MeanC=1.735;
STDC=0.023;
MeanD=1.667;
STDD=0.039;
Y = [MeanA MeanB ;
MeanC MeanD ];
errY= [STDA STDB;
STDC STDC ];
如果我繪制正態分布,那么它們的cofidence inteval似乎重疊
alpha = 0.05; % significance level
for tt=1:length(Y)
figure
mu = Y(tt,1); % mean
sigma = errY(tt,1);
cutoff1n = norminv(alpha, mu, sigma);
cutoff2n = norminv(1-alpha, mu, sigma);
xn = [linspace(mu-4*sigma,cutoff1n), ...
linspace(cutoff1n,cutoff2n), ...
linspace(cutoff2n,mu+4*sigma)];
yn = normpdf(xn, mu, sigma);
plot(xn,yn)
mu = Y(tt,2); % mean
sigma = errY(tt,2);
cutoff1 = norminv(alpha, mu, sigma);
cutoff2 = norminv(1-alpha, mu, sigma);
x = [linspace(mu-4*sigma,cutoff1), ...
linspace(cutoff1,cutoff2), ...
linspace(cutoff2,mu+4*sigma)];
y = normpdf(x, mu, sigma);
hold on, plot(x,y)
plot(x,y,'r-',xn,yn,'g-' , 'LineWidth',3)
set(gca,'Fontsize', 32)
if tt==1
hleg1=legend('A', 'B');
title('study1')
elseif tt==2
hleg1=legend('C', 'D');
title('Study2')
end
set(hleg1,'Location','NorthEastoutside')
set(gca,'Fontsize',22)
xlo = [x(x<=cutoff1) cutoff1];
ylo = [y(x<=cutoff1) 0];
patch(xlo, ylo, 'r')
xhi = [cutoff2 x(x>=cutoff2)];
yhi = [0 y(x>=cutoff2)];
patch(xhi, yhi, 'r')
xlon = [xn(xn<=cutoff1n) cutoff1n];
ylon = [yn(xn<=cutoff1n) 0];
patch(xlon, ylon, 'g')
xhin = [cutoff2n xn(xn>=cutoff2n)];
yhin = [0 yn(xn>=cutoff2n)];
patch(xhin, yhin, 'g')
end
我看到了置信區間(CI)重疊的情節 .
現在我需要以CI的形式繪制CI;
有人可以幫助繪制CI周圍的意思
%%
我按以下方式計算Ci:
SE2=errY/sqrt(10);
CI2n=Y-1.96*(SE2);
CI2p=Y+1.96*(SE2);
請告訴它是否正確,如果是,我該如何繪制它們 . 謝謝
總結
以上是生活随笔為你收集整理的java 置信区间_仅从均值和标准差绘制置信区间的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: IOS 为UILabel添加长按复制功能
- 下一篇: laravel项目中css样式表的背景图