MLE of combined analytically and empirically defined distributions
1 view (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
Torsten
on 5 Mar 2025
Edited: Torsten
on 5 Mar 2025
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
Torsten
on 6 Mar 2025
Edited: Torsten
on 6 Mar 2025
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)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!