pois_d.m

来自「计量工具箱」· M 代码 · 共 38 行

M
38
字号
% PURPOSE: demo of poisson distribution functions
%          prints mean and variance of 1000 draws
%          plots pdf,cdf,inverse
% 
%---------------------------------------------------
% USAGE: pois_d
%---------------------------------------------------

n = 1000;
lam = 10;

tic;
tst = pois_rnd(n,lam);
toc;

% mean should equal lam
fprintf('mean should = %16.8f \n',lam);
fprintf('mean of draws = %16.8f \n',mean(tst));
fprintf('variance should = %16.8f \n',lam);
fprintf('variance of draws = %16.8f \n',std(tst)*std(tst));

tst = round(unif_rnd(n,1,20));
tsts = sort(tst);

pdf = pois_pdf(tsts,lam);
plot(tsts,pdf);
title('poisson pdf over 1 to 20 with mean=10');
pause;

cdf = pois_cdf(tsts,lam);
plot(tsts,cdf);
title('poisson cdf over 1 to 20 with mean=10');
pause;

pinv = pois_inv(cdf,lam);
plot(tsts,pinv);
title('poisson quantiles over 1 to 20 with mean=10');

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?