I need to check two conditions:
- $E[X]\stackrel{?}{=}\mu$,
- $E[(X-\mu)(X-\mu)^{\top}]\stackrel{?}{=}\Sigma$.
Here $X$ is generated (output) data, $\mu$ is the mean vector, $\Sigma$ is the covariance matrix. $\mu$, $\Sigma$ are input data.
For the test the first condition I wrote the code in R:
all( abs(apply(X, 1, mean) - mu) < .Machine$double.eps)
# [1] TRUE
For the test the second condition I wrote the code in R with Error:
SS <- mean((X - mu) %*% t(X - mu)) # Error in X - mu : non-conformable arrays
Also I have tried
XX <- apply(X, 2, X- mu);
all(abs(cov(XX)-Sigma) <Machine$double.eps)
Question. How to check the second condition?
The input and output data are below.
> dput(X)
structure(c(0.0613307578354561, 0.0793852352305158, 0.106501868600655,
0.0613307578354561, 0.0793852352305158, 0.106501868600655, 0.0613307578354561,
0.0793852352305158, 0.106501868600655, 0.0613307578354561, 0.0793852352305158,
0.106501868600655, 0.0613307578354561, 0.0793852352305158, 0.106501868600655,
-0.0580547578354561, -0.0677532352305158, -0.102897868600655,
-0.0580547578354561, -0.0677532352305158, -0.102897868600655,
-0.0580547578354561, -0.0677532352305158, -0.102897868600655,
-0.0580547578354561, -0.0677532352305158, -0.102897868600655,
-0.0580547578354561, -0.0677532352305158, -0.102897868600655,
0.001638, 0.005816, 0.001802, -0.0632519844767603, -0.0984530938115999,
-0.0957267222612055, 0.0665279844767603, 0.1100850938116, 0.0993307222612055
), .Dim = c(3L, 13L))
> dput(mu)
structure(c(0.001638, 0.005816, 0.001802), .Dim = c(3L, 1L))
> dput(Sigma)
structure(c(0.00164362748495062, 0.00127550132157053, 0.00109066033003292,
0.00127550132157053, 0.00296017401626616, 0.00168755721411896,
0.00109066033003292, 0.00168755721411896, 0.00280257641141517
), .Dim = c(3L, 3L))