Table of Contents

Class ShannonEntropyIndicators

Namespace
Virtufin.Base.Behavior
Assembly
Virtufin.Base.dll

Running Shannon entropy over a source indicator's values — the two variants (fixed sample count, fixed time window) mirror SimpleMovingAverage<TTime, TValue>'s own two variants, but composed from the general Take/TimeWindow combinators rather than a specialized O(1) fold: entropy has no cheap incremental update the way a sum does (evicting one sample from a frequency table doesn't cheaply update -Σp·log(p)), so both variants materialize the window on every Value read (O(window size)).

public static class ShannonEntropyIndicators
Inheritance
ShannonEntropyIndicators
Inherited Members

Methods

RunningShannonEntropy<TSelf, TSample, TValue>(IIndicator<TSelf, TSample, TValue>, int, double)

Running Shannon entropy over the last count values the source indicator held — the count-bounded variant.

public static MappedIndicator<TakeIndicator<TSelf, TSample, TValue>, TSample, ImmutableArray<TValue>, double> RunningShannonEntropy<TSelf, TSample, TValue>(this IIndicator<TSelf, TSample, TValue> source, int count, double logBase = 2) where TSelf : IIndicator<TSelf, TSample, TValue>

Parameters

source IIndicator<TSelf, TSample, TValue>

The source indicator whose values are the symbols.

count int

The window size. Must be positive.

logBase double

The logarithm base — bits (2, the default) or nats (E).

Returns

MappedIndicator<TakeIndicator<TSelf, TSample, TValue>, TSample, ImmutableArray<TValue>, double>

Type Parameters

TSelf
TSample
TValue

RunningShannonEntropy<TSelf, TSample, TValue, TTime>(IIndicator<TSelf, TSample, TValue>, Func<TSample, TTime>, Func<TTime, TTime, bool>, double)

Running Shannon entropy over the trailing time window — the duration-bounded variant.

public static MappedIndicator<TimeWindowIndicator<TSelf, TSample, TValue, TTime>, TSample, ImmutableArray<TimestampedSample<TTime, TValue>>, double> RunningShannonEntropy<TSelf, TSample, TValue, TTime>(this IIndicator<TSelf, TSample, TValue> source, Func<TSample, TTime> timeOf, Func<TTime, TTime, bool> isExpired, double logBase = 2) where TSelf : IIndicator<TSelf, TSample, TValue> where TTime : IComparable<TTime>

Parameters

source IIndicator<TSelf, TSample, TValue>

The source indicator whose values are the symbols.

timeOf Func<TSample, TTime>

Extracts the observation time from an incoming sample.

isExpired Func<TTime, TTime, bool>

Called as isExpired(oldestTime, latestTime) during eviction to decide whether the oldest in-window observation has aged out.

logBase double

The logarithm base — bits (2, the default) or nats (E).

Returns

MappedIndicator<TimeWindowIndicator<TSelf, TSample, TValue, TTime>, TSample, ImmutableArray<TimestampedSample<TTime, TValue>>, double>

Type Parameters

TSelf
TSample
TValue
TTime