如何创建带限(100-640 Hz)白高斯噪声?

时间:2017-01-25 17:02:18

标签: matlab random filter noise

我想用(相对)平坦的频谱创建500 ms的带限(100-640 Hz)高斯白噪声。噪声应该正常分布,其中均值= ~0和99.7%的值在±2之间(即标准偏差= 2/3)。我的采样率是1280赫兹;因此,为每个帧生成一个新的幅度。

duration  = 500e-3;
rate      = 1280;
amplitude = 2;

npoints   = duration * rate;
noise     = (amplitude/3)* randn( 1, npoints ); 
% Gaus distributed white noise; mean = ~0; 99.7% of amplitudes between ± 2.
time      = (0:npoints-1) / rate

有人可以告诉我如何过滤信号以获得所需的结果(即100-640赫兹)?另外,我希望有人也可以告诉我如何生成图表来说明频谱确实是平坦的。

我打算将波形导入信号(CED),以输出作为经颅电刺激的一种形式。

1 个答案:

答案 0 :(得分:3)

以下是对你的问题的评论中“Some Guy”提到的方法的Matlab实现。

% In frequency domain, white noise has constant amplitude but uniformly
% distributed random phase. We generate this here. Only half of the
% samples are generated here, the rest are computed later using the complex
% conjugate symmetry property of the FFT (of real signals).
X         = [1; exp(i*2*pi*rand(npoints/2-1,1)); 1]; % X(1) and X(NFFT/2) must be real 

% Identify the locations of frequency bins. These will be used to zero out
% the elements of X that are not in the desired band
freqbins  = (0:npoints/2)'/npoints*rate;

% Zero out the frequency components outside the desired band 
X(find((freqbins < 100) | (freqbins > 640))) = 0;

% Use the complex conjugate symmetry property of the FFT (for real signals) to
% generate the other half of the frequency-domain signal
X         = [X; conj(flipud(X(2:end-1)))];

% IFFT to convert to time-domain
noise     = real(ifft(X));

% Normalize such that 99.7% of the times signal lies between ±2
noise     = 2*noise/prctile(noise, 99.7);

使用该方法生成的大约一百万个样本的统计分析得到以下谱和分布:

首先,正如预期的那样,光谱(使用Welch方法)在感兴趣的波段中是平坦的:

PSD

此外,使用信号直方图估计的分布与高斯PDF相当匹配。 enter image description here