Generate a Poisson random variable

4 visualizaciones (últimos 30 días)
ABUL HASNAT
ABUL HASNAT el 9 de Mzo. de 2020
Respondida: the cyclist el 9 de Mzo. de 2020
The problem I need to solve is as below:
To generate a Poisson random variable with parameter λ use the following:
X=min ∑Ui exp(-λ) ; i=1,2...n
where Ui are i.i.d samples from the uniform distribution.
Show that X is Poisson (λ). Plot them.
How to solve this?
  2 comentarios
Image Analyst
Image Analyst el 9 de Mzo. de 2020
Have you tried a for loop:
for i = 1 : n
ABUL HASNAT
ABUL HASNAT el 9 de Mzo. de 2020
I have tried this way:
a=0;b=1;
ns =10000;% ns = sample size
S = zeros(ns,1);
Y = zeros(ns,1);
lambda = 4;
for i=1:ns; % starting loop
n = 0; %minimum n
U=a+(b-a)*rand;
while U>=exp(-lambda); % repeat if prod is less than or equal to exp(-lambda)
U=U*[a+(b-a)*rand];
n=n+1;
end
Y(i) = U;
S(i)=n;
bar(S);
end
xlabel('Sample size');ylabel('Poisson random variables');
But the output is not possion look alike. How can I prove it? Help.

Iniciar sesión para comentar.

Respuesta aceptada

the cyclist
the cyclist el 9 de Mzo. de 2020
Use
histogram(S)
instead of
bar(S)
and move that line out of the for loop, so you don't have to draw it 10,000 times. :-)

Más respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by