Iteration Problem in an Array?

I have a minimization problem that works just fine following the codes below,
**%%STEP 1** perform minimization problem
A = ones(1,N);
b = 1;
Aeq = ones(1,N);
Beq = 1;
lb = zeros(N,1);
ub = [];
x0 = rand(N,1);
x0 = x0/norm(x0);
x0 = x0.*x0;
% x0 is random Wgt that sum up to one.
Opts2 = optimset('Algorithm','interior-point','Display','off');
f = @(w) (abs(sqrt(w'*Sigma*w))/(prod(w))^(1/N));
Wgt = fmincon(f,x0,A,b,Aeq,beq,lb,ub,[],Opts);
--------------------------------------------------------------------
%%Step 2 - Find the Beta using the Wgt obtained from above
Port_ret = LgRet*Wgt;
Beta = zeros(1,N);
for w = 1:N
Beta(w) = regress(LgRet(:,w),Port_ret);
end
%%Step 3 Check the property Beta*weight = 1/N
LHS = Beta.*Wgt';
RHS = (1/N)*ones(1,N);
% if LHS == RHS then the Wgt obtained above satisfies the property, if not perform iteration, by increasing the Wgt if LHS < RHS and decrease Wgt if LHS > RHS, and use the new Wgt to find Beta by repeating Step 2 until the equality LHS == RHS is obtained.
--------------------------------------------------------------------
% Here
% N is scalar
% Wgt is N-by-1 vector
% Sigma is N-by-N matrix
% LgRet is M-by-N matrix
% Port_ret is M-by-1 vector
% Beta is 1-by-N vector
% LHS is 1-by-N vector
% RHS is 1-by-N vector
% However to get the correct Wgt,
% the condition LHS == RHS must satisfy.
% The problem needs to
% Increase Wgt if Beta.*Wgt' < RHS
% Decrease Wgt if Beta.*Wgt' > RHS
% And then perform *Setp 2* again, do this iteration until LHS = RHS
% *Note that sum of Wgt at all time must equal 1*
% in this exercise i use N as 100
% M as 1051

답변 (0개)

카테고리

도움말 센터File Exchange에서 Linear Algebra에 대해 자세히 알아보기

질문:

2015년 3월 31일

편집:

2015년 3월 31일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by