【问题标题】:How can i generate gaussian random process using matlab?如何使用matlab生成高斯随机过程?
【发布时间】:2013-12-03 17:32:45
【问题描述】:

如何使用 Matlab 生成具有零均值和单位方差的高斯随机过程?

高斯随机变量可以通过

实现

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

但是高斯随机过程呢?

【问题讨论】:

  • 顺便说一句,这不是高斯变量的实现,这只是它的 PDF。
  • @Oli 高斯随机变量和高斯随机过程是有区别的。后者具有无限维,就像t 的函数,每个不同的t 产生不同的随机变量。 @user2942448 你想到的是哪个高斯随机过程?
  • @StrategyThinker:当然,randn 允许这样做。但如果没有进一步的限定,我会将“高斯过程”解释为不相关的高斯样本。

标签: matlab gaussian stochastic-process


【解决方案1】:

如果高斯过程是白色(不同时刻的样本之间没有相关性),只需使用

w = randn(1,n);

其中n 是所需的样本数。

如果需要在样本之间引入correlation(即不同时刻的值是相关的),通常的做法是生成白高斯过程,然后应用低通滤波器(使用convfilter)。过程的自相关由滤波器形状决定。

例如,

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')

您可以看到,过滤后的信号(红色)具有更平滑的时间变化,因为过滤器引入了(自动)相关性。

【讨论】:

    【解决方案2】:

    一个具有指定相关长度 (cl) 和 RMSE 高度 (hRMSE) 的随机高斯过程可以通过一个高斯滤波器g=exp(-(x.^2)/(cl^2/2)) 传递一个平均值为 0 和标准偏差 hRMSE 的白噪声来生成。

    此外,您可以在以下链接中找到 Matlab 代码:http://www.mysimlabs.com/matlab/surfgen/rsgeng1D.m

    抄录如下:

    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));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-16
      • 2014-04-15
      • 1970-01-01
      • 2020-08-24
      • 2012-10-17
      • 2011-08-09
      • 2021-09-22
      相关资源
      最近更新 更多