Gamfit function not working
Afficher commentaires plus anciens
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);
Réponses (2)
Star Strider
le 29 Avr 2019
Modifié(e) : Star Strider
le 29 Avr 2019
0 votes
That code runs for me without error.
Is there a problem?
EDIT —
The confidence intervals are for the parameters.
John D'Errico
le 29 Avr 2019
Modifié(e) : John D'Errico
le 29 Avr 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))

Catégories
En savoir plus sur Gamma Distribution dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!