Borrar filtros
Borrar filtros

Computing Variance manually problem

7 visualizaciones (últimos 30 días)
Algorithms Analyst
Algorithms Analyst el 23 de En. de 2013
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?

Respuesta aceptada

Shashank Prasanna
Shashank Prasanna el 23 de En. de 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
  1 comentario
Algorithms Analyst
Algorithms Analyst el 23 de En. de 2013
Thannk you.yes thre is some reason for doing it thank you...

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by