# Generating 1/f^b colored time series

Tags:
1. Mar 3, 2015

### Jon Norberg

Please excuse (and ignore) this if this is not the right place to ask this. I am an ecologists and need to generate a time series with a specific color or frequency spectra. I never learned how fourier transforms work in class and while I get the gist from reading there are so many subtleties that makes it hard to get it right unless one spends considerable time understanding it all. So I hope to get some help here.

I want to be able to define minFreq, maxFreq, Nfreq, Variance and color. I do not want to generate a discrete time series but instead have a function that provides me with a continuous function over time, even if it is evaluated at a specific time. Also, I'd prefer to make this in the sine domain instead of complex.

I want to get two vectors (amplitude, A and phase, P) by providing minFreq, maxFreq, Nfreq, Variance (of the time series) and color such that I can call

T(t,A,P)=sum(A*sin(w*t+P))

with the output having the given variance and color

I tried this code but does not have the properties I need and I probably made many errors in ignorance.

N=64
k=1:N
maxP=365
minP=1
k=linspace(minP,maxP,N)
w=2*pi*k'./maxP
b=1
p=rand(N,1)*2*pi
a=ones(N,1).*(1./w.^(b/2))
for t=1:1000
T(t)=sum(a.*sin(t*w+p))./sum(a);
end

*slight edit*

Any hints are greatly appreciated

P.S. is it possible to define the vectors such that the generated time serie's variance is independent of the choice of Nfreq and color?

Last edited: Mar 3, 2015
2. Mar 8, 2015