Skip to content

RunningAverage

Under Construction

This documentation is auto-generated, and is a work in progress. Please see the source code at https://github.com/phetsims/dot/blob/main/js/RunningAverage.js for the most up-to-date information.

Overview

Data structure that keeps track of running average over a given self.

@author Sam Reid (PhET Interactive Simulations) @author Jonathan Olson (PhET Interactive Simulations)

Class RunningAverage

import { RunningAverage } from 'scenerystack/dot';

Constructor

new RunningAverage( windowSize )

Instance Methods

clear()

Clear the running average. @public

getRunningAverage()

Gets the current value of the running average. @public

@returns {number}

isSaturated()

Returns whether the number of samples is at least as large as the self size (the buffer is full). @public

@returns {boolean}

updateRunningAverage( sample )

Add a data point to the average and return the new running average. @public

@param {number} sample @returns {number}

Source Code

See the source for RunningAverage.js in the dot repository.