How to compute log likelihood (which function to use) in Matlab the when the data is not normally distributed

S
savieklkdnf · Jun 29, 2022 · 2K views
Question
Hi! I was wondering how to compute (which function to use) in Matlab the log likelihood but when the data is not normally distributed. Thanks!
Expert Answer
Profile picture of John Williams
John Williams PhD Expert
Answered Aug 25, 2026
If you have the most recent release of the Statistics Toolbox:
>> x = poissrnd(4,20,1);
>> pd = fitdist(x,'poisson');
>> pd.NLogL
ans =
39.0221
If you do not:
>> mu = poissfit(x);
>> -sum(log(poisspdf(x,mu)))
ans =
39.0221
 
 

To find maximum likelihood estimates (MLEs), you can use a negative loglikelihood function as an objective function of the optimization problem and solve it by using the MATLAB® function fminsearch or functions in Optimization Toolbox™ and Global Optimization Toolbox. These functions allow you to choose a search algorithm and exercise low-level control over algorithm execution. By contrast, the mle function and the distribution fitting functions that end with fit, such as normfit and gamfit, use preset algorithms with options limited to those set by the statset function.

 

 

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!