Carmen
Carmen

Reputation: 793

Assign outcomes to discrete distribution Matlab

I am trying to fit a distribution to a discrete dataset. The possible outcomes are A = [1 3 4 5 9 10] with a respective probability of prob

prob = [0.2 0.15 0.1 0.05 0.35 0.15];

I have used makedist to find the distribution

pd = makedist('Multinomial','probabilities', prob);

I wonder if there is a way to include the outcomes 1 to 10 from A in the distribution, such that I can calculate the mean and the variance of the possible outcomes with var(pd), mean(pd). Up till now the mean is 3.65, but my aim is it to have mean(pd) = 5.95, which is the weighted sum of the possible outcomes . Thanks in advance.

Upvotes: 1

Views: 90

Answers (1)

Tommaso Belluzzo
Tommaso Belluzzo

Reputation: 23685

The solution is pretty easy. The possible outcomes of a multinomial distrubution are defined by a sequence of values starting at 1 and ending at numel(prob). From this official documentation page:

Create a multinomial distribution object for a distribution with three possible outcomes. Outcome 1 has a probability of 1/2, outcome 2 has a probability of 1/3, and outcome 3 has a probability of 1/6.

pd = makedist('Multinomial','probabilities',[1/2 1/3 1/6])

Basically, your vector of possible outcomes includes a few values associated to a null (signally 0) probability. Thus, define your distribution as follows in order to obtain the expected result:

p = [0.20 0.00 0.15 0.10 0.05 0.00 0.00 0.00 0.35 0.15];
pd = makedist('Multinomial','probabilities',p);

mean(pd) % 5.95
var(pd) % 12.35

Upvotes: 1

Related Questions