-1

How can i generate Gaussian random process using Matlab with zero mean and unit variance ?

Gaussian random variable can be implemented by

w=(1/sqrt(2*pi))*exp(-(t.^2)/2);

but what about Gaussian random process ?

zahypeti
  • 183
  • 1
  • 8
user2942448
  • 19
  • 1
  • 1
  • 2
  • 1
    Incidentally, that's not an implementation of a Gaussian variable, that's simply its PDF. – Oliver Charlesworth Dec 03 '13 at 17:38
  • @Oli There is a difference between a Gaussian random variable and a Gaussian random process. The latter has infinite dimension, it is like a function of `t` with every different `t` producing a different random variable. @user2942448 Which Gaussian random process do you have in mind? – Strategy Thinker Dec 03 '13 at 19:17
  • @StrategyThinker: Of course, and `randn` permits that. But without further qualification, I'd interpret "Gaussian process" to mean uncorrelated Gaussian samples. – Oliver Charlesworth Dec 03 '13 at 20:46

2 Answers2

2

If the Gaussian process is white (no correlation between samples at different instants), just use

w = randn(1,n);

where n is the desired number of samples.

If you need to introduce correlation between samples (that is, the values at different instants are correlated), the usual approach is to generate a white Gaussian process and then apply a low-pass filter (using conv or filter). The autocorrelation of the process is determined by the filter shape.

For example,

w = randn(1,500);
y = conv(w,ones(1,100)/10,'same'); %// apply a simple low-pass filter
plot(w)
hold on
plot(y,'r')

You can see that the filtered signal (red) has smoother time variations, because of the (auto)correlation introduced by the filter.

enter image description here

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
1

A random Gaussian process with specified correlation length(cl) and RMSE -height(hRMSE) can be generated by passing a white noise with mean 0 and standard deviation hRMSE through a Gaussian filter g=exp(-(x.^2)/(cl^2/2)).

Furthermore, you can find the Matlab code under the below link: http://www.mysimlabs.com/matlab/surfgen/rsgeng1D.m

Which has been transcribed below:

function [f,x] = rsgeng1D(N,rL,h,cl)
%
% [f,x] = rsgeng1D(N,rL,h,cl) 
%
% generates a 1-dimensional random rough surface f(x) with N surface points. 
% The surface has a Gaussian height distribution function and a Gaussian 
% autocovariance function, where rL is the length of the surface, h is the 
% RMS height and cl is the correlation length.
%
% Input:    N   - number of surface points
%           rL  - length of surface
%           h   - rms height
%           cl  - correlation length
%
% Output:   f   - surface heights
%           x   - surface points
%
% Last updated: 2010-07-26 (David Bergström).  
%

format long;

x = linspace(-rL/2,rL/2,N);

Z = h.*randn(1,N); % uncorrelated Gaussian random rough surface distribution
                     % with mean 0 and standard deviation h

% Gaussian filter
F = exp(-x.^2/(cl^2/2));

% correlation of surface using convolution (faltung), inverse
% Fourier transform and normalizing prefactors
f = sqrt(2/sqrt(pi))*sqrt(rL/N/cl)*ifft(fft(Z).*fft(F));
brodoll
  • 1,851
  • 5
  • 22
  • 25
user176420
  • 41
  • 4