title: Trimming collection used for calculation distance
body: <p>I have data collection where every record has information about speed of vehicle and time when this record was taken. Time difference between every record is various and it is about 300 ms. I use this collection to calculate travelled distance. I would like to trim this collection without too much loss of accuracy of calculation. Is there any algorithm for it?</p>
  
  <p>I tried to write simple algorithm that deleted record if record does not differed from previous one by at least X %. This algorithm is not working well. For example when I used algorithm with 3% and 4% trimming, number of records was same but calculated distance differed by 40m on 500m distance, where 4% was more accurate.     </p>
  
  <p>EDIT: Changes on Benjamin algorithm:</p>
  
  <p>I have time when record was collected so I need 3 records.</p>
  
  <p><code>double timeDifference = (next.time - curr.time) / (curr.time - previous.time);
  previuos.value = (previous.value + curr.value * timeDifference) / 2</code></p>
  
  <p>Also I dont want result to be double but long so I need to use rounding that will change distance. Also one minute is about 300 records so i hope that rounding will not effect calculation so much.     </p>