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!