DSPRelated.com
Forums

integration of a continuous function

Started by Alex_001 February 23, 2009
On Feb 23, 6:18&#4294967295;pm, illywhacker <illywac...@gmail.com> wrote:
> On Feb 23, 4:19&#4294967295;pm, John <sampson...@gmail.com> wrote: > > > > > On Feb 23, 8:46&#4294967295;am, illywhacker <illywac...@gmail.com> wrote: > > > > On Feb 23, 2:23&#4294967295;pm, "Alex_001" <a.bast...@email.it> wrote: > > > > > Hi, > > > > it's well known that sampling a continuous function according to the > > > > sampling theorem requirements, you get all the information on the > > > > contunuous function just from the samples. > > > > now, if you have to get an accurate estimate of the integral of the > > > > continous function from samples satisfying the sampling theorem > > > > requirements, how can you &#4294967295;get a good estimate of such an integral? > > > > I noticed that if you use a sampling frequency close to the Nyquist rate > > > > and apply the definition of integration in the time domain ( sum(Xi* > > > > delta(x))) the value you get for the integral is totally inaccurate... > > > > You can express the original continuous function as a linear > > > combination of shifted sinc functions weighted by the sample values. > > > This is the reconstruction theorem. Any integral of the original > > > continuous function is therefore a linear combination of integrated > > > shifted sinc functions weighted by the sample values. > > > > illywhacker; > > > Is this another way of saying interpolate by a large factor using a > > sinc filter and then do sum(Xi*deltaX)? > > Yes. but the sinc function is determined by the sampling procedure and > the maximum frequency in the original signal
Sorry: I meant sampling rate, since we are not assuming exact Nyquist sampling. illywhacker;

Alex_001 wrote:

> for VLV: I know the problem could be pretty trivial
It could be trivial or it could be complicated. You haven't stated the problem. What you did was you asked for somebody to explain why your solution isn't working. The actual problem has been left to the imagination of the user. , but I do not work
> 100% of my time on this...and I just wanted to know if there was a esasy > solution. > Anyway, nobody forced you to read my thread and reply, did someone?
Believe it or not you were getting good advice. -jim
> > Alex
Alex_001 wrote:

> Hi, > it's well known that sampling a continuous function according to the > sampling theorem requirements, you get all the information on the > contunuous function just from the samples.
If you look closely, you will find that only works in the infinite time limit. Also, it only works if the signal isn't quantized, which they usually are by the time they get into a computer.
> now, if you have to get an accurate estimate of the integral of the > continous function from samples satisfying the sampling theorem > requirements, how can you get a good estimate of such an integral?
The sum of the points should be a good estimate. Quantization noise will average out in the long term.
> I noticed that if you use a sampling frequency close to the Nyquist rate > and apply the definition of integration in the time domain ( sum(Xi* > delta(x))) the value you get for the integral is totally inaccurate...
I believe for a sufficiently long integration time you should get the right answer. Sufficiently long should be such that the difference between the sampling frequency and Nyquist rate is much larger than 1/(integration time). That shouldn't be hard for real signals of practical use. For a CD at 44.1kHz and 20kHz frequency limit (40kHz Nyquist rate) that would require a time much longer than 1/(4.1kHz) or about 0.00025s. Much longer might be 100 or 1000 times as long, so say 0.25s. If that isn't enough, then state more details of the problem you are actually working on. -- glen
On Feb 23, 10:18 pm, jim <".sjedgingN0sp"@m...@mwt.net> wrote:
> Alex_001 wrote: > > for VLV: I know the problem could be pretty trivial > > It could be trivial or it could be complicated. You haven't stated the problem. > What you did was you asked for somebody to explain why your solution isn't > working. The actual problem has been left to the imagination of the user. > > , but I do not work > > > 100% of my time on this...and I just wanted to know if there was a esasy > > solution. > > Anyway, nobody forced you to read my thread and reply, did someone? > > Believe it or not you were getting good advice.
Telling someone to use polynomial interpolation while knowing nothing about the problem is the approach of someone who uses cookbook solutions. While that might be OK for Abvolt Inc., it is not good advice. illywhacker;

illywhacker wrote:
> > On Feb 23, 10:18 pm, jim <".sjedgingN0sp"@m...@mwt.net> wrote: > > Alex_001 wrote: > > > for VLV: I know the problem could be pretty trivial > > > > It could be trivial or it could be complicated. You haven't stated the problem. > > What you did was you asked for somebody to explain why your solution isn't > > working. The actual problem has been left to the imagination of the user. > > > > , but I do not work > > > > > 100% of my time on this...and I just wanted to know if there was a esasy > > > solution. > > > Anyway, nobody forced you to read my thread and reply, did someone? > > > > Believe it or not you were getting good advice. > > Telling someone to use polynomial interpolation while knowing nothing > about the problem is the approach of someone who uses cookbook > solutions. While that might be OK for Abvolt Inc., it is not good > advice.
Oh I suppose you think that you are GOD and that your sinc function is infinitely long and not just another polynomial. Should I take a moment to pray or would you prefer I make a sacrificial offering? The good advice I was referring to was this -> "Cut the bullshit. What are you really trying to do?" Everybody else (and you in particular) up to that point was giving bullshit advice "while knowing nothing about the problem" -jim
> > illywhacker;
On Feb 24, 3:03&#4294967295;pm, jim <".sjedgingN0sp"@m...@mwt.net> wrote:
> illywhacker wrote: > > > On Feb 23, 10:18 pm, jim <".sjedgingN0sp"@m...@mwt.net> wrote: > > > Alex_001 wrote: > > > > for VLV: I know the problem could be pretty trivial > > > > It could be trivial or it could be complicated. You haven't stated the problem. > > > What you did was you asked for somebody to explain why your solution isn't > > > working. The actual problem has been left to the imagination of the user. > > > > , but I do not work > > > > > 100% of my time on this...and I just wanted to know if there was a esasy > > > > solution. > > > > Anyway, nobody forced you to read my thread and reply, did someone? > > > > Believe it or not you were getting good advice. > > > Telling someone to use polynomial interpolation while knowing nothing > > about the problem is the approach of someone who uses cookbook > > solutions. While that might be OK for Abvolt Inc., it is not good > > advice. > > Oh I suppose you think that you are GOD and that your sinc function is > infinitely long and not just another polynomial.
Oh dear. The point about polynomials is not that they are not dense. It is the poor orthogonality properties, divergence, etc, etc, that make them poor choice for many tasks. The problem is to infer the original signal, or rather its integral. In the simplest cases, this means inverting an operator, whatever that operator might be. Its inverse, though, is surely not a low order polynomial, not even qualitatively. But the cookbook can be applied, and surely will produce reasonable results. illywhacker;
On Feb 23, 4:42&#4294967295;pm, Glen Herrmannsfeldt <g...@ugcs.caltech.edu> wrote:
> Alex_001 wrote: > > Hi, > > it's well known that sampling a continuous function according to the > > sampling theorem requirements, you get all the information on the > > contunuous function just from the samples. > > If you look closely, you will find that only works in the infinite > time limit. &#4294967295;Also, it only works if the signal isn't quantized, > which they usually are by the time they get into a computer. > > > now, if you have to get an accurate estimate of the integral of the > > continous function from samples satisfying the sampling theorem > > requirements, how can you &#4294967295;get a good estimate of such an integral? > > The sum of the points should be a good estimate. &#4294967295;Quantization noise > will average out in the long term. > > > I noticed that if you use a sampling frequency close to the Nyquist rate > > and apply the definition of integration in the time domain ( sum(Xi* > > delta(x))) the value you get for the integral is totally inaccurate... > > I believe for a sufficiently long integration time you should get > the right answer. &#4294967295;Sufficiently long should be such that the difference > between the sampling frequency and Nyquist rate is much larger > than 1/(integration time). &#4294967295; That shouldn't be hard for real > signals of practical use. &#4294967295;For a CD at 44.1kHz and 20kHz frequency > limit (40kHz Nyquist rate) that would require a time much longer > than 1/(4.1kHz) or about 0.00025s. &#4294967295;Much longer might be 100 > or 1000 times as long, so say 0.25s. > > If that isn't enough, then state more details of the problem > you are actually working on. > > -- glen
Hello Glen, The sum of the points is pretty close. But a simple correction gets you closer. Just sum all of the interior points plus add in 1/2 of the first and last point. The final sum should be scaled by sampling period (or divided by the sampling rate). This falls out from the integral of the scaled sync function. The error caused by tails of the omitted data (data outside of the integration interval) can be diluted down by taking more samples within the interval via a higher sampling rate, but the general approach gives a pretty good estimate. Of course the OP hasn't given detail about his problem so how good is good enough for his needs? But I think he, like a lot of people, need to experiment with this and learn more about the problem at hand and then be able to specify his problem. Our generic suggestions give him some things to try. Clay

Glen Herrmannsfeldt wrote:

> Alex_001 wrote: >
>> now, if you have to get an accurate estimate of the integral of the >> continous function from samples satisfying the sampling theorem >> requirements, how can you get a good estimate of such an integral? > > I believe for a sufficiently long integration time you should get > the right answer. Sufficiently long should be such that the difference > between the sampling frequency and Nyquist rate is much larger > than 1/(integration time).
Good point. The impact of the oscillating components into the integral falls like 1/t. VLV
Here's my problem:

we're aquiring a signal form a piezoelectric force sensor; the analog
signal is filtered by a lowpass filter at 5 kHz and sampled at 100 kHz. In
such a way we get a "smooth" waveform, that is what we want. 

What we need is to calculate the integral of this signal, on a 5 ms
window.
I was wondering if there's a EASY way to reduce the sampling frequency and
still get an accurate estimate (there are surely ways to do that, but if
too compicated is useless for our application, we'd rather have a higher
sampling frequency).

Following illywhacker's (and someoneelse's) advice, I wrote my continuous
function as a linear combination of shifted sinc functions weighted by the
sample values (recostruction theorem). 
Denoting with X(t) the continuous function, and X(n*T) it samples in [0,
To], I got for the integral in [0 T0] (N = total number of samples):

integral[0 , T0]{X(t)dt} = sum[n=0..N]{X(nT)* integral[-n ,
(T0-nT)/T]{sinc(p)dp}}

Now, the function integral[0 , x]{sinc(x)dx} is known and tabulate (Matlab
implements such a function, for example). So, if my procedure was correct,
it should be not that hard...I will try and let you know.

Alex


Alex_001 wrote:
> Here's my problem: > > we're aquiring a signal form a piezoelectric force sensor; the analog > signal is filtered by a lowpass filter at 5 kHz and sampled at 100 kHz. In > such a way we get a "smooth" waveform, that is what we want. > > What we need is to calculate the integral of this signal, on a 5 ms > window. > I was wondering if there's a EASY way to reduce the sampling frequency and > still get an accurate estimate
What could be simpler then a moving average filter?
> Following illywhacker's (and someoneelse's) advice, I wrote my continuous > function as a linear combination of shifted sinc functions weighted by the > sample values (recostruction theorem).
Extra knowledge is harmful to the idiots.
> Now, the function integral[0 , x]{sinc(x)dx} is known and tabulate (Matlab > implements such a function, for example).
"Matlab does all thinking for us" (TM) VLV