Debian Codegraph @

man/iterate.lin.recursion.Rd

raw
1 \name{iterate.lin.recursion}
2 \alias{iterate.lin.recursion}
3 \title{Generate Sequence Iterating a Linear Recursion}
4 \description{
5 Generate numeric sequences applying a linear recursion \code{nr.it} times.
6 }
7 \usage{
8 iterate.lin.recursion(x, coeff, delta = 0, nr.it)
9 }
10 \arguments{
11 \item{x}{numeric vector with \emph{initial values}, i.e., specifying
12 the beginning of the resulting sequence; must be of length (larger
13 or) equal to \code{length(coeff)}.}
14 \item{coeff}{coefficient vector of the linear recursion.}
15 \item{delta}{numeric scalar added to each term; defaults to 0. If not
16 zero, determines the linear drift component.}
17 \item{nr.it}{integer, number of iterations.}
18 }
19 \value{
20 numeric vector, say \code{r}, of length \code{n + nr.it}, where
21 \code{n = length(x)}. Initialized as \code{r[1:n] = x}, the recursion
22 is \code{r[k+1] = sum(coeff * r[(k-m+1):k])}, where \code{m = length(coeff)}.
23 }
24 \note{
25 Depending on the zeroes of the characteristic polynomial of \code{coeff},
26 there are three cases, of convergence, oszillation and divergence.
27 }
28 \author{Martin Maechler}
29 \seealso{\code{\link{seq}} can be regarded as a trivial special case.}
30 \examples{
31 ## The Fibonacci sequence:
32 iterate.lin.recursion(0:1, c(1,1), nr = 12)
33 ## 0 1 1 2 3 5 8 13 21 34 55 89 144 233
34
35 ## seq() as a special case:
36 stopifnot(iterate.lin.recursion(4,1, d=2, nr=20)
37 == seq(4, by=2, length=1+20))
38
39 ## ''Deterministic AR(2)'' :
40 round(iterate.lin.recursion(1:4, c(-0.7, 0.9), d = 2, nr=15), dig=3)
41 ## slowly decaying :
42 plot(ts(iterate.lin.recursion(1:4, c(-0.9, 0.95), nr=150)))
43 }
44 \keyword{arith}