www.gusucode.com > stats 源码程序 matlab案例代码 > stats/ComputeThePoissonDistributionPdfExample.m

    %% Compute the Poisson Distribution pdf

% Copyright 2015 The MathWorks, Inc.


%%
% Create a Poisson distribution object with the rate parameter, $\lambda$,
% equal to 2.
lambda = 2;
pd = makedist('Poisson',lambda);

%%
% Define the input vector _x_ to contain the values at which to calculate
% the pdf.
x = [0 1 2 3 4];

%%
% Compute the pdf values for the Poisson distribution at the values in _x_.
y = pdf(pd,x)

%%
% Each value in _y_ corresponds to a value in the input vector _x_. For
% example, at the value _x_ equal to 3, the corresponding pdf value in _y_
% is equal to 0.1804.

%%
% Alternatively, you can compute the same pdf values without creating a
% probability distribution object. Use the |pdf| function, and specify a
% Poisson distribution using the same value for the rate parameter,
% $\lambda$.
y2 = pdf('Poisson',x,lambda)

%%
% The pdf values are the same as those computed using the probability
% distribution object.