Find the node of a sequence in a context tree
Source:R/ctx_node.R
, R/ctx_node_cpp.R
find_sequence.Rd
This function checks whether the sequence ctx
is represented in the context
tree ct
. If this is the case, it returns a description of matching node, an
object of class ctx_node
. If the sequence is not represented in the tree,
the function return NULL
.
Usage
find_sequence(ct, ctx, reverse = FALSE, ...)
# S3 method for ctx_tree
find_sequence(ct, ctx, reverse = FALSE, ...)
# S3 method for ctx_tree_cpp
find_sequence(ct, ctx, reverse = FALSE, ...)
Arguments
- ct
a context tree.
- ctx
a sequence to search in the context tree
- reverse
specifies whether the sequence
ctx
is given the temporal order (FALSE
, default value) or in the reverse temporal order (TRUE
). See the dedicated section.- ...
additional parameters for the find_sequence function
Value
an object of class ctx_node
if the sequence ctx
is represented
in the context tree, NULL
when this is not the case.
Details
The function looks for sequences in general. The is_context()
function can
be used on the resulting object to test if the sequence is in addition a
proper context.
State order in a sequence
sequence are given by default
in the temporal order and not in the "reverse" order used by many VLMC
research papers: older values are on the left. For instance, the context
c(1, 0)
is reported if the sequence 0, then 1 appeared in the time series
used to build the context tree. In the present function, reverse
refers
both to the order used for the ctx
parameter and for the default order used by the resulting ctx_node
object.