Table of Contents

Class Average

Namespace
Bonsai.Reactive
Assembly
Bonsai.Core.dll

Represents an operator that computes the numerical average of an observable sequence.

Marble diagram

The Average operator collects all the values from the source sequence and emits a single floating-point number representing their arithmetic mean. The single result value is emitted only when the source sequence terminates successfully.

Examples

Use Average to report the mean value at the end of the sequence.

Average Example

Signal Smoothing

Use Average to smooth a noisy signal by grouping elements with WindowCount, then applying Average inside a SelectMany.

Average Application Downsample

Note

This operation is equivalent to downsampling and reduces the number of elements in the sequence. To implement a moving average that preserves the number of elements, you can adjust the Skip property in WindowCount to create sliding windows.

Note

This example requires the Bonsai.Design.Visualizers package to be installed.

[Combinator]
public class Average
Inheritance
Average
Inherited Members

Methods

Process(IObservable<decimal>)

Computes the average of an observable sequence of decimal values.

Process(IObservable<double>)

Computes the average of an observable sequence of double values.

Process(IObservable<int>)

Computes the average of an observable sequence of int values.

Process(IObservable<long>)

Computes the average of an observable sequence of long values.

Process(IObservable<decimal?>)

Computes the average of an observable sequence of nullable decimal values.

Process(IObservable<double?>)

Computes the average of an observable sequence of nullable double values.

Process(IObservable<int?>)

Computes the average of an observable sequence of nullable int values.

Process(IObservable<long?>)

Computes the average of an observable sequence of nullable long values.

Process(IObservable<float?>)

Computes the average of an observable sequence of nullable float values.

Process(IObservable<float>)

Computes the average of an observable sequence of float values.