Covariance: To TableOfReal (random sampling)...


Generate a TableOfReal object by random sampling from a multivariate normal distribution whose Covariance matrix is the selected object.
Setting

Number of data points

determines the number of data points that will be generated. Each data point occupies one row in the generated table.
Algorithm
The algorithm proceeds as follows:

1. Diagonalize the covariance matrix: calculate the eigenvalues
v_{}
i and eigenvectors e_{i} of the m × m Covariance matrix. In general there will also be m of these. Let E be the m × m matrix with eigenvector e_{j} in column j (j=1..m).

2. Generate a vector x whose elements x_{k} equal x_{k} = randomGauss (0, √ (v_{k})). Each x_{k} is a random deviate drawn from a Gaussian distribution with mean zero and standard deviation equal to the square root of the corresponding eigenvalue v_{k}.

3. Rotate back: calculate the vector y = E x, obtained by multiplying the vector x with the matrix E.

4. Add the centroid to y and copy the elements of y to the corresponding row of the TableOfReal object.

5. Repeat steps 2, 3 and 4 until the desired number of data points has been reached.

6. Copy the column labels from the Covariance object to the TableOfReal object.
In case the covariance matrix is diagonal, the algorithm is much simpler: we can skip the first and third step.
Links to this page
© djmw 20101101