Re: [BLACKBOX] LibVector question

From: [at]} <Wojtek>
Date: Wed, 25 Mar 2009 20:01:34 -0400

----boundary-LibPST-iamunique-2114707877_-_-
Content-type: text/plain

Robert:

   thank you for a quick answer. I should have been more specific.
Yes, my "filters" are FIR. I intend to apply such filters to
a waveform in order to obtain a "filtered waveform". My filters
are simple and completely specified by a set of known coefficients.
I am not concerned with the Z-transform, s-transform, or frequency
responses.

Wiki says that "correlation" and "convolution" are similar to each
other, hence my silly question. Steven Smith says the two are
basically the same, the difference being time-reversal of one
of the participants. My FIRs are time-symmetric. So I cannot
care about time-reversal, even if I wanted to. I just wanted
to know which one of the two functions is to be used in practice,
forget the theory...

The answer is LibVectors.Conv (x, h) and I am happy with that...

Thanks a lot!

Wojtek

On Wed, 25 Mar 2009, Robert wrote:

> Wojtek
>
> I quick, partial reply, as it is late at night.
>
> 1. The published version of Lib is several years old, but use that if it is
> later than what you have.
>
> 2. Why are there two functions Correlation & Convolution? Why indeed! Why is
> grass green? It just is. Look, for example, at
>
> http://en.wikipedia.org/wiki/Convolution
> &
> http://en.wikipedia.org/wiki/Cross-correlation
>
> for their accepted definitions (I hope mine are the same!).
> My definition of Correlation appears to be different (I use g(t-tau) rather
> than g(t+tau)). However this difference is illusary; see for example:
> http://en.wikipedia.org/wiki/Auto-correlation.
>
> I do agree that it is easy to get one confused with the other, but that is
> not a good idea!
>
> 3. By 'Filter' I assume you mean a 'digital' filter, or more precisely a
> discrete time filter analysed in terms of its 'z' transform. I mention this
> because the Filter SubSystem also provides some facilities for analysis of
> continuous time filters, ie things analysed in terms of their Laplace or 's'
> transform.
>
> I also assume that you want to implement a 'Finite Impulse Response' digital
> filter (one whose z transform is a polynomial) not an 'Infinite Impulse
> Response' filter (one whose z transform is a rational function).
>
> In this case (ie a FIR) the answer is simple.
>
> In 'x' is a vector describing the input sequence and 'h' is the filters time
> domain 'Impulse Response', ie its 'coefficients, then we get the output
> sequence 'y' by
>
> y := LibVectors.Conv (x, h);
>
> Or use LibCVectors.Conv if you are using Complex data.
>
>
> The Function FilterDFTs.Conv does the same thing as LibCVectors.Conv, but it
> is
> much 'faster' as it uses FFTs behind the scenes. But take 'faster' with a
> pinch of salt. It is certainly true if x and h are both long, and both of
> comparable size, but for your modest and disparate sizes there may not be
> much advantage unless you start adopting more complex 'overlap-and-add' or
> 'overlap-and-save' processing schemes. You possibly are not in enough of a
> hurry to justify the complexity.
>
>
> Regards
>
> Robert
>
>
>
>
> Wojtek Skulski wrote:
>> Robert:
>>
>> after a break I am back to using Lib for a small but important
>> project. I need to apply custom digital filters to waveform digitizer
>> data. I prefer not to use Filters because Filters look like overkill. I
>> thought of coding from scratch, but before I started
>> I fortunately looked at LibVectors. Both the convolution and the
>> correlation are there, so I can use LibVectors and on that occasion
>> brush up my knowledge concerning LibPlotters etc.
>>
>> Before I start, I have a couple silly questions.
>>
>> 1. Is it advisable to upgrade Lib now to the new revision?
>> The one I have on disk is a few years old.
>>
>> 2. Which function would you advise to digitally filter a waveform
>> with a filter? (Waveform has 1k samples, the filter has about
>> 40 coefficients.)
>>
>> res := Corr (waveform, filter);
>> res := Conv (waveform, filter);
>>
>> Why are there two functions anyway? The math seems almost the same
>> except for indexing. What is the reason for the two indexing schemes?
>>
>> Thank you,
>>
>> Wojtek
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> No virus found in this incoming message.
>> Checked by AVG - www.avg.com Version: 8.5.278 / Virus Database:
>> 270.11.28/2022 - Release Date: 03/25/09 07:16:00
>>
>
>

> ----
> To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to
> LISTSERV{([at]})nowhere.xy
>
>


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-2114707877_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2l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