Computing Variance manually problem
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
HI all I am facing a problem in computing variance manualy.As
I have a A= magic(3) matrix of 9 elements
when I calculate it directly by using var it gives me
var(var(A)) ans is 27 but when I campute manually it does not match with above answer
As
variance=(A-mean(mean(A))).^2/8 variance=sum(sum(variance)) answer is 0. why is this situation occurring is there any problem in my formula?
0 Kommentare
Akzeptierte Antwort
Shashank Prasanna
am 23 Jan. 2013
Your formula is wrong. when you say var(var(A)) you are actually computing the variances of each column and then variances of these variances. Is there a reason you are doing this? However if you are interested in reproducing the result, then you have to follow the same steps manually as follows:
A = magic(3);
B = sum((A-repmat(mean(A),3,1)).^2)/2; % Variance of each column
var_magic = sum((B-mean(B)).^2)/2 % Variance of the variance computed above.
var_magic =
27
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown 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!