how to random initialize svd function in matlab??

1 Ansicht (letzte 30 Tage)
Fethi Bencherki
Fethi Bencherki am 5 Mär. 2020
Beantwortet: Christine Tobler am 5 Mär. 2020
i want the svd function in matlab to give me two different values for the same matrix , i mean the U and V , currently im getting the same everytime i run

Akzeptierte Antwort

Christine Tobler
Christine Tobler am 5 Mär. 2020
The linear algebra functions in MATLAB are run-to-run reproducible, meaning if you call them twice with the exact same input, you get the exact same output.
If you want to randomize the output, you could pre-multiply the matrix with two random orthogonal matrices, and then apply does matrices to the outputs U and V:
[m, n] = size(A);
U0 = orth(randn(m));
V0 = orth(randn(n));
[U, S, V] = svd(U0*A*V0');
U = U0'*U;
V = V0'*V;
norm(A - U*S*V', 'fro')
This will still return the same singular values (which are unique), but returns different singular vectors.

Weitere Antworten (1)

KALYAN ACHARJYA
KALYAN ACHARJYA am 5 Mär. 2020
data_test=magic(3);
[U,S,V]=svd(data_test)
Result
U =
-0.5774 0.7071 0.4082
-0.5774 0.0000 -0.8165
-0.5774 -0.7071 0.4082
S =
15.0000 0 0
0 6.9282 0
0 0 3.4641
V =
-0.5774 0.4082 0.7071
-0.5774 -0.8165 -0.0000
-0.5774 0.4082 -0.7071
>>
  1 Kommentar
Fethi Bencherki
Fethi Bencherki am 5 Mär. 2020
Bearbeitet: Fethi Bencherki am 5 Mär. 2020
i might have formulated the question in a wrong manner , see normally svd is non unique , but due to some reason svd(A) is outputing the same results , i want it instead to give me different U, V everytime i run , for the same matrix A ofcourse

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Eigenvalues finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by