Gamfit function not working

5 Ansichten (letzte 30 Tage)
pbarua2
pbarua2 am 29 Apr. 2019
Bearbeitet: John D'Errico am 29 Apr. 2019
Hi, can anyone tell what am I doing wrong in this or give the correct code to find confidence interval for Gamma function?
Here's the code that I wrote
a = 2; b = 4;
r = gamrnd(a,b,100,1);
[p,ci] = gamfit(r);

Antworten (2)

Star Strider
Star Strider am 29 Apr. 2019
Bearbeitet: Star Strider am 29 Apr. 2019
That code runs for me without error.
Is there a problem?
EDIT —
The confidence intervals are for the parameters.

John D'Errico
John D'Errico am 29 Apr. 2019
Bearbeitet: John D'Errico am 29 Apr. 2019
Do you seriously expect to recover the exact values of those parameters? With only 100 samples, the CI are pretty wide.
[p,ci] = gamfit(r)
p =
2.1896399976245 3.4111990831996
ci =
1.69026534773641 2.55050801547712
2.83655067863624 4.56233782235144
Now, try it again, but with a larger sample size.
r = gamrnd(a,b,10000,1);
>> [p,ci] = gamfit(r)
p =
1.97058207162021 4.11621427675147
ci =
1.92055036089918 3.9975075019774
2.02191714419451 4.23844607264689
It seems to be working fine. The parameters are converging to the original values. Small sample sizes are always going to be a limitation of any such parameter estimation. Remember, the gamma distribution chosen is one that is skewed.
fplot(@(x) gampdf(a,b,x))
untitled.jpg

Kategorien

Mehr zu Gamma Functions finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by