A rather unusual question...
I am looking for a way to calculate the coherence value of two signals
which are several cycles of a fixed frequency sinusoidal like waveform.
i.e. I need a single value in the range 0-1 for the coherence of the
two waveforms.
I have tried calculating the coherence using the standard formula:
|Sxy|^2 / (Sxx.Syy)
where Sxy is the Cross Power Spectrum and Sxx and Syy are the AutoPower
Spectrums
and then extracting the value of the single frequency I am interesed in
from the frequency domain response.
But the coherence specturm calcuation using this technique is only
valid with averaged data samples, and I only have *one* set of sampled
data for each waveform, so I always get a result of 1.0 regardless of
the actual coherence between the two waveforms.
Does anyone know of a way to calculate coherence, or a "coherence like"
result for *non-averaged* data that gives a result from 0 to 1 for two
similar sine waves?
Any help appreciated.
Thanks
Dave :)
Coherence Calculation
Started by ●November 29, 2005
Reply by ●November 30, 20052005-11-30
"David L. Jones" <altzone@gmail.com> wrote in message news:1133322147.878771.305150@z14g2000cwz.googlegroups.com...> A rather unusual question... > I am looking for a way to calculate the coherence value of two signals > which are several cycles of a fixed frequency sinusoidal like waveform. > i.e. I need a single value in the range 0-1 for the coherence of the > two waveforms. > > I have tried calculating the coherence using the standard formula: > |Sxy|^2 / (Sxx.Syy) > where Sxy is the Cross Power Spectrum and Sxx and Syy are the AutoPower > Spectrums > and then extracting the value of the single frequency I am interesed in > from the frequency domain response. > But the coherence specturm calcuation using this technique is only > valid with averaged data samples, and I only have *one* set of sampled > data for each waveform, so I always get a result of 1.0 regardless of > the actual coherence between the two waveforms. > > Does anyone know of a way to calculate coherence, or a "coherence like" > result for *non-averaged* data that gives a result from 0 to 1 for two > similar sine waves? > > Any help appreciated. > > Thanks > Dave :) >No - I always average. McC
Reply by ●November 30, 20052005-11-30
David L. Jones wrote:> A rather unusual question... > I am looking for a way to calculate the coherence value of two signals > which are several cycles of a fixed frequency sinusoidal like waveform. > i.e. I need a single value in the range 0-1 for the coherence of the > two waveforms.Using coherence on pure (or close-to-pure) sinusoids is usually a bad idea -- because, if the sinusoids are of the same frequency (i.e. are phase or frequency locked), they'll be "completely coherent", and if they're not they won't be.> I have tried calculating the coherence using the standard formula: > |Sxy|^2 / (Sxx.Syy) > where Sxy is the Cross Power Spectrum and Sxx and Syy are the AutoPower > Spectrums > and then extracting the value of the single frequency I am interesed in > from the frequency domain response. > But the coherence specturm calcuation using this technique is only > valid with averaged data samples, and I only have *one* set of sampled > data for each waveform, so I always get a result of 1.0 regardless of > the actual coherence between the two waveforms.I don't think it's because you only have one set of data, I think it's because you're only looking at one frequency --- that of the sinusoids of interest.> Does anyone know of a way to calculate coherence, or a "coherence like" > result for *non-averaged* data that gives a result from 0 to 1 for two > similar sine waves?Start back at square one: tell us why you're really interested in the sine waves! :-) Do they have a phase-shift between them? -> Use correlation to find it. Do they have a frequency-shift between them? -> Mix (multiply) them and look at the beat frequency. You'll need to supply the background before we can help further, I think. Ciao, Peter K.
Reply by ●November 30, 20052005-11-30
Peter K. wrote:> David L. Jones wrote: > > > A rather unusual question... > > I am looking for a way to calculate the coherence value of two signals > > which are several cycles of a fixed frequency sinusoidal like waveform. > > i.e. I need a single value in the range 0-1 for the coherence of the > > two waveforms. > > Using coherence on pure (or close-to-pure) sinusoids is usually a bad > idea -- because, if the sinusoids are of the same frequency (i.e. are > phase or frequency locked), they'll be "completely coherent", and if > they're not they won't be.Yes, I am aware it's not the best of ideas, as coherence is usually done and calculated over a frequency domain with broadband data. The two waveforms will in practice not be pure sinusoids, but will have minor noise and distortion components, so in theory a coherence calculation is possible. In fact, the goal is to have them as completely coherent as possible (as it is for most systems) i.e. no noise or distortion is added to the system, and all of the output signal is due entirely to the input signal.> > I have tried calculating the coherence using the standard formula: > > |Sxy|^2 / (Sxx.Syy) > > where Sxy is the Cross Power Spectrum and Sxx and Syy are the AutoPower > > Spectrums > > and then extracting the value of the single frequency I am interesed in > > from the frequency domain response. > > But the coherence specturm calcuation using this technique is only > > valid with averaged data samples, and I only have *one* set of sampled > > data for each waveform, so I always get a result of 1.0 regardless of > > the actual coherence between the two waveforms. > > I don't think it's because you only have one set of data, I think it's > because you're only looking at one frequency --- that of the sinusoids > of interest.No, it's the same over the entire frequency domain. The standard coherence function as presented relies on averaging. If you have calculate coherence with no averaging you get a result of 1.0 in every frequency bin. This is why every dynamic signal analyser will not allow you to display coherence without turning on averaging.> > Does anyone know of a way to calculate coherence, or a "coherence like" > > result for *non-averaged* data that gives a result from 0 to 1 for two > > similar sine waves? > > Start back at square one: tell us why you're really interested in the > sine waves! :-)For mostly political reasons (don't ask!) I require a "coherence" number of 0 to 1 to indicate the "quality" of one waveform compared to a reference. The standard way to do this is with a coherence function, but in this case I do not have the averaged data sets available to do this usign the standard technique. In the end I may have to compare the signals in the time domain instead of using the coherence function in the frequency domain. I have a way to do this to give a 0 to 1 "coherence like" number, but I am wondering if anyone knows how to do it in the frequency domain using a coherence function? I know there are many other ways to compare two waveforms, but I need a 0 to 1 "coherence" indication display. Dave :)
Reply by ●November 30, 20052005-11-30
David L. Jones wrote:> A rather unusual question... > I am looking for a way to calculate the coherence value of two signals > which are several cycles of a fixed frequency sinusoidal like waveform. > i.e. I need a single value in the range 0-1 for the coherence of the > two waveforms.Try Average Cross-Correlation R12(t) = (Integration sign from -infinity to +infinity) v1(t)*v2(t)*(T+t)dt This is for non-peiodic waveforms. reference: Principles of Communication Systems - Taub+Schilling Alan
Reply by ●November 30, 20052005-11-30
Alan Peake wrote:> David L. Jones wrote: > > A rather unusual question... > > I am looking for a way to calculate the coherence value of two signals > > which are several cycles of a fixed frequency sinusoidal like waveform. > > i.e. I need a single value in the range 0-1 for the coherence of the > > two waveforms. > > Try Average Cross-Correlation > R12(t) = (Integration sign from -infinity to +infinity) > v1(t)*v2(t)*(T+t)dt > This is for non-peiodic waveforms. > reference: Principles of Communication Systems - Taub+Schilling > > AlanThanks Alan. My waveform will however be periodic, several full cycles of fixed frequency data. So probably not suitable? Dave :)
Reply by ●November 30, 20052005-11-30
"David L. Jones" <altzone@gmail.com> writes:> Yes, I am aware it's not the best of ideas, as coherence is usually > done and calculated over a frequency domain with broadband data.OK.> The two waveforms will in practice not be pure sinusoids, but will have > minor noise and distortion components, so in theory a coherence > calculation is possible. In fact, the goal is to have them as > completely coherent as possible (as it is for most systems) i.e. no > noise or distortion is added to the system, and all of the output > signal is due entirely to the input signal.So the outcome you'd like is for the "coherence" to be 1.> > I don't think it's because you only have one set of data, I think it's > > because you're only looking at one frequency --- that of the sinusoids > > of interest. > > No, it's the same over the entire frequency domain. The standard > coherence function as presented relies on averaging. If you have > calculate coherence with no averaging you get a result of 1.0 in every > frequency bin. This is why every dynamic signal analyser will not allow > you to display coherence without turning on averaging.OK. That's a little strange, but perhaps you're right about the averaging... though I'm not exactly sure what you mean. Dumb question: why can't you just block the data you have into, admittedly smaller, datasets so you _can_ use the averaging technique? That's what matlab does: if I do this: x = sin(0.090823*[0:1023]+rand(1)*2*pi) + randn(1,1024); y = sin(0.090823*[0:1023]+rand(1)*2*pi) + randn(1,1024); and then try cohere(x,y,1024) everything is 1, but if I go cohere(x,y,128) I don't get the frequency resolution, but I do get something that's 1 around the right frequency and not 1 outside of that. Bear in mind that this example is very fake: even with random phases, the freqyencies are effectively "locked".> For mostly political reasons (don't ask!) I require a "coherence" > number of 0 to 1 to indicate the "quality" of one waveform compared to > a reference.OK. Ain't politics a killer? :-)> The standard way to do this is with a coherence function, but in this > case I do not have the averaged data sets available to do this usign > the standard technique. > > In the end I may have to compare the signals in the time domain instead > of using the coherence function in the frequency domain. I have a way > to do this to give a 0 to 1 "coherence like" number, but I am wondering > if anyone knows how to do it in the frequency domain using a coherence > function? > > I know there are many other ways to compare two waveforms, but I need a > 0 to 1 "coherence" indication display.Total harmonic distortion (THD)? That'll start at zero and probably never get close to 1. If you need "good" to be close to 1, how about: 1 - THD? Thanks for taking the time to explain more about the problem. Let us know if any of this is a help. Ciao, Peter K.
Reply by ●November 30, 20052005-11-30
David L. Jones wrote:> Peter K. wrote: > >>David L. Jones wrote: >> >> >>>A rather unusual question... >>>I am looking for a way to calculate the coherence value of two signals >>>which are several cycles of a fixed frequency sinusoidal like waveform. >>>i.e. I need a single value in the range 0-1 for the coherence of the >>>two waveforms. >> >>Using coherence on pure (or close-to-pure) sinusoids is usually a bad >>idea -- because, if the sinusoids are of the same frequency (i.e. are >>phase or frequency locked), they'll be "completely coherent", and if >>they're not they won't be. > > > Yes, I am aware it's not the best of ideas, as coherence is usually > done and calculated over a frequency domain with broadband data. > > The two waveforms will in practice not be pure sinusoids, but will have > minor noise and distortion components, so in theory a coherence > calculation is possible. In fact, the goal is to have them as > completely coherent as possible (as it is for most systems) i.e. no > noise or distortion is added to the system, and all of the output > signal is due entirely to the input signal. > > >>>I have tried calculating the coherence using the standard formula: >>> |Sxy|^2 / (Sxx.Syy) >>>where Sxy is the Cross Power Spectrum and Sxx and Syy are the AutoPower >>>Spectrums >>>and then extracting the value of the single frequency I am interesed in >>>from the frequency domain response. >>>But the coherence specturm calcuation using this technique is only >>>valid with averaged data samples, and I only have *one* set of sampled >>>data for each waveform, so I always get a result of 1.0 regardless of >>>the actual coherence between the two waveforms. >> >>I don't think it's because you only have one set of data, I think it's >>because you're only looking at one frequency --- that of the sinusoids >>of interest. > > > No, it's the same over the entire frequency domain. The standard > coherence function as presented relies on averaging. If you have > calculate coherence with no averaging you get a result of 1.0 in every > frequency bin. This is why every dynamic signal analyser will not allow > you to display coherence without turning on averaging. > > >>>Does anyone know of a way to calculate coherence, or a "coherence like" >>>result for *non-averaged* data that gives a result from 0 to 1 for two >>>similar sine waves? >> >>Start back at square one: tell us why you're really interested in the >>sine waves! :-) > > > For mostly political reasons (don't ask!) I require a "coherence" > number of 0 to 1 to indicate the "quality" of one waveform compared to > a reference. > The standard way to do this is with a coherence function, but in this > case I do not have the averaged data sets available to do this usign > the standard technique. > > In the end I may have to compare the signals in the time domain instead > of using the coherence function in the frequency domain. I have a way > to do this to give a 0 to 1 "coherence like" number, but I am wondering > if anyone knows how to do it in the frequency domain using a coherence > function? > > I know there are many other ways to compare two waveforms, but I need a > 0 to 1 "coherence" indication display.In Matlab coh=rand; ;)> > Dave :) >
Reply by ●November 30, 20052005-11-30
David L. Jones wrote:> A rather unusual question... > I am looking for a way to calculate the coherence value of two signals > which are several cycles of a fixed frequency sinusoidal like waveform. > i.e. I need a single value in the range 0-1 for the coherence of the > two waveforms.To get the reasonable answer, please clarify what exactly are you trying to accomplish. What is the task and what is your goal? Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Reply by ●November 30, 20052005-11-30






