gsm_iter_cpp: Time series creation

Description Usage Arguments Details Value Author(s) Examples

View source: R/RcppExports.R

Description

Create time series produced by general symmetric map

Usage

1
gsm_iter_cpp(N, x0, r, alpha, N_discr, skipFirst, method)

Arguments

N

integer - Number of iterations

x0

double - starting value

r

double - controll parameter

alpha

double - exponent of general symmetric map

N_discr

integer - controlls discretization of state space (zero corresponds to continuous case)

skipFirst

Boolean - If set to FALSE, the resulting time series contains the initial value x0

method

integer - method of discretization with 1... round routine from base package (fast) or 2... matrix multiplication (slow)

Details

This routine is implemented in C++

Value

vector of type double - the resulting time series

Author(s)

J.C. Lemm, P. v.W. Crommelin

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//C++ DEFINITION
Rcpp::NumericVector gsm_iter_cpp(int N, double x0, double r, double alpha, int N_discr,bool skipFirst, int method){
  if(method==1){
    if(N_discr>0){
      N_discr--; //Decrement because the rounding routine maps to N_discr + 1 values
    }
    Rcpp::NumericVector X(N);
    if(skipFirst){
      if(N_discr == 0){
        X[0] = gsm_cpp(x0,r,alpha);
      }else{
        X[0] = round(gsm_cpp(x0,r,alpha)*N_discr)/N_discr;
      }
    }else{
      X[0] = x0;
    }
    if(N>1){
      if(N_discr == 0){
        for(int i=1; i<N ; i++){
          X[i] = gsm_cpp(X[i-1],r,alpha);
        }
      }else{
        for(int i=1; i<N ; i++){
          X[i] = round(gsm_cpp(X[i-1],r,alpha)*N_discr)/N_discr;
        }
      }
    }
    return(X);
  }else{
    return(Dgsm_iter_cpp(N,x0,r,alpha,N_discr,skipFirst));
  }
}

PhilippVWC/myBayes documentation built on Oct. 2, 2020, 8:25 a.m.