MovingNormalStatistics Class
Click or drag to resize
Accord.NET (logo)

MovingNormalStatistics Class

Moving-window statistics.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.MovingMovingNormalStatistics

Namespace:  Accord.Statistics.Moving
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class MovingNormalStatistics : IMovingStatistics, 
	IRunningStatistics, IRunning<double>, IMoving<double>, 
	IEnumerable
Request Example View Source

The MovingNormalStatistics type exposes the following members.

Constructors
  NameDescription
Public methodMovingNormalStatistics
Initializes a new instance of the MovingNormalStatistics class.
Top
Properties
  NameDescription
Public propertyCount
Gets the number of samples within the window.
Public propertyMean
Gets the mean of the values within the window.
Public propertyStandardDeviation
Gets the standard deviation of the values within the window.
Public propertySum
Gets the sum the values within the window.
Public propertySumOfSquares
Gets the sum of squared values within the window.
Public propertyVariance
Gets the variance of the values within the window.
Public propertyWindow
Gets the size of the window.
Top
Methods
  NameDescription
Public methodClear
Removes all elements from the window and resets statistics.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetEnumerator
Returns an enumerator that iterates through the collection.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodPush
Pushes a value into the window.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodSetEqualsDouble
Compares two enumerables for set equality. Two enumerables are set equal if they contain the same elements, but not necessarily in the same order.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks
Provides statistics derived from successive segments of constant, overlapping size ('windowSize') of a series of values. Values are added one at a time to a MovingNormalStatistics instance through Push(Double) method and are actually kept inside the instance.
Examples
// Moving Normal Statistics can be used to keep track of the mean, variance and standard 
// deviation of the last N samples that have been fed to it. It is possible to feed one 
// value at a time, and the class will keep track of the mean and variance of the samples 
// without registering the samples themselves. 

// An example where this class can be useful is when trying to filter the (x,y) trajectories 
// of a movement tracker (i.e. to show the average point on the past 10 frames) and monitor 
// the quality of the tracking (i.e. if the variance becomes too high, tracking might have been lost).

// Fix seed for reproducible results
Accord.Math.Random.Generator.Seed = 0;

Random rnd = Accord.Math.Random.Generator.Random;

// Create a estimator that will keep the mean and standard deviation of the past 5 samples:
var normal = new MovingNormalStatistics(windowSize: 5);

// Read 50 samples
for (int i = 0; i < 50; i++)
    normal.Push(rnd.Next(1, 10));

// The properties of the 5 last samples are:
double sum = normal.Sum; // 21
double mean = normal.Mean; // 4.2
double stdDev = normal.StandardDeviation; // 2.4899799195977463
double var = normal.Variance; // 6.2
See Also