R/TF_approx.R

Defines functions dappro2 appro2 adjust_acceptance

# function for adjust the acceptance rate
#' @export
adjust_acceptance=function(accept,sgm,target = 0.5){
  y = 1. + 1000.*(accept-target)*(accept-target)*(accept-target)
  if (y < .9)
    y = .9
  if (y > 1.1)
    y = 1.1
  sgm = sgm* y
  return(sgm)
}

# approximate the threhold function
#' @export
appro2 = function(x, epison = 10^-8) {
  temp = 0.5*(1+2/pi*atan(x/epison))
  return(temp)
}

# appraoximate the derivative of the threshold function
#' @export
dappro2 = function(x, epison = 10^-8) {
  temp = 2/(pi*(epison+x^2/epison))
  return(temp)
}
y1zhong/TGLG documentation built on July 18, 2021, 3:52 p.m.