extract the j-th component of the vector resulting from the matrix product.

8 vues (au cours des 30 derniers jours)
Tommaso Delicato
Tommaso Delicato le 1 Fév 2021
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

Réponses (1)

Swastik Sarkar
Swastik Sarkar le 19 Juin 2025
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);
Component (A^T x)_20 = 0.1311
fprintf('Component (A^+ Σ x / sqrt(x^T Σ x))_%d = %.4f\n', j, component2);
Component (A^+ Σ x / sqrt(x^T Σ x))_20 = 0.4803
fprintf('RC(F_%d) = %.4f\n', j, RC_Fj);
RC(F_20) = 0.0630
This method also makes it easier to compute all RC(Fj)RC(Fj​) values in a loop if needed.
I hope this helps !

Catégories

En savoir plus sur Networks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by