Go to Post Cooperate BEHIND the curtain; compete IN FRONT OF it. - Travis Hoffman [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-01-2008, 22:36
Lafleur Lafleur is offline
Registered User
AKA: Tom Lafleur
FRC #0812
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2006
Location: San Diego
Posts: 34
Lafleur will become famous soon enoughLafleur will become famous soon enough
Data Smoothing

Here is a bit of code to use the Exponential moving average (EMA) function for data smoothing. I find it much superior to that of a straight average because it favors newer samples, making it more responsive. Also it requires one to save only one value between calculations.

To use, call the EMAweight function with the number of samples that you want to smoothing over, it will calculate a weight factor for the EMA function.

call EMA with the oldvalue, newsample and the weight

here is a reference for EMA:

http://www.esignal.com/futuresource/...tudies/emi.htm
Quote:
//prototypes

float EMA (int, int, float );
float EMAweight (float);

// how to use

w = EMAweight (30.0); // set weight
xEMA = EMA( xEMA, newsample, w); // old, new, weight


//
// Ema routines
//
float EMAweight (float samples)
{
return (2.0 / ( 1.0 + samples));
}

float EMA (int prevEMA, int newVALUE, float weightx)
{
return ((weightx * (newVALUE - prevEMA)) + prevEMA);
}
  #2   Spotlight this post!  
Unread 14-01-2008, 10:17
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: Data Smoothing

Quote:
Originally Posted by Lafleur View Post
Here is a bit of code to use the Exponential moving average (EMA) function for data smoothing.
Nice. We've stuck with arithmetic moving averages in the past since they are fast and can be implemented in pure integer math, but it's nice to see someone using this and posting sample code.
  #3   Spotlight this post!  
Unread 14-01-2008, 13:08
Lafleur Lafleur is offline
Registered User
AKA: Tom Lafleur
FRC #0812
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2006
Location: San Diego
Posts: 34
Lafleur will become famous soon enoughLafleur will become famous soon enough
Re: Data Smoothing

You can use this with integer math with changes to the math lib.... or use scaling on the weight ratio and final EMA
  #4   Spotlight this post!  
Unread 14-01-2008, 22:06
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Data Smoothing

Second (and higher) order IIR low pass filters have responses similar to this one.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Historical data Andrew Schuetze General Forum 0 15-05-2006 07:42
Data Communication coreyk IT / Communications 4 02-05-2005 19:09
Team Data Katy Scouting 3 02-04-2003 15:17
Match Data Jack Scouting 0 08-03-2003 16:49


All times are GMT -5. The time now is 18:38.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi