Hi There
How do you fit a gamma distribution to random data while fixing one of the gamma distribution parameters? Lets say we fix the shaping factor k for example and try to find the scaling factor Thetha of the gamma pdf? How is this done in Matlab?

 채택된 답변

Tom Lane
Tom Lane 2012년 4월 7일

1 개 추천

Expanding on what Wayne wrote, you can supply your fixed-parameter version of the gamma distribution to the mle function. Try this:
x = gamrnd(1.1,100,100,1);
ab = gamfit(x) % fit a and b
b = mle(x,'pdf',@(x,b)gampdf(x,1,b),'start',1) % fix a=1
% compare the empirical distribution and two fits
ecdf(x);
xx = linspace(0,max(x));
line(xx,gamcdf(xx,ab(1),ab(2)),'color','r')
line(xx,gamcdf(xx,1,b),'color','c')

댓글 수: 3

Wayne King
Wayne King 2012년 4월 7일
That was the piece I was missing! thanks Tom
Bhekisizwe
Bhekisizwe 2012년 4월 8일
Thanks guys, Thanks a lot...this will definately help me...:-)
GM Fahad Bin Mostafa
GM Fahad Bin Mostafa 2019년 2월 21일
Hi Tom
I want to fit excel data with gamma in matlab. Would you please help me?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Wayne King
Wayne King 2012년 4월 7일

0 개 추천

You can use either mle() with the 'Distribution','gamma'
gamfit()
or fitdist() with 'gamma'. All require the Statistics Toolbox.
R = gamrnd(5,2,1e3,1);
gpdf = fitdist(R,'gamma');
[phat,phatci] = gamfit(R);
%same as
[phat,phatci] = mle(R,'Distribution','gamma');
Once you fix one of the parameters, you can create gamma pdfs by varying the other using gampdf and fit that to your data.

카테고리

도움말 센터File Exchange에서 Gamma Functions에 대해 자세히 알아보기

질문:

2012년 4월 7일

댓글:

2019년 2월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by