MATLAB | calculating gamma distance parameters based on average and probability intervals

I have a system of two equations with two unknowns that I want to solve using MATLAB, but I don’t know exactly how to program. I was given information on the gamma distribution (average 1.86, 90% interval between 1.61 and 2.11) and ultimately they want to get the average and variance. I know that I could use the usual approximation, but I would rather decide for A and B, the parameters of the shape and scale of the gamma distribution, and find the average and variance in this way. In the pseudo-MATLAB code, I would like to solve the following:

gamcdf(2.11, A, B) - gamcdf(1.61, A, B) = 0.90;
A*B = 1.86;

How would you decide to solve this? I have a symbolic math toolkit if that helps.

+3
source share
1 answer

The average value of A * B. So can you decide, perhaps, A in terms of means (mu) and B?

A = mu/B

Of course, it was of no use if you did not know B. Or is it?

Look at your first expression. Can you replace?

gamcdf(2.11, mu/B, B) - gamcdf(1.61, mu/B, B) = 0.90

Does it bring you closer? May be. There will be no useful symbolic solution, except in terms of the most incomplete gamma function. How do you solve one equation numerically in one unknown in Matlab? Use fzero.

Of course, fzero is looking for a null value. But by subtracting 0.90, this is allowed.

Is it possible to define a function that fzero can use? Use function descriptor.

>> mu = 1.86;
>> gamfun = @(B) gamcdf(2.11, mu/B, B) - gamcdf(1.61, mu/B, B) - 0.90;

So give it a try. Before we do this, I always recommend plotting things.

>> ezplot(gamfun)

. , . , , fzero.

, . fzero, -, .

>> B = fzero(gamfun,[.0000001,.1])
B =
        0.0124760672290871
>> A = mu/B
A =
          149.085442218805
>> ezplot(@(x) gampdf(x,A,B))

"", .. , .

+5

Source: https://habr.com/ru/post/1764279/


All Articles