Table of Contents

Class Median

Namespace
Pamoja.Kit
Assembly
Pamoja.Kit.dll

Rejects a single wild reading, where an average would let it pull the answer.

public sealed class Median : IDisposable
Inheritance
Median
Implements
Inherited Members

Constructors

Median(int)

Creates an empty median filter.

public Median(int capacity = 32)

Parameters

capacity int

How many readings to take the median over, from 1 to 32; 32 unless told fewer. A small odd window, such as 5, follows a real change in a few readings; a window of 32 follows it 16 readings late.

Exceptions

ArgumentOutOfRangeException

capacity is not from 1 to 32.

Properties

Capacity

How many readings the filter keeps.

public int Capacity { get; }

Property Value

int

Value

The current median, or null before the first reading.

public float? Value { get; }

Property Value

float?

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Update(float)

Folds a reading in and returns the median of the window.

public float Update(float reading)

Parameters

reading float

The reading to add. One that is not a finite number is not kept.

Returns

float

The median across the window.