Sign in to follow this  
Nytegard

Comparing waves (beginners question)

Recommended Posts

I'm trying to find a good algorithm to compare two waves. Actually, not a single wave, but each wave contains multiple waves which have different amplitudes, frequencies, etc. And they don't have to be sinusoidal. There are no equations for the waves themselves, but I know all the datapoints on them. I just can't compare differences of the actual datapoints between the period that x(t) is in waves, because if a period is missing, that can throw everything off. I need a way to decide which wave is mostly like the base wave.

Share this post


Link to post
Share on other sites
Calculate the fourier transform of all the wave function and then calculate the integral of the difference function squared., the less the result the more similar are the waves:

b(t) : base wave ->fourier transform-> B(k)
x1(t) -> X1(k)
x2(t) -> X2(k)
...

D1=integral[ ( B(k) - X1(k) )^2 ) , k from -inf ... inf ]
D2=integral[ ( B(k) - X2(k) )^2 ) , k from -inf ... inf ]
...

The wave with the smallest D is most similar to the base wave.

Of course you can use DFT ( FFT ) and then you will have just a simple sum instead of the integration.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kambiz
Of course you can use DFT ( FFT ) and then you will have just a simple sum instead of the integration.

It looks like a DFT is his only option, as he specified that he only has a sampled wave, not a wavefunction.

I concur though. Fourier transform is the way to solve this problem.

Regards
Admiral

Share this post


Link to post
Share on other sites
A few notes.

A Fourier Transform maps a (function from time to magnitude) to a (function from frequency to magnitude). The 'default' frequency space is a sinusodal one.

In essence, it takes your function, and expresses it as a sum of sins and cosines.

DFT and FFT are versions of the Fourier Transform. As it happens, if you have a regularly sampled real-to-real function that has 'ends' (ie, it's domain is bounded), a Fourier Transform will capture all of the information in the original samples.

You can use Fourier Transform like actions and not map to a sinusodal based frequency domain. Doing so requires some heavy math, and the odds are you don't need it. (as an example, a FFT-like transformation is used when multiplying large integers (and I mean _large_ integers -- so large they are represented as linked lists)).

By mapping to the frequency domain, you can compare two different functions in a way that detects small high-amplitude waves and isolates the effects.

Share this post


Link to post
Share on other sites
What kind of waves will compare. If you have nice, regular waves, that are well described by their frequency spectrum, Fourier is the way to go. For other cases, you could use a wavelet transform. It expresses your function as a some of wavelets, each wavelet being localized in both time and frequency. This method may be more efficient if your waves are irregular.

Share this post


Link to post
Share on other sites
FFt are great for filtering if you want to preserve the nature of the signal. But they are not very good for data base manipulation. The reason is that FFT tell you how much information is in the signal but not where and when the information is happening in the signal.

For database operations on signals wavelet are much better, because they decompose the signal into series of signal each one similar to the other but with and extra amount of detail.
So they tell how much simillar each componnent to the next.
Most imagine and signature recognition programs use wavelets not fft.
Check out Haar or Walsh-Hadamard transfom basis.

Share this post


Link to post
Share on other sites
Quote:
Original post by DrakeSlayer
What kind of waves will compare. If you have nice, regular waves, that are well described by their frequency spectrum, Fourier is the way to go. For other cases, you could use a wavelet transform. It expresses your function as a some of wavelets, each wavelet being localized in both time and frequency. This method may be more efficient if your waves are irregular.


Well, I know I put this as a beginners question, but due to nature of the problem, I can't exactly describe it in full detail. It deals with something similar to speech recognition comparisons.

I have a series of sound waves, and I need to compare if any sections of any of the waves overlap with each other to a point where they could be considered similar (As they'll never be identitical), regardless of frequency or volume. The odds that everything will be sinusoidal are slight (like voice comparisons, not voice comparisons).

Thanks for the suggestions. I'll definately be looking into some of this.

Share this post


Link to post
Share on other sites
A Fourier Transform to a Sinusodal wavespace is a decent analogue to how we hear things.

We don't hear things as a sequence of PCM data -- we hear things as a set of frequencies. Well, that is closer to how we hear things. :)

And even if it isn't a perfect fit... FFT are so useful, even though we don't "see" things in a frequency space, it is still used to do image processing.

Share this post


Link to post
Share on other sites
Ok, with your signals, a simple DFT won't work. You should look at time frequency analysis (do a google search). It should give you a solution to your problem.

Share this post


Link to post
Share on other sites
Wavelets would also give a good approximation and allow for fuzzy comparison and data manipulation. I'd take a quick glance at HAAR wavelets.

-Ken Noland

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this