How to fit this model with a Weibull distribution?
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Michele Turchiarelli
am 27 Sep. 2024
Kommentiert: Sam Chak
am 29 Sep. 2024
Hi. I'm trying to fit my empirical curve with a theoretical Weibull distribution through curve fitting (cftool). The problem is that I get a negative value and I can't understand why.
I tried adding a +c constant to the Weibull function, but it only got worse:
I also tried adjusting the variables' StartingPoint values but nothing changed. I am pretty sure this has to work somehow. Thank you in advance.
2 Kommentare
Akzeptierte Antwort
Sam Chak
am 28 Sep. 2024
I normalized the x-axis data to facilitate the fitting algorithm's search process. Is this solution acceptable?
%% data
X = load("x_axis.mat");
Y = load("y_axis.mat");
%% process a bit
t = X.t;
tm = max(X.t) % max t for normalization; makes the fitting easier
y = Y.M_empRel;
% Fitting model
fo = fitoptions('Method', 'NonlinearLeastSquares',...
'Lower', [0.02, 0.5],...
'Upper', [0.03, 0.6]);
ft = fittype('exp(-((t/299578)/b)^c)', ...
'dependent', {'prob'}, 'independent', {'t'}, ...
'coefficients', {'b', 'c'}, ...
'options', fo);
%% Fit curve to data
[yfit, gof] = fit(t, y, ft, 'StartPoint', [0.025, 0.55])
%% Plot results
plot(yfit, t, y), grid on
xlabel('t'), ylabel('y(t)')
title({'$y(t) = \exp\left(- \left(\frac{t}{299578 b}\right)^{c}\right)$, with $b = 0.02498$ and $c = 0.5535$'}, 'interpreter', 'latex', 'fontsize', 16)
legend('Data', 'Fitted model', 'fontsize', 14)
4 Kommentare
Weitere Antworten (2)
John D'Errico
am 27 Sep. 2024
Bearbeitet: John D'Errico
am 27 Sep. 2024
If this is data that you think comes from a Weibull, then you do not want to use regression techniques to fit the distribution. And adding a constant term invalidates the result as a Weibull distribution.
You can use MLE. But more approprately, use wblfit.
help wblfit
If you provide the data, we can possibly offer more or better advice. Lacking that, just use wblfit.
13 Kommentare
Torsten
am 28 Sep. 2024
Then why did the exponential fit work?
Because a*exp(b*x) is not a distribution function for arbitrary choices of the parameters a and b.
Besides, what am I supposed to do then to make it work with a Weibull distribution? Scale down my values/data?
It will be difficult with a modified Weibull function because only in a very special case it passes through (0/1).
David Goodmanson
am 27 Sep. 2024
Bearbeitet: David Goodmanson
am 27 Sep. 2024
Hi MIchele,
One possibility is that you are not fitting the correct statistical function to the data. The algebraic expression you have is a probability density function (pdf), but the data runs from y = 1 down to y = 0 [eventually], and looks like a cumulative distribution function (cdf), more specifically (1-cdf) since a cdf runs from 0 up to 1. For the weibull cdf,
y = 1-exp(-(x/b)^c) and (1-y) = exp(-(x/b)^c)
and the latter function you can fit to the data.
When x=0 then y=1, and when x=b then y = exp(-1) = .368 for all vaues of c. Looking at your plot, .368 occurs close to x = 1 which implies that b is approximately 1.
I guess another possibility is that y is a pdf that so happens to equal 1 at x = 0. This occurs for the weibull pdf when c = 1, which is the same as the pdf of an exponential distribution, (1/b) exp(-x/b).
3 Kommentare
David Goodmanson
am 27 Sep. 2024
I plotted the data you enclosed vs a linear scale and it does not look in the least like the data in the plot.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!