R/calcTau.R

Defines functions calcTau

Documented in calcTau

#' Calculate Mixture Variance
#' 
#' @param alpha Significance level
#' @param sigma Population standard deviation
#' @param truncation Desired truncation time for mSPRT
#' @return tau Optimal mixture variance \eqn{\tau} for mSPRT.
#' @references Johari, R., Koomen, P., Pekelis, L. & Walsh, D. 2017, "Peeking at A/B Tests: Why it matters, and what to do about it", ACM, , pp. 1517
#' @section Details:
#' Mixture variance \deqn{\tau^2 =  \sigma^2 \frac{\Phi(-b)}{\frac{1}{b}\phi(b)-\Phi(-b)}.}
#' @export
calcTau <- function(alpha, sigma, truncation) {
  is.numeric(alpha) & alpha > 0 & alpha < 1 || stop("Alpha must be between 0 and 1")
  b <- (2*log(alpha^(-1)))/(truncation*sigma^2)^(1/2)
  return(round(sigma^2 *( stats::pnorm(-b) / ((1/b)*stats::dnorm(b) - stats::pnorm(-b)) ),2))
}
shitoushan/mixtureSPRT documentation built on Sept. 29, 2021, 7:46 a.m.