MATLAB: Sum Function - Solving Probability Mass Function

In summary, the individual is new to MATLAB and was stuck on a problem involving calculating the expectation value of a poisson distribution. They thought of using a for loop but were unsure of how to sum the results. After some trial and error, they were able to sort out the issue by initializing a sum term and including it in the loop. However, they encountered a problem when increasing the value of k, as both the answer for the poisson process and the sum became NaN. They are wondering if there is a way to avoid this and still get the expected result of 0 for the probability and 5 for the expectation value.
  • #1
Apudapa
1
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
  • #2
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).
 

FAQ: MATLAB: Sum Function - Solving Probability Mass Function

What is the MATLAB Sum Function?

The MATLAB Sum Function is a built-in function that calculates the sum of all the elements in a given array or matrix. It can also be used to calculate the cumulative sum of all elements in an array.

How can the Sum Function be used to solve Probability Mass Functions (PMF)?

The Sum Function can be used to solve PMFs by calculating the total probability of all possible outcomes in a discrete probability distribution. This is done by adding up the individual probabilities of each outcome.

What is a Probability Mass Function (PMF)?

A Probability Mass Function is a function that describes the probability of a discrete random variable taking on a certain value. It maps each possible outcome to its corresponding probability. In other words, it shows the likelihood of each possible outcome occurring.

How do you input a PMF into the MATLAB Sum Function?

To input a PMF into the MATLAB Sum Function, you first need to define the discrete random variable and its corresponding probabilities as arrays. Then, you can use the Sum Function to calculate the total probability by passing in the array of probabilities as the input argument.

Can the Sum Function be used to solve continuous probability distributions?

No, the Sum Function is not suitable for solving continuous probability distributions as it can only calculate the sum of discrete values. For continuous distributions, the integral function should be used instead.

Similar threads

Replies
1
Views
2K
Replies
8
Views
1K
Replies
4
Views
1K
Replies
1
Views
1K
Replies
1
Views
1K
Replies
1
Views
2K
Replies
19
Views
2K
Replies
4
Views
4K
Back
Top