c - Bounded numerical integration -
please note not inquire code, insight, perchance encountered similar issue.
i mantaining code runs in real time in embedded system. safety reasons new check must implemented.
this check based on integrated value of variable. integral must span lastly "t_s" seconds, i.e. @ each new cycle have remove value variable had t_s seconds ago , add together current one.
the naive approach store in array lastly t_s*frequency floating point values.
running @ 62.5hz, rapidly wastes lots of precious , limited memory.
are there known approaches that, @ obvious expense of accuracy, cut down memory footprint of such check?
the value measurement coming real system, not generated function.
i thought storing n averages, each of m points , integrate n averages, cut down memory requirement n+m numbers, can made smaller t_s*frequency, wonder:
if has been studied , "optimal" point has been found (as function of m, example). serached, apparently google-fu broken, searching including "numerical integration" not lead for.
if there improve approach
i tagged post c because official language of project, solution not work in ansi-c not viable me, unfortunately.
i cannot seem find net page statistics calculations three(?) variables described. maybe when google-fu recovers.
alas, if don't need 100% accuracy can live average value, like:
avg = (avg * 0.95) + ((newvalue - avg) * 0.05);
this give approximate average of older values recent 1 (newvalue
) has no more 1/20 of influence; result multiplied 20 average integral. of course, may adjust 2 constants value of 1-(1/n)
, 1/n
, respectively, number n
of samples consider.
edit:
"on-line" (iterator) algorithms estimating statistical median, mode, skewness, kurtosis?
and
http://math.stackexchange.com/questions/106700/incremental-averageing
may have useful answers, too.
c memory-optimization
No comments:
Post a Comment