Filtering White noise to produce desired Coloured Noise

Started by dilpreet06 November 1, 2007

I am trying to produce a coloured noise from white noise in the discrete
time domain. I do it by producing an FIR filter of coefficients b,a from
the Noise Floor (V/sqrt(Hz)), which filters white noise produced by the
randn function. 

Here is the code again: 

%Filter coefficients of Noise floor of circuit
[b,a]  = invfreqz(PSD_N.^0.5,(2*pi/fs)*(nn_f_scale),70,0,[],20,0.01);

%Generate White Noise
n_white = randn([1 B])';      % multiply of power 1
n_white = n_white - mean(n_white); % white noise must be DC free

%Generate Coloured Noise
n_out   = filter(b,a,n_white);     % filtering operation produces coloured

Is this correct? Because, according to my simulation, i have a bias of
some 40dB between my analytical calculation and simulation.

Thanks for all answers! :-)