matlab箱线图做出来,明明两个图均值都在0处的,为什么放一起第二个会偏下方呢?请高人指教一下!
clc;clearall;n=1:1:1000;f1=zeros(size(n));f=zeros(size(n));y=1;g=zeros(size(n));f2=ze...
clc;
clear all;
n=1:1:1000;
f1=zeros(size(n));
f=zeros(size(n));
y=1;
g=zeros(size(n));
f2=zeros(size(n));
F1=zeros(size(n));
F2=zeros(size(n));
g1=zeros(size(n));
g2=zeros(size(n));
g3=zeros(size(n));
F3=zeros(size(n));
F4=zeros(size(n));
for s=1:numel(n)
x=trnd(3,30,1);
[M,N]=size(x);
for k=1:M
if x(k)<=y
I=1;
else
I=0;
end
f1(s)=x(k).*I;
f(s)=f(s)+f1(s);
g(s)=f(s)./M;%%%%%%%%Pnf
g2(s)=I;
g3(s)=g3(s)+g2(s);
g4(s)=g3(s)./M;%%%%%%%%%%Fn
end
f2(s)=integral(@(x) tpdf(x,3),-inf,y);%%%%%%%F
X(s)=mean(x);
F1(s)=(g(s)-y.*g4(s))./(y-X(s)+2*g(s)-2*g4(s));%%%%%%%%Gn
g1(s)=integral(@(x) x.*tpdf(x,3),-inf,y);%%%%%Pf
F2(s)=(g1(s)-y.*f2(s))./(2*(g1(s)-y.*f2(s))+y-0);%%%%%%%G
F3(s)=F1(s)-F2(s);
end
for s=1:numel(n)
x=trnd(3,100,1);
[M,N]=size(x);
for k=1:M
if x(k)<=y
I=1;
else
I=0;
end
f1(s)=x(k).*I;
f(s)=f(s)+f1(s);
g(s)=f(s)./M;%%%%%%%%Pnf
g2(s)=I;
g3(s)=g3(s)+g2(s);
g4(s)=g3(s)./M;%%%%%%%%%%Fn
end
f2(s)=integral(@(x) tpdf(x,3),-inf,y);%%%%%%%F
X(s)=mean(x);
F1(s)=(g(s)-y.*g4(s))./(y-X(s)+2*g(s)-2*g4(s));%%%%%%%%Gn
g1(s)=integral(@(x) x.*tpdf(x,3),-inf,y);%%%%%Pf
F2(s)=(g1(s)-y.*f2(s))./(2*(g1(s)-y.*f2(s))+y-0);%%%%%%%G
F4(s)=F1(s)-F2(s);
end
w(:,1)=F3;
w(:,2)=F4;
boxplot(w)
改变样本量M的大小,分开画出来都是0均值,放一起就不行了 展开
clear all;
n=1:1:1000;
f1=zeros(size(n));
f=zeros(size(n));
y=1;
g=zeros(size(n));
f2=zeros(size(n));
F1=zeros(size(n));
F2=zeros(size(n));
g1=zeros(size(n));
g2=zeros(size(n));
g3=zeros(size(n));
F3=zeros(size(n));
F4=zeros(size(n));
for s=1:numel(n)
x=trnd(3,30,1);
[M,N]=size(x);
for k=1:M
if x(k)<=y
I=1;
else
I=0;
end
f1(s)=x(k).*I;
f(s)=f(s)+f1(s);
g(s)=f(s)./M;%%%%%%%%Pnf
g2(s)=I;
g3(s)=g3(s)+g2(s);
g4(s)=g3(s)./M;%%%%%%%%%%Fn
end
f2(s)=integral(@(x) tpdf(x,3),-inf,y);%%%%%%%F
X(s)=mean(x);
F1(s)=(g(s)-y.*g4(s))./(y-X(s)+2*g(s)-2*g4(s));%%%%%%%%Gn
g1(s)=integral(@(x) x.*tpdf(x,3),-inf,y);%%%%%Pf
F2(s)=(g1(s)-y.*f2(s))./(2*(g1(s)-y.*f2(s))+y-0);%%%%%%%G
F3(s)=F1(s)-F2(s);
end
for s=1:numel(n)
x=trnd(3,100,1);
[M,N]=size(x);
for k=1:M
if x(k)<=y
I=1;
else
I=0;
end
f1(s)=x(k).*I;
f(s)=f(s)+f1(s);
g(s)=f(s)./M;%%%%%%%%Pnf
g2(s)=I;
g3(s)=g3(s)+g2(s);
g4(s)=g3(s)./M;%%%%%%%%%%Fn
end
f2(s)=integral(@(x) tpdf(x,3),-inf,y);%%%%%%%F
X(s)=mean(x);
F1(s)=(g(s)-y.*g4(s))./(y-X(s)+2*g(s)-2*g4(s));%%%%%%%%Gn
g1(s)=integral(@(x) x.*tpdf(x,3),-inf,y);%%%%%Pf
F2(s)=(g1(s)-y.*f2(s))./(2*(g1(s)-y.*f2(s))+y-0);%%%%%%%G
F4(s)=F1(s)-F2(s);
end
w(:,1)=F3;
w(:,2)=F4;
boxplot(w)
改变样本量M的大小,分开画出来都是0均值,放一起就不行了 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询