Moments Filter

A Filter is a Physlet that takes data from a data source, processes the data, and passes this processed data to a data listener.



x x*x

The Moments filter calculates the average and standard deviation (that is the square root of the mean squared deviation) of incoming data.  In this example, the red ball sends its state (e.g., a sate datum for an Animator object contains the variables t, x, y, vx, vy, ax, ay, fx, fy, and m) to the filter at every clock tick.  The script takes either the x or the x*x value and passes it to the Moments filter.

The Moments Physlet has two modes of operation whenever it receives complete data sets.  These modes are determined by the setAutoReplaceData flag. 

The setAutoReplaceData signature is setAutoReplaceData(int sid, boolean set).  The series identifier, sid, has no effect but has been included for consistency with other Physlets.  The set variable determines the value.