# Sphering Data

We can easily generate random random data in Euler. E.g., the following simulate the [X+Y,X] for 0-1-distributed X and Y.

>X=normal(100); Y=normal(100); V=(X+Y)_X;
>plot2d(V,V,r=4,>points,style=".."): Sphering is a linear process which applied to each point leads to random variables with mean 0 and the unity matrix as covariance matrix. It is vary easy to achieve this. If V contains the random variables in each row, mean(V) and covarmatrix(V) will will work. But we can just as well use the matrix language to compute those. After subtracting the mean value of each row of V, we can compute the covariance matrix by

$$S_{i,j} = \dfrac{1}{n-1} \sum\limits_{k=1}^n v_{i,k} v_{k,j}.$$

This is in fact equal to

$$S = \dfrac{1}{n-1} V \cdot V’$$

So, if T is the square root of S, we have

$$(T^{-1} V) (T^{-1} V)‘ = T^{-1} V V‘ T^{-1} = T^{-1} S T^{-1} = I$$

We used that T is symmetric.

>V=(V-sum(V)/cols(V)); S=V.V'/(cols(V)-1)
1.94951        1.0316
1.0316       1.07188
>real(eigenvalues(S))
[2.63175,  0.389644]
>SQ=matrixfunction("sqrt",S)
1.31858      0.459208
0.459208      0.927906
>VS=inv(SQ).V;
>plot2d(VS,VS,r=4,>points,style=".."): I added the sphering for the next version of Euler using an SVD decomposition directly instead of matrixfunction().

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.