1

I am working on a project in Android for my Signal Processing course. My aim is to find signal properties, such as periodicity, even/odd, causality etc, given a user-input function. Right now, I am stuck at trying to figure out how to programmatically calculate the periodicity of a given function. I know the basics behind periodicity: f(t+T) = f(t)

The only idea I have right now is to extensively calculate values for the function, and then check for repetition of values. I know the method is quite stupid, given the fact I don't know how many such values I need to calculate to determine if it is periodic or not.

I know this can be done easily in Matlab, but again very difficult to port Matlab to Java. Is there something I am missing? I have been searching a lot, but haven't found anything useful.

Thanks for any help, in advance!

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
ndhaijaan
  • 309
  • 1
  • 7
  • 14
  • Have you looked at the FFT? If your data is nice only one (or few) frequencies should dominate the spectrum and would easily be visible on the fft, that is the frequency of your function. – arynaq Aug 04 '13 at 17:03
  • Are you asking how to calculate periodicity in Java or the algorithm in general? In either case what have you tried in Matlab or Java? – Andy Jones Aug 04 '13 at 17:16
  • @arynaq Maybe I'm being a little lazy, but no, I haven't looked up FFT. But I'm guessing there's no simpler way to do it. Is there some sort of program algorithm you might be referring to? I might have to code it out in Java.. Your help is much appreciated. – ndhaijaan Aug 05 '13 at 07:43
  • @AndyJones I could not find anything about calculating periodicity in Java, so I'm looking for algorithms in general. I know that in Matlab I could use something like seqperiod, but there are no such modules in Java. Right now, I'm just trying to constantly evaluate the function over a range, dump the values in an array, and then search the sequence for a pattern. – ndhaijaan Aug 05 '13 at 07:48

1 Answers1

0

If the function f is given as a symbolic expression, then the equation you stated can in some cases be solved symbolically. The amount of work required for this will depend on how your functions are described, what kinds of functions you allow, what libraries you use and so on.

If your only interaction with the function is evaluating it, i.e. if you treat the function description as a black box or obtain its values from some sensor, then your best bet would be a Fourier transformation of the data, to convert it from the time domain into frequency domain. In particularly, you probably want to choose your number of of samples to analyze as a power of two, and then use FFT to quickly obtain intensities for various frequencies.

MvG
  • 57,380
  • 22
  • 148
  • 276
  • My app takes in user input functions like y(x) = `sin(x)*cos(x)`. Based on that I tell if it is periodic or not, even/odd etc. I felt evaluating the function would be a better approach, since many of my future functionalities depend on it. With that in mind, I've been trying to use a Math Expression Evaluator (https://github.com/darius/expr). Of course this is just the beginning of my project, and I'm open to any suggestions. I shall look up FFTs in the meanwhile. Thanks for the tip! – ndhaijaan Aug 05 '13 at 08:01