Problems with fmin. Trying to minimize a function with two unknowns and a vector that changes
7 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Walter Roberson
2016 年 1 月 25 日
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 件のコメント
Walter Roberson
2016 年 1 月 25 日
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.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!