MATLAB Answers

0

Multivariable Optimization problem with MATLAB

Arindam Sutradhar さんによって質問されました 2019 年 1 月 20 日
最新アクティビティ Alan Weiss
さんによって 回答されました 2019 年 1 月 22 日
I wish to find a maximum for the following function, the function is m:
x = normrnd(0,1,[1,5]);
global x
xbar=mean(x);
global xbar
n=length(x);
global n
an = @(a0,b0,k0,m0) a0+n/2;
bn = @(a0,b0,k0,m0) (b0 + ((n-1) * sum((x-xbar).^2))/2 + ((k0 * n * ((xbar-m0).^2) )/(2*(k0 + n))));
kn = @(a0,b0,k0,m0) (k0 + n);
mn = @(a0,b0,k0,m0) ((k0 * m0)+(n.*xbar))/(k0 + n);
m=@(a0,b0,k0,m0)(gamma(an(a0,b0,k0,m0))/gamma(a0)) * ((b0^a0)/(bn(a0,b0,k0,m0).^an(a0,b0,k0,m0))) * (sqrt(k0/kn(a0,b0,k0,m0))) * ((2*pi)^(-n/2))
This is not linear. I wish to find a Global maximum. Most of the function I found in matlab handles the polynomials. But I do not find any particular function that gives me a maximum for this. I tried to use 'fminunc'. But that is showing me an error message
"Failure in initial objective function evaluation. FMINUNC cannot continue."
Looking forward to some help. Thanks in advance.

  0 件のコメント

サインイン to comment.

タグ

1 件の回答

Alan Weiss
Answer by Alan Weiss
on 22 Jan 2019

I don't understand what you are trying to do exactly. But for troubleshooting, you need to ensure that the function handle that you pass to fminunc calculates a scalar numerical value at the initial point x0. So try to evaluate
fun(x0)
where fun is your objective function and x0 is your initial point. Undoubtedly, this will evaluate to a nonscalar value, or will fail to evaluate. That is where you need to start your investigation.
Alan Weiss
MATLAB mathematical toolbox documentation

  0 件のコメント

サインイン to comment.



Translated by