Rootboy, On your example, how does the CPt get a value for "filteredPSI" the first time it tries to calculate it?
For the first time all it will accumulate is the PSI_Input * .02 portion. And you can make the .98/.02 ratio into anything that you like as long as it adds up to 1.00.
This ratio was for an otherwise unusable O2 sensor, your application would probably not need to go so medieval on it.
And of course you can set your free running timer up for any period that you like. Start out small, say, 100ms.
And my entire routine also had offset and slope adjustments. I left them out here in the interest of clarity. But for offset you would add a positive or negative offset. And for slope, you would multiply by a value of, for example, .95 - 1.05 to give yourself a +/- 5% slope.
The advantage to this method is that you don't have to create an array of variables to provide your base for your average.
And like Bernie pointed out, it approaches the the average over time, which is why this is a filter, not a true average. But I think that you will find that it gets very close.