Skip to content

Instantly share code, notes, and snippets.

@datablend
Created January 4, 2012 13:43
Show Gist options
  • Save datablend/1560142 to your computer and use it in GitHub Desktop.
Save datablend/1560142 to your computer and use it in GitHub Desktop.
Update average speed
// Recalculate average speed
double previousspeed = (Double)torecord.getProperty("speed");
int previousoccurences = (Integer)torecord.getProperty("occurences");
double currentspeed = analyzer.getHorizontalSpeed(track.getTrkpt(i).getTime());
double denormalizespeed = previousspeed * previousoccurences;
double newspeed = ((denormalizespeed + currentspeed) / (previousoccurences + 1));
// Update the data accordingly
torecord.setProperty("speed",newspeed);
torecord.setProperty("occurences",previousoccurences+1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment