Posted Friday, November 24, 2006 4:26 AM
|
|
|
|
| what is the best way to get the variance of a column in a matrix?
|
|
Posted Friday, November 24, 2006 5:22 AM
|
|
|
|
Using the ColsDotProduct(col, col) you can get Sum(x^2) and then you divide by N or N-1 where N is the number of rows.
Trifon Triantafillidis | Lead Developer |
|
|
|
Posted Friday, November 24, 2006 8:53 AM
|
|
|
|
I cant use that as that will not give me the variance as it is the sum of the x^2 and not the sum of (x-mean)^2
I can do it the long way by looping through but just wondered if there was a quicker command
|
|
Posted Friday, November 24, 2006 9:14 AM
|
|
|
|
Sum( (x-mean)^2 ) = Sum( x^2 ) - 2*Sum(x)*mean + N*mean^2 = Sum(x^2) - 2 * Sun(x)* ( Sum(x)/N ) + N *(Sum(x)^2/N^2) =
= Sum(x^2) - Sum(x)^2 / N
You can get Sum(x) using ColSum method
Trifon Triantafillidis | Lead Developer |
|
|
|
Posted Monday, November 27, 2006 8:08 AM
|
|
|
|
thanks
|
|
|
|