You could filter this digitally using a low pass filter:
int valueFilt = (1-0.99)*value + 0.99*valueFilt;
Change the 0.99 to change the cut off frequency (closer to 1.0 is lower frequency). The actual expression for that value is exp(-2*pi*f/fs) where f is the cutoff frequency you want and fs is the frequency the data is sampled at.
Another type of "digital filter" is an event filter. It works well on data that has outliers; e.g. 9,9,8,10,9,25,9 . An event filter returns the most frequent value. Statistically this is the mode.
Statistical averages such as Mean, Mode etc.. can be calculated using the Arduino Average Library.
An example taken from the Arduino Library page referred to :
#include <Average.h>
#define CNT 600
int d[CNT];
void setup()
{
Serial.begin(9600);
}
void loop()
{
int i;
for(i=0; i<CNT; i++)
{
d[i] = random(500);
}
Serial.print("Mean: ");
Serial.print(mean(d,CNT),DEC);
Serial.print(" Mode: ");
Serial.print(mode(d,CNT),DEC);
Serial.print(" Max: ");
Serial.print(maximum(d,CNT),DEC);
Serial.print(" Min: ");
Serial.print(minimum(d,CNT),DEC);
Serial.print(" Standard deviation: ");
Serial.print(stddev(d,CNT),4);
Serial.println("");
Serial.println("");
delay(5000);
}