Is there a way to compute average norm after a series of trials?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Tarek Hajj Shehadi
il 12 Lug 2021
Commentato: Tarek Hajj Shehadi
il 12 Lug 2021
Suppose I have a matrix
and
I am solving a least-square problem using QR using my own algorithm.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/682003/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/682008/image.png)
A and b are both generated randomly.
Is there a way to run this least square algorithm several time and at each run the norm
is computed and finally the average of all these norms is taken?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/682013/image.png)
0 Commenti
Risposta accettata
Ben McMahon
il 12 Lug 2021
I am a bit confused by your question, as x is not defined. If you want to run your algorithim for a set number of randomly generated matrices and vectors then something similar to the code below should work:
numIterations = 10; % Number of random samples of your matrix / vector combo you want to compute
for Iteration = 1:numIterations
A = rand(100,100);
b = rand(100,1);
x = myLeastSquareAlgo(A,b); % Your algorithim function that calculates 'x'.
normArray(Iteration) = norm(b-A*x);
end
meanNorm = mean(normArray);
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!