R/discreteMap_iter.R

Defines functions discreteMap_iter

Documented in discreteMap_iter

#' @title Time Series generation from a matrix
#' @description This function produces a time Series generated by a supplied matrix
#' @param N integer - number of iterations/Length of time series
#' @param x0 double - starting value
#' @param mat matrix of type double - The generating system
#' @param skipFirst boolean - Wether the resulting time series should contain the initial value x0 or not
#' @return the time series
#' @export
discreteMap_iter = function(N,x0,mat,skipFirst = TRUE){
  x0 = valToVec(val = x0,
                N = dim(mat)[2])
  if (skipFirst) x0 = mat %*% x0
  Series = matrix(data = rep(x0,N),
                  nrow = length(x0),
                  ncol = N,
                  byrow = FALSE)
  for (i in 2:N){
    Series[,i] = mat %*% Series[,i-1]
  }
  result = apply(X = Series,
                 MARGIN = 2,
                 FUN = function(colVec){
                   vecToVal(vec = colVec)
                 })
  return(result)
}
PhilippVWC/myBayes documentation built on Oct. 2, 2020, 8:25 a.m.