Online & windowed

History

TimeDag.historyFunction
history(x::Node{T}, window::Int) -> Node{Vector{T}}

Create a node whose values represent the last window values seen in x.

Each value will be vector of length window, and the result will only start ticking once window values have been seen. The vector value contains time-ordered observations, with the most recent observation last.

source

Cumulative & rolling statistics

Base.prodFunction
prod(x::Node) -> Node

Create a node which ticks when x ticks, with values of the cumulative product of x.

source
prod(x::Node, window::Int; emit_early::Bool=false) -> Node
prod(x::Node, window::TimePeriod; emit_early::Bool=false) -> Node

Create a node of the rolling product of x over the last window knots, or time interval.

If emit_early is false, then the node returned will only start ticking once the window is full. Otherwise, it will tick immediately with a partially-filled window.

source
Base.sumFunction
sum(x::Node) -> Node

Create a node which ticks when x ticks, with values of the cumulative sum of x.

source
sum(x::Node, window::Int; emit_early::Bool=false) -> Node
sum(x::Node, window::TimePeriod; emit_early::Bool=false) -> Node

Create a node of the rolling sum of x over the last window knots, or time interval.

If emit_early is false, then the node returned will only start ticking once the window is full. Otherwise, it will tick immediately with a partially-filled window.

source
Statistics.meanFunction
mean(x::Node) -> Node

Create a node which ticks when x ticks, with values of the running mean of x.

source
mean(x::Node, window::Int; emit_early::Bool=false) -> Node
mean(x::Node, window::TimePeriod; emit_early::Bool=false) -> Node

Create a node of the rolling mean of x over the last window knots, or time interval.

If emit_early is false, then the node returned will only start ticking once the window is full. Otherwise, it will tick immediately with a partially-filled window.

source
Statistics.varFunction
var(x::Node; corrected::Bool=true) -> Node

Create a node which ticks when x ticks, with values of the running variance of x.

This is equivalent to a sample variance over the n values of x observed at and before a given time. If corrected is true (the default), we normalise by n-1, otherwise we normalise by n.

source
var(x::Node, window::Int; emit_early::Bool=false, corrected::Bool=true) -> Node
var(x::Node, window::TimePeriod; emit_early::Bool=false, corrected::Bool=true) -> Node

Create a node of the rolling variance of x over the last window knots, or time interval.

If emit_early is false, then the node returned will only start ticking once the window is full. Otherwise, it will tick immediately with a partially-filled window.

This is equivalent to a sample variance over the n values of x (capped at window), observed at and before a given time. If corrected is true (the default), we normalise by n-1, otherwise we normalise by n.

source
Statistics.stdFunction
std(x::Node; corrected::Bool=true) -> Node

Create a node which ticks when x ticks, with values of the running standard deviation of x.

This is equivalent to sqrt(var(x; corrected)).

source
std(x::Node, window::Int; emit_early::Bool=false, corrected::Bool=true) -> Node
std(x::Node, window::TimePeriod; emit_early::Bool=false, corrected::Bool=true) -> Node

Create a node of the rolling standard deviation of x over the last window knots, or time interval.

If emit_early is false, then the node returned will only start ticking once the window is full. Otherwise, it will tick immediately with a partially-filled window.

This is equivalent to sqrt(var(x, window; emit_early, corrected)).

source
Statistics.covFunction
cov(x, y[, alignment]; corrected::Bool=true) -> Node

Create a node which ticks with values of the running covariance of x and y.

The specified alignment controls the behaviour when x and y tick at different times, as per the documentation in Alignment. When not specified, it defaults to UNION.

This is equivalent to a sample covariance over the n values of (x, y) pairs observed at and before a given time. If corrected is true (the default), we normalise by n-1, otherwise we normalise by n.

source
cov(x, y, window::Int[, alignment]; emit_early=false, corrected=true) -> Node
cov(x, y, window::TimePeriod[, alignment]; emit_early=false, corrected=true) -> Node

Create a node of the rolling covariance of x and y over the last window knots, or time interval.

The specified alignment controls the behaviour when x and y tick at different times, as per the documentation in Alignment. When not specified, it defaults to UNION.

If emit_early is false, then the node returned will only start ticking once the window is full. Otherwise, it will tick immediately with a partially-filled window.

This is equivalent to a sample covariance over the n values of (x, y) pairs observed at and before a given time, with n capped at window. If corrected is true (the default), we normalise by n-1, otherwise we normalise by n.

source
cov(x::Node{<:AbstractVector}; corrected::Bool=true) -> Node

Create a node which ticks with values of the running covariance of x.

Warning

If the values of x change shape over time, this node will throw an exception during evaluation.

source
cov(x::Node{<:AbstractVector}, window::Int; corrected::Bool=true) -> Node

Create a node of the rolling covariance of x over the last window knots.

If emit_early is false, then the node returned will only start ticking once the window is full. Otherwise, it will tick immediately with a partially-filled window.

Warning

If the values of x change shape over time, this node will throw an exception during evaluation.

source
Statistics.corFunction
cor(x, y[, alignment]; corrected::Bool=true) -> Node

Create a node which ticks with values of the running correlation of x and y.

The specified alignment controls the behaviour when x and y tick at different times, as per the documentation in Alignment. When not specified, it defaults to UNION.

This is equivalent to a sample correlation over the n values of (x, y) pairs observed at and before a given time.

source
cor(x, y, window::Int[, alignment]; emit_early=false) -> Node
cor(x, y, window::TimePeriod[, alignment]; emit_early=false) -> Node

Create a node of the rolling covariance of x and y over the last window knots, or time interval.

The specified alignment controls the behaviour when x and y tick at different times, as per the documentation in Alignment. When not specified, it defaults to UNION.

If emit_early is false, then the node returned will only start ticking once the window is full. Otherwise, it will tick immediately with a partially-filled window.

This is equivalent to a sample correlation over the n values of (x, y) pairs observed at and before a given time, with n capped at window.

source
TimeDag.emaFunction
ema(x::Node, α::AbstractFloat) -> Node
ema(x::Node, w_eff::Integer) -> Node

Create a node which computes the exponential moving average of x.

The decay is specified either by α, which should satisfy 0 < α < 1, or by w_eff, which should be an integer greater than 1. If the latter is specified, then we compute α = 2 / (w_eff + 1).

For internal state $s_t$, with $s_0 = 0$, and resulting EMA series $m_t$, this has the form:

\[\begin{aligned} s_t &= s_{t-1} + (1 - \alpha) x_t \\ m_t &= \frac{\alpha s_t}{1 - (1 - \alpha)^t}. \end{aligned}\]

For further information, see the notational conventions and discussion on Wikipedia. Note that this function implements the variant including the correction for the initial convergence problem.

source