Problems with fmin. Trying to minimize a function with two unknowns and a vector that changes
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ribal Abi Raad
am 25 Jan. 2016
Kommentiert: Walter Roberson
am 25 Jan. 2016
Hi, I'm still a bit new to Matlab, but I have a problem that i can't seem to figure out. I know that fminsearch or fminunc usually minimize functions(constant ones at least) such as x^2+y. I have the following equation:
-log((1/beta)*(1+xi*(l(i,1)-u)/beta)^(-1/(xi-1)))
What I am looking to minimize is the the sum of all the logs from i = 1 to N, where l(i,1) for all N is a known number, and beta and xi are unknowns. I can do minimization for each function, but I don't know to minimize for the sum.
I've looked around and I haven't found any solutions yet.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 25 Jan. 2016
obj_fun = @(beta, xi, L, U) sum( -log((1/beta)*(1+xi*(L-U)/beta)^(-1/(xi-1))) );
l = ...
u = ...
guess = randn(1,2);
fminsearch( @(bx) obj_fun(bx(1), bx(2), l, u), guess )
If you have constraints you would use fmincon instead of fminsearch.
Also if there are local minima then you might need to use a global solver instead of a local solver.
2 Kommentare
Walter Roberson
am 25 Jan. 2016
I do not know what the value of i is there. You should be passing in an entire vector for your third parameter. And it is a good idea to not name a variable l (lower case L) as it is often difficult to tell the difference between that and the number 1.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!