extract the j-th component of the vector resulting from the matrix product.
5 次查看(过去 30 天)
显示 更早的评论
I cannot code the fact that I have to extract the j-th component from the vector that results from a matrix product in a constrained minimization problem.
Minimize ∑(RC(Fj)/σP−1/M)^2 for j=1:M
sub ∑x=1
where RC(Fj) = (A⊤x)j⋅ (A+Σx/√x⊤Σx)j
where
- A is a loadings matrix
- A+ is Moore-Penrose inverse of A
- Σ is a covariance matrix
- x is a weights vector
I should therefore extract the j-th component of the following matrix products
(A⊤x)j
(A+Σx/√x⊤Σx)j
0 个评论
回答(1 个)
Swastik Sarkar
2025-6-19
In this case, it may be more convenient to compute the full vectors for both (A⊤x) & (A+Σx/√x⊤Σx)and then access the required component by indexing
The following example illustrates this method using randomly generated values:
n = 40;
M = 30;
j = 20;
A = randn(n, M);
R = randn(n);
Sigma = R' * R;
x = rand(n, 1);
x = x / sum(x);
v1 = A' * x;
v2 = (pinv(A) * Sigma * x) / sqrt(x' * Sigma * x);
component1 = v1(j);
component2 = v2(j);
RC_Fj = component1 * component2;
% Display results
fprintf('Component (A^T x)_%d = %.4f\n', j, component1);
fprintf('Component (A^+ Σ x / sqrt(x^T Σ x))_%d = %.4f\n', j, component2);
fprintf('RC(F_%d) = %.4f\n', j, RC_Fj);
This method also makes it easier to compute all RC(Fj)RC(Fj) values in a loop if needed.
I hope this helps !
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!