mil.navy.nps.dis
Class RunningAverage

java.lang.Object
  extended bymil.navy.nps.dis.RunningAverage

public class RunningAverage
extends java.lang.Object

This Java class allows for an object that will keep N items and return the average of those items when queried.

Version:
1.0
Author:
Scott D. Heller (http://web.nps.navy.mil/~brutzman) This code includes parts of Kent Watsen's EAI-based World.java/Ownship.java and Don McGregors's testing/BehaviorStreamBufferTest.java
Location:
http://www.web3d.org/WorkingGroups/vrtp/mil/navy/nps/dis/RunningAverage.java
History:
21 Nov 98 Scott D. Heller New

See Also:
EspduTransform

Constructor Summary
RunningAverage(int requestedNumberOfDataPoints)
          Constructor requires the number of data points to be retained to be specified.
 
Method Summary
 float addDataPoint(float dataPoint)
          Add one data point to the vector, and return the new average.
 float average()
          Function to return the calculated average.
protected static void debug(java.lang.String pDiagnostic)
          Debugging output.
 boolean getDEBUG()
           
 float getPrevUpdate()
          Returns the last update made to the circular queue.
 void setDEBUG(boolean pDEBUG)
           
protected static void trace(java.lang.String pDiagnostic)
          Debugging output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RunningAverage

public RunningAverage(int requestedNumberOfDataPoints)
Constructor requires the number of data points to be retained to be specified.

Method Detail

addDataPoint

public float addDataPoint(float dataPoint)
Add one data point to the vector, and return the new average.


average

public float average()
Function to return the calculated average.


getPrevUpdate

public float getPrevUpdate()
Returns the last update made to the circular queue. Useful when calculating deltas between updates.


getDEBUG

public boolean getDEBUG()

setDEBUG

public void setDEBUG(boolean pDEBUG)

debug

protected static void debug(java.lang.String pDiagnostic)
Debugging output. Pass in a string, and it gets printed out on the console. You can pass in strings such as "foo " + bar.getName().


trace

protected static void trace(java.lang.String pDiagnostic)
Debugging output. Pass in a string, and it gets printed out on the console. You can pass in strings such as "foo " + bar.getName().