Why do nested means give different answers depending on which dimension is averaged first
Mostra commenti meno recenti
Consider that I have a square matrix where I want the average of all elements. Also consider that because I'm awkward I want to do this using mean() rather than mean2(). To do this I could take the average of rows then the average of that. Or I could do the same for columns. I've tried both here using the simple code below and the offset is always very small (e-16) but always non-zero. Am I missing something fundamental?
array = rand(100);
mean_1 = mean(mean(array,1));
mean_2 = mean(mean(array,2));
offset = mean_1 - mean_2;
1 Commento
jonas
il 25 Lug 2018
Its probably because the first average gives an vector of floating point number which are not exact
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!