How to generate correlated gaussian noises

From NeuralNetoff
Jump to: navigation, search

Theory

http://www.columbia.edu/~mh2078/MCS04/MCS_framework_FEegs.pdf


Matlab code

Generate 3 channels of correlated gaussian noise:

clear;

%Here we use 3 uncorrelated gaussian noise as input, whose mean's are 0 and Std's are 1.

R=normrnd(0,1,[3,1000]);

%Here is your covariance matrix, if all channels of signals have a Std of 1, then it is your correlation coefficient matrix.

sigma=[1.0 0.2 0.8;

0.2 1.0 0.5;

0.8 0.5 1.0];

%Do the Cholesky Decomposition of your covariance matrix sigma.

C=chol(sigma);

%Transform the input to 3 channels of correlated output.

X=C'*R;

X=X';

% Let's see whether the covariance matrix of X now.

cov(X);

X;

% Write Data to binary file

fid = fopen('RNG.out', 'wb');

fwrite(fid, X, 'double');

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox