Reply by Rune Allnor March 4, 20082008-03-04
On 3 Mar, 21:41, wbsm...@gmail.com wrote:
> On Mar 3, 11:32 am, Rune Allnor <all...@tele.ntnu.no> wrote: > > > Ouch! Very low numbers. Wouldn't trust them at all. Either the > > numerics has bugs or the general idea is flawed. I would like > > to see coherence numbers in the range 0.1-1 before proceeding. > > or maybe the signals just have very low coherence? &#4294967295;i am pretty sure > the algorithm is working (i am using the matlab 'mscohere' function, > which returns an array of ones if i measure the coherence of one > signal with itself).
That doesn't mean too much. I don't think the Mathworks have been all out wrong in the past, but they have a long history of doing very simple things in very awkward ways.
>&#4294967295;and actually, there is a high value (nearly 1) > for the lowest frequency values of my two signals. &#4294967295;but when i get > above anything near about 0.5 kHz (my sampling frequency is 44.1 kHz), > the values decrease to the aforementioned range.
Maybe my idea about using cross spectra and coherence functions was flawed in the first place. Rune
Reply by March 3, 20082008-03-03
On Mar 3, 11:32 am, Rune Allnor <all...@tele.ntnu.no> wrote:

> Ouch! Very low numbers. Wouldn't trust them at all. Either the > numerics has bugs or the general idea is flawed. I would like > to see coherence numbers in the range 0.1-1 before proceeding.
or maybe the signals just have very low coherence? i am pretty sure the algorithm is working (i am using the matlab 'mscohere' function, which returns an array of ones if i measure the coherence of one signal with itself). and actually, there is a high value (nearly 1) for the lowest frequency values of my two signals. but when i get above anything near about 0.5 kHz (my sampling frequency is 44.1 kHz), the values decrease to the aforementioned range. bryan
Reply by Rune Allnor March 3, 20082008-03-03
On 3 Mar, 20:22, wbsm...@gmail.com wrote:
> On Mar 1, 4:15 am, Rune Allnor <all...@tele.ntnu.no> wrote: > > > > > > > On 1 Mar, 00:43, wbs <cssm...@gmail.com> wrote: > > > > On Feb 29, 12:26 pm, Rune Allnor <all...@tele.ntnu.no> wrote: > > > > > 2) if this is entirely nonsensical, what is a more standard way of > > > > > finding frequency-specific differences between two signals, and then > > > > > generating a third signal that is a frequency-dependent difference of > > > > > one signal from another? > > > > > The cross spectrum is one approach to test. Mind you, it > > > > basically detects the frequency bands where both the two > > > > signals have large energy. You want to identify where one > > > > signal is large and the other is small. That might require > > > > some tweaking, which might not be worth the effort. > > > > right, so i first looked at the cross spectrum of the two signals, and > > > then didn't really know what to do with that. &#4294967295;while this may not be > > > 'worth the effort' i wonder if you can help me figure out how i might > > > actually use the cross-PSD to get at this issue. > > > A *very* peliminary, naive approach (not to mention untested!) > > would be to first compute the energy normalized autospetcra: > > > pxx(f) = Pxx(f)/Px > > pyy(f) = Pyy(f)/Py > > > where Px means 'Pxx(f) integrated over f'. Then compute the > > cross spectrum cxy(f) with the same normalization - I wouldn't > > be surprised if this would look something like > > > cxy(f)^2 = Cxy(f)^2/sqrt(Px*Py) > > > This, all of a sudden, looks very similar to measuring the > > coherence between x and y. Which, in turn, *might* suggest > > that fitting a filter to the coherence spectrum between x > > and y might help you in your task. > > > Just keep in mind that I post this on an 'early' saturday > > morning following a late friday night, long before I got > > any hint of breakfast. If you still take the chance to > > follow up on my dubious hunches, you might want to check > > out > > > Bendat & Piersol: "Random Data" > > > Rune > > yes, signal coherence... this is a good lead, i think. &#4294967295;however, when > i do plot the coherence of the two signals, i am not entirely sure how > to interpret the results... i mean, clearly, places where the > coherence is very low are places i should think about setting bandpass > filters...
That was the idea, yes...
> problem is, i do not know how to define "very low" since > the range of the coherence plot is really only between 0 and 5e-5.
Ouch! Very low numbers. Wouldn't trust them at all. Either the numerics has bugs or the general idea is flawed. I would like to see coherence numbers in the range 0.1-1 before proceeding.
>&#4294967295;i > suppose i could start by setting bandpass filters at the local minima > in the coherence function. &#4294967295;comments on this idea?
Bail out! Unless you can find (and fix!) blunders and/or flaws.
> thanks for this lead. &#4294967295;i was thinking about coherence in looking at > the cross spectral density, but hadn't specifically tried this out.
Rune
Reply by March 3, 20082008-03-03
On Mar 1, 4:15 am, Rune Allnor <all...@tele.ntnu.no> wrote:
> On 1 Mar, 00:43, wbs <cssm...@gmail.com> wrote: > > > > > On Feb 29, 12:26 pm, Rune Allnor <all...@tele.ntnu.no> wrote: > > > > 2) if this is entirely nonsensical, what is a more standard way of > > > > finding frequency-specific differences between two signals, and then > > > > generating a third signal that is a frequency-dependent difference of > > > > one signal from another? > > > > The cross spectrum is one approach to test. Mind you, it > > > basically detects the frequency bands where both the two > > > signals have large energy. You want to identify where one > > > signal is large and the other is small. That might require > > > some tweaking, which might not be worth the effort. > > > right, so i first looked at the cross spectrum of the two signals, and > > then didn't really know what to do with that. while this may not be > > 'worth the effort' i wonder if you can help me figure out how i might > > actually use the cross-PSD to get at this issue. > > A *very* peliminary, naive approach (not to mention untested!) > would be to first compute the energy normalized autospetcra: > > pxx(f) = Pxx(f)/Px > pyy(f) = Pyy(f)/Py > > where Px means 'Pxx(f) integrated over f'. Then compute the > cross spectrum cxy(f) with the same normalization - I wouldn't > be surprised if this would look something like > > cxy(f)^2 = Cxy(f)^2/sqrt(Px*Py) > > This, all of a sudden, looks very similar to measuring the > coherence between x and y. Which, in turn, *might* suggest > that fitting a filter to the coherence spectrum between x > and y might help you in your task. > > Just keep in mind that I post this on an 'early' saturday > morning following a late friday night, long before I got > any hint of breakfast. If you still take the chance to > follow up on my dubious hunches, you might want to check > out > > Bendat & Piersol: "Random Data" > > Rune
yes, signal coherence... this is a good lead, i think. however, when i do plot the coherence of the two signals, i am not entirely sure how to interpret the results... i mean, clearly, places where the coherence is very low are places i should think about setting bandpass filters... problem is, i do not know how to define "very low" since the range of the coherence plot is really only between 0 and 5e-5. i suppose i could start by setting bandpass filters at the local minima in the coherence function. comments on this idea? thanks for this lead. i was thinking about coherence in looking at the cross spectral density, but hadn't specifically tried this out. bryan
Reply by Rune Allnor March 1, 20082008-03-01
On 1 Mar, 00:43, wbs <cssm...@gmail.com> wrote:
> On Feb 29, 12:26 pm, Rune Allnor <all...@tele.ntnu.no> wrote:
> > > 2) if this is entirely nonsensical, what is a more standard way of > > > finding frequency-specific differences between two signals, and then > > > generating a third signal that is a frequency-dependent difference of > > > one signal from another? > > > The cross spectrum is one approach to test. Mind you, it > > basically detects the frequency bands where both the two > > signals have large energy. You want to identify where one > > signal is large and the other is small. That might require > > some tweaking, which might not be worth the effort. > > right, so i first looked at the cross spectrum of the two signals, and > then didn't really know what to do with that. &#4294967295;while this may not be > 'worth the effort' i wonder if you can help me figure out how i might > actually use the cross-PSD to get at this issue.
A *very* peliminary, naive approach (not to mention untested!) would be to first compute the energy normalized autospetcra: pxx(f) = Pxx(f)/Px pyy(f) = Pyy(f)/Py where Px means 'Pxx(f) integrated over f'. Then compute the cross spectrum cxy(f) with the same normalization - I wouldn't be surprised if this would look something like cxy(f)^2 = Cxy(f)^2/sqrt(Px*Py) This, all of a sudden, looks very similar to measuring the coherence between x and y. Which, in turn, *might* suggest that fitting a filter to the coherence spectrum between x and y might help you in your task. Just keep in mind that I post this on an 'early' saturday morning following a late friday night, long before I got any hint of breakfast. If you still take the chance to follow up on my dubious hunches, you might want to check out Bendat & Piersol: "Random Data" Rune
Reply by Tim Wescott March 1, 20082008-03-01
On Fri, 29 Feb 2008 13:45:12 -0600, SteveSmith wrote:

> Hi Bryan, > Not silly at all. You are creating a custom frequency response called a > "Wiener filter": >
<snip> Does that mean it doesn't let the hot dogs through, or that it only lets the hot dogs through. (sorry, I'm tired, can't resist). -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
Reply by wbs February 29, 20082008-02-29
On Feb 29, 12:26 pm, Rune Allnor <all...@tele.ntnu.no> wrote:

> The end objective might make sense, but somehow I think > subtracting PSDs might not be a very good way to do things. > My gut feeling is that the cross spectrum ought to be used > instead.
yes, fair enough... this is kinda what i was wondering, and why i posted this here. i am not so sure what it means mathematically to go subtracting PSDs from each other.
> > 2) if this is entirely nonsensical, what is a more standard way of > > finding frequency-specific differences between two signals, and then > > generating a third signal that is a frequency-dependent difference of > > one signal from another? > > The cross spectrum is one approach to test. Mind you, it > basically detects the frequency bands where both the two > signals have large energy. You want to identify where one > signal is large and the other is small. That might require > some tweaking, which might not be worth the effort.
right, so i first looked at the cross spectrum of the two signals, and then didn't really know what to do with that. while this may not be 'worth the effort' i wonder if you can help me figure out how i might actually use the cross-PSD to get at this issue. regards, bryan
Reply by wbs February 29, 20082008-02-29
On Feb 29, 11:45 am, "SteveSmith" <Steve.Smi...@SpectrumSDI.com>
wrote:
> Hi Bryan, > Not silly at all. You are creating a custom frequency response called a > "Wiener filter": > > http://www.dspguide.com/ch17/3.htm > > then you need to find the FIR filter that implements this frequency > response: > > http://www.dspguide.com/ch17/1.htm > > Regards, > Steve
hi steve, very nice... thanks for the links. in matlab, i found a function called 'firwiener' but it is sparsely documented. it takes three arguments: filter order, and two signals. i wonder if this is generating a diff filter for me? i will have to look into this. thanks again, bryan
Reply by Jerry Avins February 29, 20082008-02-29
wbs wrote:
> On Feb 28, 11:21 pm, Tim Wescott <t...@seemywebsite.com> wrote: >> On Thu, 28 Feb 2008 15:50:12 -0800, cssmwbs wrote: >> >> It's hard to say without knowing what you want to do with the filtered >> signals. If you don't know why you want to do something that's a good >> indication that you haven't analyzed your problem enough. > > errrr... yes, i know exactly what i am going to do with the result... > unfortunately i work for a company, and i cannot explain sufficiently > well what i intend to do without giving more information than i can > reasonably give over a usenet group. suffice it to say i have thought > in considerable detail about how i will use the filtered and > unfiltered signals, and they will basically be applied to a system in > which we will measure response differences between the various > signals. > >> Do you mean _notch_ filters, which will filter the desired signal _out_, >> or do you mean _bandpass_ filters, which will filter out everything else? > > indeed, i mean bandpass filters... thank you for the correction. > >> Whatever else you want to do, if you take a set of cascaded FIR filters >> you can, indeed, convolve their impulse responses to get one big filter. >> This may not be the wisest thing, but it's a thing that you can do. > > ok... even though i do intend to use bandpass filters, why may this > not be the wisest thing to do (convolve the filters to get one big > filter)? what are the potential drawbacks of convolving 'cascaded FIR > filters'? just for my edification. > >> If you really want bandpass filters, then you don't want to cascade them >> -- unless the passbands overlap you'll just end up with nothing, and you >> can get that a lot quicker by multiplying your signal by 0. Instead, you >> want to add them (taking care that you're not messing them up if they >> overlap). > > ok, thanks also for this insight. so if the impulse responsea of the > passband filters have some overlap, i cannot add them, and instead > should run the set of filters sequentially? how much overlap is ok, > or is ANY overlap not ok?
If you have one filter that passes only blue light and you stack it with one that passes only red, nothing gets through. the only colors that get through cascaded filters are those that both pass. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Reply by Rune Allnor February 29, 20082008-02-29
On 29 Feb, 00:50, cssm...@gmail.com wrote:
> hi, > > i have two very noisy signals, and i am hoping to generate some sort > of "diff" of the two signals in frequency space. &#4294967295;so far, i have > computed a power spectral density estimate of each of the two > signals. &#4294967295;then i subtracted the PSD of one from the other (the idea > being that frequencies where one has low power and the other high > power, i should see a big difference... positive or negative, but big > differences where the power differs). &#4294967295;now i would like to filter one > of the signals, selecting only frequencies where there was a big > difference between the two. &#4294967295;this process may be better understood > with the following pseudocode of what i have done: > > sig1 = signal1 > sig2 = signal2 > > psd1 = computePSD(sig1) > psd2 = computePSD(sig2) > > psdDiff = absoluteValue(psd1 - psd2) > > diffPeaks = findPeaks(psdDiff) > > filteredSig = filter(sig1, diffPeaks) > > so, i have a couple questions: > 1) does this make any sense whatsoever to do something like this? &#4294967295;a > simple "hell no, not even a little" would be tolerated, as i really > have very little idea wtf i am doing here.
The end objective might make sense, but somehow I think subtracting PSDs might not be a very good way to do things. My gut feeling is that the cross spectrum ought to be used instead.
> 2) if this is entirely nonsensical, what is a more standard way of > finding frequency-specific differences between two signals, and then > generating a third signal that is a frequency-dependent difference of > one signal from another?
The cross spectrum is one approach to test. Mind you, it basically detects the frequency bands where both the two signals have large energy. You want to identify where one signal is large and the other is small. That might require some tweaking, which might not be worth the effort.
> 3) if this is not a totally absurd approach, what sorts of things do i > need to concern myself with when doing something like this? > specifically, i am concerned about the following: &#4294967295;if i have diffPeaks > returning a bunch of frequencies (like 1, 4, 9, 11, 18 and 23 kHz), > what are the limitations/consequences of repeatedly filtering the > signal with a series of notch filters at the specified frequencies?
As always it is a trade-off between bandwidth in frequency domain and ringing in time domain. A large notch bandwidth reduces ringing in time domain but might kill too much of the useful signal. And vice versa.
> or can i generate all the notch filters, convolve them together, and > then use that as a single filter? &#4294967295;
The two approaches are *formally* equivalent. There may be practical issues, though, e.g. numerical effects in fixed-point arithmetic, which favours one approach or the other.
> so this question amounts to: what > is a good way to filter a signal at a set of (non-continuous) specific > frequencies?
Rune