How do you fit a gamma distribution?

Bhekisizwe · Apr 11, 2022 · 2K views
Question
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?  
Expert Answer
Profile picture of Kshitij Singh
Kshitij Singh PhD Expert
Answered Aug 24, 2026

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')

 

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!