how to draw the cdf and pdf of a this multinomial distribution
1 次查看(过去 30 天)
显示 更早的评论
clc clear all format compact rng(970,'v4') X1=[]; X2=[]; X3=[]; U=[]; Y=[]; p =[0.0080 0.0270 0.1250 0.0360 0.0600 0.1350 0.2250 0.0540 0.1500 0.1800]; n = 3; for i = (1:10000) r=rand;
if r<0 & r<=0.0080
x1(i)=0; x2(i)=0; x3(i)=3;
y(i)=1;
X1=[x1];X2=[x2];X3=[x3];
Y=[y];
U=[U,r];
else if r>0.0080 & r<=0.0350
x1(i)=0; x2(i)=3; x3(i)=0;
y(i)=2;
X1=[x1];X2=[x2];X3=[x3];
Y=[y];
U=[U,r];
else if r>0.0350 & r<=0.1600
x1(i)=3; x2(i)=0; x3(i)=0;
y(i)=3;
X1=[x1];X2=[x2];X3=[x3];
Y=[y];
U=[U,r];
else if r>0.1600 & r<=0.1960
x1(i)=0; x2(i)=1; x3(i)=2;
y(i)=4;
X1=[x1];X2=[x2];X3=[x3];
Y=[y];
U=[U,r];
else if r>0.1960 & r<=0.2560
x1(i)=1; x2(i)=0; x3(i)=2;
y(i)=5;
X1=[x1];X2=[x2];X3=[x3];
Y=[y];
U=[U,r];
else if r>0.2560 & r<=0.3910
x1(i)=1; x2(i)=2; x3(i)=0;
y(i)=6;
X1=[x1];X2=[x2];X3=[x3];
Y=[y];
U=[U,r];
else if r>0.3910 & r<=0.6160
x1(i)=2; x2(i)=1; x3(i)=0;
y(i)=7;
X1=[x1]; X2=[x2]; X3=[x3];
Y=[y];
U=[U,r];
else if r>0.6160 & r<=0.6700
x1(i)=0; x2(i)=2; x3(i)=1;
y(i)=8;
X1=[x1];X2=[x2];X3=[x3];
Y=[y];
U=[U,r];
else if r>0.6700 & r<=0.8200
x1(i)=2; x2(i)=0; x3(i)=1;
y(i)=9;
X1=[x1];X2=[x2];X3=[x3];
Y=[y];
U=[U,r];
else if r>0.8200 & r<=1
x1(i)=1; x2(i)=1; x3(i)=1;
y(i)=10;
X1=[x1];X2=[x2];X3=[x3];
Y=[y];
U=[U,r];
end
end
end
end
end
end
end
end
end
end
end
0 个评论
回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!