MATLAB: Sum Function - Solving Probability Mass Function

  • Context: MATLAB 
  • Thread starter Thread starter Apudapa
  • Start date Start date
  • Tags Tags
    Function Matlab Sum
Click For Summary
SUMMARY

The discussion focuses on calculating the expectation value of a Poisson distribution using MATLAB's sum function. The user initially attempted to compute the probability mass function (PMF) with a loop from k=1 to 1000 but faced issues summing the results. After resolving some initial problems, they encountered NaN results when increasing k beyond 400, questioning the behavior of the PMF at high values. The conversation emphasizes the importance of proper initialization and handling of numerical limits in MATLAB.

PREREQUISITES
  • Understanding of Poisson distribution and its probability mass function (PMF).
  • Familiarity with MATLAB programming, specifically loops and summation techniques.
  • Knowledge of numerical stability and handling of large values in computations.
  • Experience with MATLAB's built-in functions for mathematical operations.
NEXT STEPS
  • Explore MATLAB's vectorization techniques to optimize summation processes.
  • Learn about MATLAB's handling of floating-point arithmetic and numerical limits.
  • Investigate alternative methods for calculating expectation values in probability distributions.
  • Study the use of MATLAB's 'poisspdf' function for direct computation of Poisson probabilities.
USEFUL FOR

Mathematics students, data analysts, and engineers working with probability distributions in MATLAB, particularly those interested in statistical modeling and numerical methods.

Apudapa
Messages
1
Reaction score
0
Hey,

I'm new to MATLAB and was stuck on a problem which requires me to calculate the expectation value of a poisson distribution by summing the probability mass function *k ie P = k*lambda^k*exp(-lambda)/factorial(k) for k= 1 to infinity. I thought of using "for k1:1000 P =... " but then had no idea how to sum the individual results. Any help much appreciated. =)

edit: I think I've sorted it out now by having a sum term initialised before and included into the loop. However, I am finding that if I increase k to above a value of 400 or so, both the answer for the poisson process and the sum become NaN. Surely, the probability should just reach 0 and the expectation value just 5. Is there any way to avoid this?
 
Last edited:
Physics news on Phys.org
Welcome to PhysicsForums! Can you post the code from your m-file? (Please put it between the [ code][/ code] tags without spaces inside the square brackets).
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 19 ·
Replies
19
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 12 ·
Replies
12
Views
4K
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
5K