Octavio Nogueira writes: > > Anybody got a good averaging algorithm? > > > > I've got a stream of numbers from 0 to 15 coming out of a PIC '620 > > comparator representing temperature of an appliance. When I turn on > > the flourescent lamp on my bench, the program...... > > I have another question about this. One of my pic aplications is a cow > scale, > I do my best to keep it still but you can imagine how the cow listen to > me, > it don't keep still at all. > The filtering I'm doing is: VAL=(LASTVAL/7+NEWVAL)/8 > I know thie is not the best way, is the median average better in this > case? To answer that question you need to know something about the probability distribution of the data you are measuring. To do this, you either guess what the distribution is (and you will be the best one to do that) or you estimate it. To estimate the probability distribution you record lots of measurements and then plot them as a histogram. If you find that the distribution is evenly spaced around the mean then averaging is good for you. If you find that the distribution extends a long way on one side (more than the other side) then the median may be your best estimator. Mal -- http://www.nfra.nl/~mgoris/