1
$\begingroup$

In all of the literature that I've found, numerical integration is used to approximate the value of the integral of some function over an interval. I'm trying to do something a little different:

I have a bunch of sampled values coming in at varying, small time steps. At each time step, I want to return the integral of the input for that time step.

So, for each time step, I simply add the new value multiplied by $\Delta t$ to a running total, and return the total for that time step.

This seems to produce the result that I want. However, is this the best way to do this? Without having the entire history of the input, is there a method of integrating that can reduce the error of the output for each time step?

$\endgroup$

1 Answer 1

1
$\begingroup$

If you don't know anything about where the input comes from, you can't do better. If you have a model of the input, you can do better. If you think it is polynomial of degree $n$, you can interpolate the last $n+1$ readings and be there. If you think it is periodic you can do an FFT on your favorite span and get an answer. The quality of your answer is dependent on the quality of your model.

Integration is a low-pass filter. If the function was $1$ for a long time, the integral becomes large, so you need to say you are returning the integral since some time.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .