# how to generate an abitrary length colored noise when the PSD is know !

20 views (last 30 days)

Show older comments

##### 3 Comments

Bjorn Gustavsson
on 7 Oct 2014

### Answers (2)

Image Analyst
on 20 Aug 2014

You need to use inverse transform sampling. By doing that you can get any distribution you want from a uniform distribution. See http://en.wikipedia.org/wiki/Inverse_transform_sampling

I've also attached a demo where I pull random values from a Rayleigh distribution. Feel free to modify it.

You might also be interested in this: http://www.mathworks.com/matlabcentral/fileexchange/7309-randraw

##### 4 Comments

Bjorn Gustavsson
on 7 Oct 2014

Youssef Khmou
on 21 Aug 2014

You proceed using Inverse Fourier transform , here is how you can start , let us consider zero mean random variable of length 200 :

x=randn(200,1);

f=fft(x); % Discret Fourier Transform with same length

p=f.*conj(f); % Power

figure; plot(p)

C=real(ifft(f)); % inverse transform of the power

figure; plot(C,x) %

the original signal or the ones resulting from inverse transformation are similar, so suppose you have vector of Power spectrum, you ifft with the desired length N :

X=real(ifft(x,N));

##### 0 Comments

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!