discretize_cpp: discretize a real value

Description Usage Arguments Details Value Author(s) Examples

View source: R/RcppExports.R

Description

this routine discretizes a value corresponding to the desired method

Usage

1
discretize_cpp(val, N_discr, domain, method)

Arguments

val

double - real value to be discretized

N_discr

integer - desired discretization

domain

vector of double - vector with two components containing the domain bounds

method

integer - discretize with 1...round routine, or 2...custom method

Details

This routine is implemented in C++

Value

double - discretized value

Author(s)

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
//C++ DEFINITION
double discretize_cpp(double val,  int N_discr, Rcpp::NumericVector domain, int method){
  double lower = domain[0];
  double upper = domain[1];
  if(method == 1){
    N_discr--;
    return(round(val*N_discr)/N_discr);
  }else{
    return(vecToVal_cpp(valToVec_cpp(val,N_discr,domain),domain));
  }
}

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