MLE of combined analytically and empirically defined distributions

Hi, I have some data that I would like to fit which has two components to it's pdf: a normal distribution and an added arbitrary distribution that cannot be described analytically but can be measured/interpolated from other data. The final distribution would look something like
@(x, mu, sigma, b) (1-b)*normpdf(x, mu, sigma)+ b*EmpiricalPDF(x)
I'm unsure of how to define the empirical distribution so it can be combined with the normal pdf and used for MLE.
Thanks!

Answers (1)

MATLAB's "mle" accepts custom pdf's.
If you write b as sin^2(p) and (1-b) as cos^2(p), it should work to estimate mu, sigma and p (and thus b).
You will have to fit a function to your EmpiricalPDF first before starting with "mle".

2 Comments

Thanks, my main question is on defining the EmpiricalPDF. Is there a way to avoid fitting a function to create the pdf, and just use an interpolation instead? I have to generate many of these programatically, and won't be able to inspect all the empirical distributions to determine the best function to approximate each one.
The below code generates a function "EmpiricalCDF" as an approximation of the cdf to your data.
Thus supply the cdf instead of the pdf when you call "mle".
You might get problems if "mle" calls "EmpiricalCDF" outside the range of your data. If this is the case, you will have to program the interpolation with extrapolation on your own. But this is very easy.
% Generate 1000 normal random numbers
mu = 0; sigma = 1; nr = 1000;
givenDist = mu + sigma * randn(nr,1);
% Generate empirical cdf from random numbers
x = sort(givenDist(:));
p = 1:length(x);
p = p./length(x);
plot(x,p,'color','r');
EmpiricalCDF = @(y)interp1(x,p,y)
EmpiricalCDF = function_handle with value:
@(y)interp1(x,p,y)

Sign in to comment.

Categories

Find more on Random Number Generation in Help Center and File Exchange

Products

Release

R2022b

Tags

Asked:

on 5 Mar 2025

Edited:

on 6 Mar 2025

Community Treasure Hunt

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

Start Hunting!