Online & windowed
History
TimeDag.history — Functionhistory(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.
Cumulative & rolling statistics
Base.prod — Functionprod(x::Node) -> NodeCreate a node which ticks when x ticks, with values of the cumulative product of x.
prod(x::Node, window::Int; emit_early::Bool=false) -> Node
prod(x::Node, window::TimePeriod; emit_early::Bool=false) -> NodeCreate 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.
Base.sum — Functionsum(x::Node) -> NodeCreate a node which ticks when x ticks, with values of the cumulative sum of x.
sum(x::Node, window::Int; emit_early::Bool=false) -> Node
sum(x::Node, window::TimePeriod; emit_early::Bool=false) -> NodeCreate 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.
Statistics.mean — Functionmean(x::Node) -> NodeCreate a node which ticks when x ticks, with values of the running mean of x.
mean(x::Node, window::Int; emit_early::Bool=false) -> Node
mean(x::Node, window::TimePeriod; emit_early::Bool=false) -> NodeCreate 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.
Statistics.var — Functionvar(x::Node; corrected::Bool=true) -> NodeCreate 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.
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) -> NodeCreate 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.
Statistics.std — Functionstd(x::Node; corrected::Bool=true) -> NodeCreate a node which ticks when x ticks, with values of the running standard deviation of x.
This is equivalent to sqrt(var(x; corrected)).
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) -> NodeCreate 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)).
Statistics.cov — Functioncov(x, y[, alignment]; corrected::Bool=true) -> NodeCreate 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.
cov(x, y, window::Int[, alignment]; emit_early=false, corrected=true) -> Node
cov(x, y, window::TimePeriod[, alignment]; emit_early=false, corrected=true) -> NodeCreate 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.
cov(x::Node{<:AbstractVector}; corrected::Bool=true) -> NodeCreate a node which ticks with values of the running covariance of x.
If the values of x change shape over time, this node will throw an exception during evaluation.
cov(x::Node{<:AbstractVector}, window::Int; corrected::Bool=true) -> NodeCreate 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.
If the values of x change shape over time, this node will throw an exception during evaluation.
Statistics.cor — Functioncor(x, y[, alignment]; corrected::Bool=true) -> NodeCreate 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.
cor(x, y, window::Int[, alignment]; emit_early=false) -> Node
cor(x, y, window::TimePeriod[, alignment]; emit_early=false) -> NodeCreate 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.
TimeDag.ema — Functionema(x::Node, α::AbstractFloat) -> Node
ema(x::Node, w_eff::Integer) -> NodeCreate 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.