How to use conditional bounds for parameters with lsqcurvefit?
Ältere Kommentare anzeigen
I am trying to fit an exponential curve to a set of data (Exponential Cumulative Distribution Function).
I would like to solve for the parameters λ,
, and
, however there are certain conditions with which I need to bound the parameters.
, and
, however there are certain conditions with which I need to bound the parameters. "The
and
are non-negative values that can be both be 0 but both values cannot be greater than 0 at the same time" as well as "The natural logarithm of λ can be any value between zero and 4."
and
are non-negative values that can be both be 0 but both values cannot be greater than 0 at the same time" as well as "The natural logarithm of λ can be any value between zero and 4."Is there a way in which I would be be able to define these conditions using lsqcurvefit to solve for the parameters? If not how should I approach fitting this curve to my data? Below is my attempt to use lsqcurvefit without the conditional between
and
.
and
.xdata = 0:7;
ydata = 100*[0 0.112543130593672 0.814735805710535 1 1 1 1 1];
lb = [log(1), 0, 0];
ub = [log(4), 7, 100]; % How to define upper bound with conditions?
fun = @(x,xdata) (1 - exp(-x(1)*(xdata-x(2))) + x(3));
x = lsqcurvefit(fun,[0, 0, 0],xdata,ydata, lb, ub)
plot(xdata, 1*ydata, '.k', 'MarkerSize', 20)
hold on
plot(xdata, 1*fun(x, xdata))
1 Kommentar
Matt J
am 25 Jan. 2023
The natural logarithm of λ can be any value between zero and 4.
If 0<=log(lambda)<=4, then your bounds on lambda would be exp(0) <=lambda<=exp(4), whereas in your code, you have log(1) <=lambda<=log(4)
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Nonlinear Optimization finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!