Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

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.

share|improve this question
1  
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

migrated from stackoverflow.com Oct 26 '11 at 20:56

1 Answer

up vote 4 down vote accepted

The [1] term is the zero frequency term- i.e. it's the mean. It does not denote oscillation. Any other strong terms do denote oscillation. The [2] term, and it's complement at [11], denotes low-frequency oscillation. You can see that in the time series by noting that Species A starts low, grows big, then goes low again. Species B is the inverse.

Edit: After thinking about this a little more, it would probably be better to use auto-correlation (Google it if you don't know what it is) to find periodicity rather than Fourier transforms. Auto-correlation will detect any kind of periodicity, not just sinusoidal tones, and would probably be more appropriate for large data sets.

share|improve this answer
thanks, if I analysed the data with an algorithm, would it be possible to get a single value of how close the data is to a perfect oscillation? And is the [1] term not the sum of all the components? – Sycren Oct 25 '11 at 23:51
@Sycren A perfect oscillation would be where the first term is something positive (at least in your population case, in the more general case the first term could be zero), and all of the other terms are zero except for two- the tone complements. The easiest way to see what I'm talking about is to create a sine wave (or cosine) and calculate its Fourier transform. – Jim Clay Oct 25 '11 at 23:55
@Sycren Also, please note that the other terms can only be perfectly zero in theory- in any real data series they will be small, but they will be non-zero. – Jim Clay Oct 25 '11 at 23:56
Can you think of any way of comparing the results from fourier with that of a sine graph to give a value denoting its similarity? – Sycren Oct 26 '11 at 0:06
2  
@Sycren You could do a ratio like "energy of top sinuosoid complement" / "sum of energies of all other terms" – Jim Clay Oct 26 '11 at 0:50
show 7 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.