排列与组合
function y=pailie(n,k)
y=factorial(n)/factorial(n-k);
function y=zuhe(n,k)
y=pailie(n,k)/factorial(k);
>> p=zuhe(5,2)*zuhe(3,2)/zuhe(8,4)
p =
0.4286
二项分布:
>> syms x;
>> x=0:1:20;
>> y=binopdf(x,20,0.3)
y =
Columns 1 through 12
0.0008 0.0068 0.0278 0.0716 0.1304 0.1789 0.1916 0.1643 0.1144 0.0654 0.0308 0.0120
Columns 13 through 21
0.0039 0.0010 0.0002 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
>> plot(x,y,'r.')
>> syms x;
>> x=0:1:20;
>> y=binocdf(x,20,0.3)
y =
Columns 1 through 12
0.0008 0.0076 0.0355 0.1071 0.2375 0.4164 0.6080 0.7723 0.8867 0.9520 0.9829 0.9949
Columns 13 through 21
0.9987 0.9997 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
>> plot(x,y,'r.')
>> ezplot('binocdf(x,20,0.3)',[0,20])
泊松分布:
(1)
>> p=poisspdf(6,3)
p =
0.0504
(2)
>> p=poisscdf(4,3)
p =
0.8153
(3)
>> x=0:1:15;
>> y=poisspdf(x,3);
>> plot(x,y,'r.')
>> title('poisspdf(x,3)')
>> ezplot('poisscdf(x,3)',[0,15])