Formula for Poisson distribution
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
amit nestor
el 14 de Abr. de 2016
Respondida: Christos Papadakis
el 16 de Nov. de 2019
Hi,
I've been trying to write a formula that will allow me to create a graph matching the Poisson Dist. for frequency as a function of the parameter (in this instance, K).
for some reason, I cant get Matlab to run it, and was wandering if any of you can see my problem:
function f = poisson (x,a) f = ((a(1)^x)/factorial(round(x)))*e^(-a(1))*a(2) + a(3);
thnaks
0 comentarios
Respuesta aceptada
Jos (10584)
el 14 de Abr. de 2016
I am not sure why you have three parameters rather than 1. See https://en.wikipedia.org/wiki/Poisson_distribution
In your code, you might want to use element wise operators, and use exp
function f = poisson (k, lambda)
f = (lambda.^k) .* exp(-lambda) ./ factorial(k)
0 comentarios
Más respuestas (1)
Christos Papadakis
el 16 de Nov. de 2019
Can someone tell me what is the difference of the above mentioned formula with the matlag function poissrnd?
In the case of the formula above, as expected , for given k and lambda we get a number between 0 and 1. On the other hand, when I call poissrnd(lambda) I get positive integers lower than lambda.
I did a Google search on that but even Matlab says that :
"r = poissrnd(lambda) generates random numbers from the Poisson distribution specified by the rate parameter lambda. "
But I do not understand exactly why is there such a difference. Sorry if my question is stupid.
Thanks in advance!
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!