How does the expfit function... functions
36 views (last 30 days)
Show older comments
Dear all,
I have spontaneously been using the expfit function for an estimate of exponential decay in large datasets. When I use the decay (inverse of the function's output, mu), it matches very well the slope of the survival function of my data plotted in log scale.
So it seems to perform very well... but I realized I do not understand how expfit is different from full exponential fitting. The expfit page is incredibly succint, and expfit is not listed in more generic help pages on "how to fit an exponential model to data" (here). So expfit is not a fitting function? What am I missing here?
Any insight?
Thanks
0 Comments
Answers (2)
Sam Chak
on 8 May 2025
This is most likely because the expfit() function does not belong to the Curve Fitting Toolbox. Furthermore, the function is more suitable for exponentially distributed sample data, which is why it is included in the Statistics and Machine Learning Toolbox.
0 Comments
John D'Errico
on 8 May 2025
You may be confused. Well, let me say, almost certainly, you are confused. ;-)
There is a difference between curve fitting, in the sense of a nonlinear regression, where you find the curve that passes through a the points on a curve, and what expfit does, which is to identify the distribution parameters from a statistical sample of data.
And I think this is not uncommon. I've seen many fall into the same trap, because the two problems look similar to someone unfamiliar with these tools.
If you have a histogram of data, or something like it, and you want to estimate the distribution of that data, then you need to use the statistics and machine learning toolbox tools like expfit, normfit, distfit, etc. You can find a list of those tools if you do help stats:
Parameter estimation.
betafit - Beta parameter estimation.
binofit - Binomial parameter estimation.
distributionFitter - Distribution fitting app.
evfit - Extreme value parameter estimation.
expfit - Exponential parameter estimation.
fitdist - Distribution fitting.
fitgmdist - Fit a Gaussian mixture model to data.
gamfit - Gamma parameter estimation.
gevfit - Generalized extreme value parameter estimation.
gpfit - Generalized Pareto parameter estimation.
lognfit - Lognormal parameter estimation.
makedist - Make probability distribution.
mle - Maximum likelihood estimation (MLE).
mlecov - Asymptotic covariance matrix of MLE.
nbinfit - Negative binomial parameter estimation.
normfit - Normal parameter estimation.
paretotails - Empirical cdf with generalized Pareto tails.
poissfit - Poisson parameter estimation.
raylfit - Rayleigh parameter estimation.
unifit - Uniform parameter estimation.
wblfit - Weibull parameter estimation.
This subset of tools is designed to estimate the distribution parameters of the corresponding distributions. They would typically use maximum likelihood estimation techniques. (Well, unifit is simple enough that nothing special would be needed.) In fact, you can even see the function MLE included in that list.
However, that is NOT a linear or nonlinear regression, which is used to minimize the sum of squres of residuals to a curve. Tools like polyfit, nlinfit, and fit all use that methodology. And of course, they all end in the letters fit, which is part of why you are confused. Different animals.
2 Comments
Steven Lord
on 8 May 2025
This isn't a great analogy, but it's like you have a set of GPS coordinates collected while you took a trip. You could fit a curve to that data, allowing you to see the exact path you were taking when you collected the data.
But if I told you these coordinates were from a car's navigation system (knowing or suspecting which "distribution" they came from) rather than from someone hiking in the woods, you could plot those coordinates on a map to identify the roads you were driving. It wouldn't necessarily give an equation for the path you followed like the first scenario, but it would still give us general information about where you were at a given time (you turned off Main Street onto Washington Street here, etc.)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!