MATLAB: How can i calculate a equation including exceeding value of realmax

calculatefactorialrealmax

Hi I want to calculate some kind of Poisson random variable. However, when i calculate 1000^x/factorial(x) with large x, the result comes NAN. I know the value of each 1000^x or factorial(x) exceeds the realmax. But, the calculated value of 1000^x/factorial(x) doesn't exceed the realmax. Is any other method to calculate that equation?

Best Answer

It is essential that you include the exp(-lambda), which is part of the Poisson distribution, in your calculations.
p(x,lambda) = exp(-lambda+x*log(lambda)-sum(log(1:x)));