# Using Fourier analysis to check if data is oscillating

A simulation gives the population numbers for every species in the domain per frame. These vary over time and can be quite noisy, for example we might have:

Species A: 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1

Species B: 5, 4, 3, 3, 2, 2, 2, 1, 2, 3, 4

Fourier analysis gives:

Species A

[1]  31.0000000+0i -11.3435375+0i   0.7284459+0i  -0.4486906+0i
[5]   0.6467467+0i   0.4170355+0i   0.4170355+0i   0.6467467+0i
[9]  -0.4486906+0i   0.7284459+0i -11.3435375+0i


Species B

[1] 31.0000000+0.0000000i  7.7083901-1.7455710i  2.5347604+1.2715540i
[4]  0.0859162+0.3689912i  1.8966739-0.8223734i -0.2257406+0.1538824i
[7] -0.2257406-0.1538824i  1.8966739+0.8223734i  0.0859162-0.3689912i
[10]  2.5347604-1.2715540i  7.7083901+1.7455710i


How can I use this to give an idea if they are oscillating?

I wish to somehow use this in a genetic algorithm as the fitness function to see how close each dataset is to oscillating.

-
aah, I see this was produced in R :-) using fft(c(1,1,2,3,4,5,5,4,3,2,1)) and fft(c(5,4,3,3,2,2,2,1,2,3,4)). – Tomas Oct 26 '11 at 14:32
yes, although I need to find an equivalent method in java.. – Sycren Oct 26 '11 at 14:33
Once you get into the principle I think you will easily find a solution in any language. Also, R can be called from within many languages. – Tomas Oct 26 '11 at 14:38
OK, I see. What could be the problem here that the species population index is not precisely known (??? I suppose??) but also has its own uncertainty. And this uncertainty is not taken into account here. I'm afraid that you have to take it into account if you want to assess the significance of oscillation of particular species. Or you would have to have a long time series to separate the real oscillation from random one, +15 years AT LEAST I'd say ... – Tomas Oct 26 '11 at 14:47
species population index? What I would like to do is set a load of parameters for each species in a predator prey model and see if I can get them to live together without killing each other completely off hence the oscillation. Instead of setting the parameters manually I can use a genetic algorithm to search for me by tweaking the parameters. However I do need a fitness function for this to select which set of parameters is performing the best. This is the reason why I wanted to check if it was oscillating and have a single value that denotes how well it is – Sycren Oct 26 '11 at 15:06
show 1 more comment