MATLAB: Formula for Poisson distribution

functionguiplotpoisson

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

Best Answer

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)