R/rtanb.R

#' Generates random deviates from a Tangent Burr Type XII probability distribution.
#' @export
#' @importFrom fdrtool rhalfnorm
#' @importFrom fdrtool dhalfnorm
#'
#' @param n Number of observations to be generated.
#' @param c C parameter.
#' @param k K parameter.
#' @param s S parameter.
#' @return A vector with n observations of the Tangent Burr Type XII distribution.
#' @examples
#' rtanb(1,3,2,2)
#' rtanb(1,0.3,0.1,0.8)
#' @family Basic functions for the Tangent-Burr Type XII distribution

rtanb <- function(n, c, k, s) {
    accept = c()
    count = 0
    
    while (length(accept) < n) {
        
        U <- rhalfnorm(1)
        x <- rhalfnorm(1)
        
        if (U <= dtanb(x, c, k, s)/(sqrt(pi) * dhalfnorm(x)/sqrt(2))) {
            accept[count] = x
            count = count + 1
        }
    }
    return(accept)
}
TrigonometricDistribution/TanB documentation built on May 9, 2019, 5:14 p.m.