R/exp_acc.R

Defines functions exp_acc_opt

Documented in exp_acc_opt

#' Acceptance rate of translated-exponential rejection sampling
#'
#' \code{exp_acc_opt} calculates the acceptance rate of translated-exponential rejection sampling for the truncation interval (a,b).
#'
#' @param a lower bound for truncation.
#' @param b upper bound for truncation.
#'
#' @examples
#' set.seed(1203)
#' exp_acc_opt(1,2)
#'
exp_acc_opt <- function(a,b){
  lambda <- ( a+sqrt(a^2+4) )/2
  rate <- sqrt(2*pi)*(pnorm(b)-pnorm(a))*lambda*exp(-lambda^2/2+lambda*a)
  return(rate)
}

Try the tmvmixnorm package in your browser

Any scripts or data that you put into this service are public.

tmvmixnorm documentation built on Sept. 19, 2020, 1:07 a.m.