Determining if a dataset approximates a sine wave

≯℡__Kan透↙ 提交于 2019-12-21 04:27:10

问题


Is there an algorithm that can be used to determine whether a sample of data taken at fixed time intervals approximates a sine wave?


回答1:


Take the fourier transform which transforms the data into a frequency table (search for fft, fast fourier transformation, for an implementation. For example, FFTW). If it is a sinus or cosinus, the frequency table will contain one very high value corresponding to the frequency you're searching for and some noise at other frequencies.

Alternatively, match several sinussen at several frequencies and try to match them using cross correlation: the sum of squares of the differences between your signal and the sinus you're trying to fit. You would need to do this for sinussen at a range of frequencies of course. And you would need to do this while translating the sinus along the x-axis to find the phase.




回答2:


You can calculate the fourier transform and look for a single spike. That would tell you that the dataset approximates a sine curve at that frequency.




回答3:


Shot into the blue: You could take advantage of the fact that the integral of a*sin(t) is a*cos(t). Keeping track of min/max of your data should allow you to know a.




回答4:


Check the least squares method.

@CookieOfFortune: I agree, but the Fourier series fit is optimal in the least squares sense (as is said on the Wikipedia article).

If you want to play around first with own input data, check the Discrete Fourier Transformation (DFT) on Wolfram Alpha. As noted before, if you want a fast implementation you should check out one of several FFT-libraries.



来源:https://stackoverflow.com/questions/992509/determining-if-a-dataset-approximates-a-sine-wave

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!