extraDistr/0000755000176200001440000000000014532054172012406 5ustar liggesusersextraDistr/NAMESPACE0000755000176200001440000000642714475546572013661 0ustar liggesusers# Generated by roxygen2: do not edit by hand export(dbbinom) export(dbern) export(dbetapr) export(dbhatt) export(dbnbinom) export(dbvnorm) export(dbvpois) export(dcat) export(ddgamma) export(ddirichlet) export(ddirmnom) export(ddlaplace) export(ddnorm) export(ddunif) export(ddweibull) export(dfatigue) export(dfrechet) export(dgev) export(dgompertz) export(dgpd) export(dgpois) export(dgumbel) export(dhcauchy) export(dhnorm) export(dht) export(dhuber) export(dinvchisq) export(dinvgamma) export(dkumar) export(dlaplace) export(dlgser) export(dlomax) export(dlst) export(dmixnorm) export(dmixpois) export(dmnom) export(dmvhyper) export(dnhyper) export(dnsbeta) export(dpareto) export(dpower) export(dprop) export(drayleigh) export(dsgomp) export(dskellam) export(dslash) export(dtbinom) export(dtnorm) export(dtpois) export(dtriang) export(dwald) export(dzib) export(dzinb) export(dzip) export(pbbinom) export(pbern) export(pbetapr) export(pbhatt) export(pbnbinom) export(pcat) export(pdgamma) export(pdlaplace) export(pdnorm) export(pdunif) export(pdweibull) export(pfatigue) export(pfrechet) export(pgev) export(pgompertz) export(pgpd) export(pgpois) export(pgumbel) export(phcauchy) export(phnorm) export(pht) export(phuber) export(pinvchisq) export(pinvgamma) export(pkumar) export(plaplace) export(plgser) export(plomax) export(plst) export(pmixnorm) export(pmixpois) export(pnhyper) export(pnsbeta) export(ppareto) export(ppower) export(pprop) export(prayleigh) export(psgomp) export(pslash) export(ptbinom) export(ptnorm) export(ptpois) export(ptriang) export(pwald) export(pzib) export(pzinb) export(pzip) export(qbern) export(qbetapr) export(qcat) export(qdunif) export(qdweibull) export(qfatigue) export(qfrechet) export(qgev) export(qgompertz) export(qgpd) export(qgumbel) export(qhcauchy) export(qhnorm) export(qht) export(qhuber) export(qinvchisq) export(qinvgamma) export(qkumar) export(qlaplace) export(qlgser) export(qlomax) export(qlst) export(qnhyper) export(qnsbeta) export(qpareto) export(qpower) export(qprop) export(qrayleigh) export(qtbinom) export(qtlambda) export(qtnorm) export(qtpois) export(qtriang) export(qzib) export(qzinb) export(qzip) export(rbbinom) export(rbern) export(rbetapr) export(rbhatt) export(rbnbinom) export(rbvnorm) export(rbvpois) export(rcat) export(rcatlp) export(rdgamma) export(rdirichlet) export(rdirmnom) export(rdlaplace) export(rdnorm) export(rdunif) export(rdweibull) export(rfatigue) export(rfrechet) export(rgev) export(rgompertz) export(rgpd) export(rgpois) export(rgumbel) export(rhcauchy) export(rhnorm) export(rht) export(rhuber) export(rinvchisq) export(rinvgamma) export(rkumar) export(rlaplace) export(rlgser) export(rlomax) export(rlst) export(rmixnorm) export(rmixpois) export(rmnom) export(rmvhyper) export(rnhyper) export(rnsbeta) export(rpareto) export(rpower) export(rprop) export(rrayleigh) export(rsgomp) export(rsign) export(rskellam) export(rslash) export(rtbinom) export(rtlambda) export(rtnorm) export(rtpois) export(rtriang) export(rwald) export(rzib) export(rzinb) export(rzip) importFrom(Rcpp,sourceCpp) importFrom(stats,pgamma) importFrom(stats,pnorm) importFrom(stats,qchisq) importFrom(stats,qgamma) importFrom(stats,qnorm) importFrom(stats,rchisq) importFrom(stats,rgamma) importFrom(stats,rnorm) importFrom(stats,rpois) useDynLib(extraDistr, .registration = TRUE) extraDistr/man/0000755000176200001440000000000014532041732013157 5ustar liggesusersextraDistr/man/MultiHypergeometric.Rd0000644000176200001440000000323514532041732017452 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/multivariate-hypergeometric-distribution.R \name{MultiHypergeometric} \alias{MultiHypergeometric} \alias{dmvhyper} \alias{rmvhyper} \title{Multivariate hypergeometric distribution} \usage{ dmvhyper(x, n, k, log = FALSE) rmvhyper(nn, n, k) } \arguments{ \item{x}{\eqn{m}-column matrix of quantiles.} \item{n}{\eqn{m}-length vector or \eqn{m}-column matrix of numbers of balls in \eqn{m} colors.} \item{k}{the number of balls drawn from the urn.} \item{log}{logical; if TRUE, probabilities p are given as log(p).} \item{nn}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function and random generation for the multivariate hypergeometric distribution. } \details{ Probability mass function \deqn{ f(x) = \frac{\prod_{i=1}^m {n_i \choose x_i}}{{N \choose k}} }{ f(x) = prod(choose(n, x)) / choose(N, k) } The multivariate hypergeometric distribution is generalization of hypergeometric distribution. It is used for sampling \emph{without} replacement \eqn{k} out of \eqn{N} marbles in \eqn{m} colors, where each of the colors appears \eqn{n_i}{n[i]} times. Where \eqn{k=\sum_{i=1}^m x_i}{k=sum(x)}, \eqn{N=\sum_{i=1}^m n_i}{N=sum(n)} and \eqn{k \le N}{k<=N}. } \examples{ # Generating 10 random draws from multivariate hypergeometric # distribution parametrized using a vector rmvhyper(10, c(10, 12, 5, 8, 11), 33) } \references{ Gentle, J.E. (2006). Random number generation and Monte Carlo methods. Springer. } \seealso{ \code{\link[stats]{Hypergeometric}} } \concept{Discrete} \concept{Multivariate} \keyword{distribution} extraDistr/man/BetaPrime.Rd0000644000176200001440000000376314532041731015326 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/beta-prime-distribution.R \name{BetaPrime} \alias{BetaPrime} \alias{dbetapr} \alias{pbetapr} \alias{qbetapr} \alias{rbetapr} \title{Beta prime distribution} \usage{ dbetapr(x, shape1, shape2, scale = 1, log = FALSE) pbetapr(q, shape1, shape2, scale = 1, lower.tail = TRUE, log.p = FALSE) qbetapr(p, shape1, shape2, scale = 1, lower.tail = TRUE, log.p = FALSE) rbetapr(n, shape1, shape2, scale = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{shape1, shape2}{non-negative parameters.} \item{scale}{positive valued scale parameter.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the beta prime distribution. } \details{ If \eqn{X \sim \mathrm{Beta}(\alpha, \beta)}{X ~ Beta(\alpha, \beta)}, then \eqn{\frac{X}{1-X} \sim \mathrm{BetaPrime}(\alpha, \beta)}{X/(1-X) ~ BetaPrime(\alpha, \beta)}. Probability density function \deqn{ f(x) = \frac{(x/\sigma)^{\alpha-1} (1+x/\sigma)^{-\alpha -\beta}}{\mathrm{B}(\alpha,\beta)\sigma} }{ f(x) = ((x/\sigma)^(\alpha-1) * (1 + x/\sigma)^(-\alpha-\beta)) / (B(\alpha,\beta) * \sigma) } Cumulative distribution function \deqn{ F(x) = I_{\frac{x/\sigma}{1+x/\sigma}}(\alpha, \beta) }{ F(x) = pbeta((x/\sigma)/(1+(x/\sigma)), \alpha, \beta) } } \examples{ x <- rbetapr(1e5, 5, 3, 2) hist(x, 350, freq = FALSE, xlim = c(0, 100)) curve(dbetapr(x, 5, 3, 2), 0, 100, col = "red", add = TRUE, n = 500) hist(pbetapr(x, 5, 3, 2)) plot(ecdf(x), xlim = c(0, 100)) curve(pbetapr(x, 5, 3, 2), 0, 100, col = "red", add = TRUE, n = 500) } \seealso{ \code{\link[stats]{Beta}} } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/Frechet.Rd0000644000176200001440000000402214532041732015024 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/frechet-distribution.R \name{Frechet} \alias{Frechet} \alias{dfrechet} \alias{pfrechet} \alias{qfrechet} \alias{rfrechet} \title{Frechet distribution} \usage{ dfrechet(x, lambda = 1, mu = 0, sigma = 1, log = FALSE) pfrechet(q, lambda = 1, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) qfrechet(p, lambda = 1, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) rfrechet(n, lambda = 1, mu = 0, sigma = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{lambda, sigma, mu}{shape, scale, and location parameters. Scale and shape must be positive.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the Frechet distribution. } \details{ Probability density function \deqn{ f(x) = \frac{\lambda}{\sigma} \left(\frac{x-\mu}{\sigma}\right)^{-1-\lambda} \exp\left(-\left(\frac{x-\mu}{\sigma}\right)^{-\lambda}\right) }{ f(x) = \lambda/\sigma * ((x-\mu)/\sigma)^(-1-\lambda) * exp(-((x-\mu)/\sigma)^-\lambda) } Cumulative distribution function \deqn{ F(x) = \exp\left(-\left(\frac{x-\mu}{\sigma}\right)^{-\lambda}\right) }{ F(x) = exp(-((x-\mu)/\sigma)^-\lambda) } Quantile function \deqn{ F^{-1}(p) = \mu + \sigma -\log(p)^{-1/\lambda} }{ F^-1(p) = \mu + \sigma * -log(p)^{-1/\lambda} } } \examples{ x <- rfrechet(1e5, 5, 2, 1.5) xx <- seq(0, 1000, by = 0.1) hist(x, 200, freq = FALSE) lines(xx, dfrechet(xx, 5, 2, 1.5), col = "red") hist(pfrechet(x, 5, 2, 1.5)) plot(ecdf(x)) lines(xx, pfrechet(xx, 5, 2, 1.5), col = "red", lwd = 2) } \references{ Bury, K. (1999). Statistical Distributions in Engineering. Cambridge University Press. } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/ZIP.Rd0000644000176200001440000000306214532041732014111 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/zero-inflated-poisson-distribution.R \name{ZIP} \alias{ZIP} \alias{dzip} \alias{pzip} \alias{qzip} \alias{rzip} \title{Zero-inflated Poisson distribution} \usage{ dzip(x, lambda, pi, log = FALSE) pzip(q, lambda, pi, lower.tail = TRUE, log.p = FALSE) qzip(p, lambda, pi, lower.tail = TRUE, log.p = FALSE) rzip(n, lambda, pi) } \arguments{ \item{x, q}{vector of quantiles.} \item{lambda}{vector of (non-negative) means.} \item{pi}{probability of extra zeros.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function and random generation for the zero-inflated Poisson distribution. } \details{ Probability density function \deqn{ f(x) = \left\{\begin{array}{ll} \pi + (1 - \pi) e^{-\lambda} & x = 0 \\ (1 - \pi) \frac{\lambda^{x} e^{-\lambda}} {x!} & x > 0 \\ \end{array}\right. }{ f(x) = [if x = 0:] \pi + (1-\pi) * exp(-\lambda) [else:] (1-\pi) * dpois(x, lambda) } } \examples{ x <- rzip(1e5, 6, 0.33) xx <- -2:20 plot(prop.table(table(x)), type = "h") lines(xx, dzip(xx, 6, 0.33), col = "red") xx <- seq(0, 20, by = 0.01) plot(ecdf(x)) lines(xx, pzip(xx, 6, 0.33), col = "red") } \seealso{ \code{\link[stats]{Poisson}} } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/Rademacher.Rd0000644000176200001440000000074114532041732015503 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rademacher-distribution.R \name{Rademacher} \alias{Rademacher} \alias{rsign} \title{Random generation from Rademacher distribution} \usage{ rsign(n) } \arguments{ \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Random generation for the Rademacher distribution (values -1 and +1 with equal probability). } \keyword{distribution} extraDistr/man/BirnbaumSaunders.Rd0000644000176200001440000000564614532041731016724 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/birnbaum-saunders-distribution.R \name{BirnbaumSaunders} \alias{BirnbaumSaunders} \alias{dfatigue} \alias{pfatigue} \alias{qfatigue} \alias{rfatigue} \title{Birnbaum-Saunders (fatigue life) distribution} \usage{ dfatigue(x, alpha, beta = 1, mu = 0, log = FALSE) pfatigue(q, alpha, beta = 1, mu = 0, lower.tail = TRUE, log.p = FALSE) qfatigue(p, alpha, beta = 1, mu = 0, lower.tail = TRUE, log.p = FALSE) rfatigue(n, alpha, beta = 1, mu = 0) } \arguments{ \item{x, q}{vector of quantiles.} \item{alpha, beta, mu}{shape, scale and location parameters. Scale and shape must be positive.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the Birnbaum-Saunders (fatigue life) distribution. } \details{ Probability density function \deqn{ f(x) = \left (\frac{\sqrt{\frac{x-\mu} {\beta}} + \sqrt{\frac{\beta} {x-\mu}}} {2\alpha (x-\mu)} \right) \phi \left( \frac{1}{\alpha}\left( \sqrt{\frac{x-\mu}{\beta}} - \sqrt{\frac{\beta}{x-\mu}} \right) \right) }{ f(x) = ((sqrt((x-\mu)/\beta) + sqrt(\beta/(x-\mu)))/(2*\alpha*(x-\mu))) * \phi((sqrt((x-\mu)/\beta) - sqrt(\beta/(x-\mu)))/\alpha) } Cumulative distribution function \deqn{ F(x) = \Phi \left(\frac{1}{\alpha}\left( \sqrt{\frac{x-\mu}{\beta}} - \sqrt{\frac{\beta}{x-\mu}} \right) \right) }{ F(x) = \Phi(((sqrt((x-\mu)/\beta) - sqrt(\beta/(x-\mu)))/\alpha) } Quantile function \deqn{ F^{-1}(p) = \left[\frac{\alpha}{2} \Phi^{-1}(p) + \sqrt{\left(\frac{\alpha}{2} \Phi^{-1}(p)\right)^{2} + 1}\right]^{2} \beta + \mu }{ F^-1(p) = (\alpha/2 * \Phi^-1(p) + sqrt((\alpha/2 * \Phi^-1(p))^2 + 1)^2 * \beta + \mu } } \examples{ x <- rfatigue(1e5, .5, 2, 5) hist(x, 100, freq = FALSE) curve(dfatigue(x, .5, 2, 5), 2, 20, col = "red", add = TRUE) hist(pfatigue(x, .5, 2, 5)) plot(ecdf(x)) curve(pfatigue(x, .5, 2, 5), 2, 20, col = "red", lwd = 2, add = TRUE) } \references{ Birnbaum, Z. W. and Saunders, S. C. (1969). A new family of life distributions. Journal of Applied Probability, 6(2), 637-652. Desmond, A. (1985) Stochastic models of failure in random environments. Canadian Journal of Statistics, 13, 171-183. Vilca-Labra, F., and Leiva-Sanchez, V. (2006). A new fatigue life model based on the family of skew-elliptical distributions. Communications in Statistics-Theory and Methods, 35(2), 229-244. Leiva, V., Sanhueza, A., Sen, P. K., and Paula, G. A. (2008). Random number generators for the generalized Birnbaum-Saunders distribution. Journal of Statistical Computation and Simulation, 78(11), 1105-1118. } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/TruncPoisson.Rd0000644000176200001440000000427014532041732016117 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/truncated-poisson-distributtion.R \name{TruncPoisson} \alias{TruncPoisson} \alias{dtpois} \alias{ptpois} \alias{qtpois} \alias{rtpois} \title{Truncated Poisson distribution} \usage{ dtpois(x, lambda, a = -Inf, b = Inf, log = FALSE) ptpois(q, lambda, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) qtpois(p, lambda, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) rtpois(n, lambda, a = -Inf, b = Inf) } \arguments{ \item{x, q}{vector of quantiles.} \item{lambda}{vector of (non-negative) means.} \item{a, b}{lower and upper truncation points (\code{a < x <= b}).} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the truncated Poisson distribution. } \examples{ x <- rtpois(1e5, 14, 16) xx <- seq(-1, 50) plot(prop.table(table(x))) lines(xx, dtpois(xx, 14, 16), col = "red") hist(ptpois(x, 14, 16)) xx <- seq(0, 50, by = 0.01) plot(ecdf(x)) lines(xx, ptpois(xx, 14, 16), col = "red", lwd = 2) uu <- seq(0, 1, by = 0.001) lines(qtpois(uu, 14, 16), uu, col = "blue", lty = 2) # Zero-truncated Poisson x <- rtpois(1e5, 5, 0) xx <- seq(-1, 50) plot(prop.table(table(x))) lines(xx, dtpois(xx, 5, 0), col = "red") hist(ptpois(x, 5, 0)) xx <- seq(0, 50, by = 0.01) plot(ecdf(x)) lines(xx, ptpois(xx, 5, 0), col = "red", lwd = 2) lines(qtpois(uu, 5, 0), uu, col = "blue", lty = 2) } \references{ Plackett, R.L. (1953). The truncated Poisson distribution. Biometrics, 9(4), 485-488. Singh, J. (1978). A characterization of positive Poisson distribution and its statistical application. SIAM Journal on Applied Mathematics, 34(3), 545-548. Dalgaard, P. (May 1, 2005). [R] simulate zero-truncated Poisson distribution. R-help mailing list. \url{https://stat.ethz.ch/pipermail/r-help/2005-May/070680.html} } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/Laplace.Rd0000644000176200001440000000441514532041732015013 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/laplace-distribution.R \name{Laplace} \alias{Laplace} \alias{dlaplace} \alias{plaplace} \alias{qlaplace} \alias{rlaplace} \title{Laplace distribution} \usage{ dlaplace(x, mu = 0, sigma = 1, log = FALSE) plaplace(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) qlaplace(p, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) rlaplace(n, mu = 0, sigma = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{mu, sigma}{location and scale parameters. Scale must be positive.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the Laplace distribution. } \details{ Probability density function \deqn{ f(x) = \frac{1}{2\sigma} \exp\left(-\left|\frac{x-\mu}{\sigma}\right|\right) }{ f(x) = 1/(2*\sigma) * exp(-|(x-\mu)/\sigma|) } Cumulative distribution function \deqn{ F(x) = \left\{\begin{array}{ll} \frac{1}{2} \exp\left(\frac{x-\mu}{\sigma}\right) & x < \mu \\ 1 - \frac{1}{2} \exp\left(\frac{x-\mu}{\sigma}\right) & x \geq \mu \end{array}\right. }{ F(x) = [if x < mu:] 1/2 * exp((x-\mu)/\sigma) [else:] 1 - 1/2 * exp((x-\mu)/\sigma) } Quantile function \deqn{ F^{-1}(p) = \left\{\begin{array}{ll} \mu + \sigma \log(2p) & p < 0.5 \\ \mu - \sigma \log(2(1-p)) & p \geq 0.5 \end{array}\right. }{ F^-1(p) = [if p < 0.5:] \mu + \sigma * log(2*p) [else:] \mu - \sigma * log(2*(1-p)) } } \examples{ x <- rlaplace(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dlaplace(x, 5, 16), -200, 200, n = 500, col = "red", add = TRUE) hist(plaplace(x, 5, 16)) plot(ecdf(x)) curve(plaplace(x, 5, 16), -200, 200, n = 500, col = "red", lwd = 2, add = TRUE) } \references{ Krishnamoorthy, K. (2006). Handbook of Statistical Distributions with Applications. Chapman & Hall/CRC Forbes, C., Evans, M. Hastings, N., & Peacock, B. (2011). Statistical Distributions. John Wiley & Sons. } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/Gompertz.Rd0000644000176200001440000000360714532041732015263 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/gompertz-distribution.R \name{Gompertz} \alias{Gompertz} \alias{dgompertz} \alias{pgompertz} \alias{qgompertz} \alias{rgompertz} \title{Gompertz distribution} \usage{ dgompertz(x, a = 1, b = 1, log = FALSE) pgompertz(q, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) qgompertz(p, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) rgompertz(n, a = 1, b = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{a, b}{positive valued scale and location parameters.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the Gompertz distribution. } \details{ Probability density function \deqn{ f(x) = a \exp\left(bx - \frac{a}{b} (\exp(bx)-1)\right) }{ f(x) = a*exp(b*x - a/b * (exp(b*x)-1)) } Cumulative distribution function \deqn{ F(x) = 1-\exp\left(-\frac{a}{b} (\exp(bx)-1)\right) }{ F(x) = 1-exp(-a/b * (exp(b*x)-1)) } Quantile function \deqn{ F^{-1}(p) = \frac{1}{b} \log\left(1-\frac{b}{a}\log(1-p)\right) }{ F^-1(p) = 1/b * log(1 - b/a * log(1-p)) } } \examples{ x <- rgompertz(1e5, 5, 2) hist(x, 100, freq = FALSE) curve(dgompertz(x, 5, 2), 0, 1, col = "red", add = TRUE) hist(pgompertz(x, 5, 2)) plot(ecdf(x)) curve(pgompertz(x, 5, 2), 0, 1, col = "red", lwd = 2, add = TRUE) } \references{ Lenart, A. (2012). The Gompertz distribution and Maximum Likelihood Estimation of its parameters - a revision. MPIDR WORKING PAPER WP 2012-008. \url{https://www.demogr.mpg.de/papers/working/wp-2012-008.pdf} } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/InvChiSq.Rd0000644000176200001440000000431414532041732015134 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/inverse-chi-squared-distribution.R \name{InvChiSq} \alias{InvChiSq} \alias{dinvchisq} \alias{pinvchisq} \alias{qinvchisq} \alias{rinvchisq} \title{Inverse chi-squared and scaled chi-squared distributions} \usage{ dinvchisq(x, nu, tau, log = FALSE) pinvchisq(q, nu, tau, lower.tail = TRUE, log.p = FALSE) qinvchisq(p, nu, tau, lower.tail = TRUE, log.p = FALSE) rinvchisq(n, nu, tau) } \arguments{ \item{x, q}{vector of quantiles.} \item{nu}{positive valued shape parameter.} \item{tau}{positive valued scaling parameter; if provided it returns values for scaled chi-squared distributions.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function and random generation for the inverse chi-squared distribution and scaled chi-squared distribution. } \details{ If \eqn{X} follows \eqn{\chi^2 (\nu)} distribution, then \eqn{1/X} follows inverse chi-squared distribution parametrized by \eqn{\nu}. Inverse chi-squared distribution is a special case of inverse gamma distribution with parameters \eqn{\alpha=\frac{\nu}{2}}{\alpha=\nu/2} and \eqn{\beta=\frac{1}{2}}{\beta=1/2}; or \eqn{\alpha=\frac{\nu}{2}}{\alpha=\nu/2} and \eqn{\beta=\frac{\nu\tau^2}{2}}{\beta=(\nu\tau^2)/2} for scaled inverse chi-squared distribution. } \examples{ x <- rinvchisq(1e5, 20) hist(x, 100, freq = FALSE) curve(dinvchisq(x, 20), 0, 1, n = 501, col = "red", add = TRUE) hist(pinvchisq(x, 20)) plot(ecdf(x)) curve(pinvchisq(x, 20), 0, 1, n = 501, col = "red", lwd = 2, add = TRUE) # scaled x <- rinvchisq(1e5, 10, 5) hist(x, 100, freq = FALSE) curve(dinvchisq(x, 10, 5), 0, 150, n = 501, col = "red", add = TRUE) hist(pinvchisq(x, 10, 5)) plot(ecdf(x)) curve(pinvchisq(x, 10, 5), 0, 150, n = 501, col = "red", lwd = 2, add = TRUE) } \seealso{ \code{\link[stats]{Chisquare}}, \code{\link[stats]{GammaDist}} } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/GammaPoiss.Rd0000644000176200001440000000602414532041732015510 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/gamma-poisson-distribution.R \name{GammaPoiss} \alias{GammaPoiss} \alias{dgpois} \alias{pgpois} \alias{rgpois} \title{Gamma-Poisson distribution} \usage{ dgpois(x, shape, rate, scale = 1/rate, log = FALSE) pgpois(q, shape, rate, scale = 1/rate, lower.tail = TRUE, log.p = FALSE) rgpois(n, shape, rate, scale = 1/rate) } \arguments{ \item{x, q}{vector of quantiles.} \item{shape, scale}{shape and scale parameters. Must be positive, scale strictly.} \item{rate}{an alternative way to specify the scale.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function and random generation for the gamma-Poisson distribution. } \details{ Gamma-Poisson distribution arises as a continuous mixture of Poisson distributions, where the mixing distribution of the Poisson rate \eqn{\lambda} is a gamma distribution. When \eqn{X \sim \mathrm{Poisson}(\lambda)}{X ~ Poisson(\lambda)} and \eqn{\lambda \sim \mathrm{Gamma}(\alpha, \beta)}{\lambda ~ Gamma(\alpha, \beta)}, then \eqn{X \sim \mathrm{GammaPoisson}(\alpha, \beta)}{X ~ Gamma-Poisson(\alpha, \beta)}. Probability mass function \deqn{ f(x) = \frac{\Gamma(\alpha+x)}{x! \, \Gamma(\alpha)} \left(\frac{\beta}{1+\beta}\right)^x \left(1-\frac{\beta}{1+\beta}\right)^\alpha }{ f(x) = \Gamma(\alpha+x) / (x!*\Gamma(\alpha)) * (\beta/(1+\beta))^x * (1-\beta/(1+\beta))^\alpha } Cumulative distribution function is calculated using recursive algorithm that employs the fact that \eqn{\Gamma(x) = (x - 1)!}. This enables re-writing probability mass function as \deqn{ f(x) = \frac{(\alpha+x-1)!}{x! \, \Gamma(\alpha)} \left( \frac{\beta}{1+\beta} \right)^x \left( 1- \frac{\beta}{1+\beta} \right)^\alpha }{ f(x) = ((\alpha+x-1)!)/(x!*\Gamma(\alpha))*(\beta/(1+\beta))^x*(1-\beta/(1+\beta))^\alpha } what makes recursive updating from \eqn{x} to \eqn{x+1} easy using the properties of factorials \deqn{ f(x+1) = \frac{(\alpha+x-1)! \, (\alpha+x)}{x! \,(x+1) \, \Gamma(\alpha)} \left( \frac{\beta}{1+\beta} \right)^x \left( \frac{\beta}{1+\beta} \right) \left( 1- \frac{\beta}{1+\beta} \right)^\alpha }{ f(x+1) = ((\alpha+x-1)!*(\alpha+x))/(x!*(x+1)*\Gamma(\alpha))*(\beta/(1+\beta))^x*(\beta/(1+\beta))*(1-\beta/(1+\beta))^\alpha } and let's us efficiently calculate cumulative distribution function as a sum of probability mass functions \deqn{F(x) = \sum_{k=0}^x f(k)}{F(x) = f(0)+...+f(x)} } \examples{ x <- rgpois(1e5, 7, 0.002) xx <- seq(0, 12000, by = 1) hist(x, 100, freq = FALSE) lines(xx, dgpois(xx, 7, 0.002), col = "red") hist(pgpois(x, 7, 0.002)) xx <- seq(0, 12000, by = 0.1) plot(ecdf(x)) lines(xx, pgpois(xx, 7, 0.002), col = "red", lwd = 2) } \seealso{ \code{\link[stats]{Gamma}}, \code{\link[stats]{Poisson}} } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/DirMnom.Rd0000644000176200001440000000373014532041731015015 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dirichlet-multinomial-distribution.R \name{DirMnom} \alias{DirMnom} \alias{ddirmnom} \alias{rdirmnom} \title{Dirichlet-multinomial (multivariate Polya) distribution} \usage{ ddirmnom(x, size, alpha, log = FALSE) rdirmnom(n, size, alpha) } \arguments{ \item{x}{\eqn{k}-column matrix of quantiles.} \item{size}{numeric vector; number of trials (zero or more).} \item{alpha}{\eqn{k}-values vector or \eqn{k}-column matrix; concentration parameter. Must be positive.} \item{log}{logical; if TRUE, probabilities p are given as log(p).} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density function, cumulative distribution function and random generation for the Dirichlet-multinomial (multivariate Polya) distribution. } \details{ If \eqn{(p_1,\dots,p_k) \sim \mathrm{Dirichlet}(\alpha_1,\dots,\alpha_k)}{(p[1],\dots,p[k]) ~ Dirichlet(\alpha[1],\dots,\alpha[k])} and \eqn{(x_1,\dots,x_k) \sim \mathrm{Multinomial}(n, p_1,\dots,p_k)}{(x[1],\dots,x[k]) ~ Multinomial(n, p[1],\dots,p[k])}, then \eqn{(x_1,\dots,x_k) \sim \mathrm{DirichletMultinomial(n, \alpha_1,\dots,\alpha_k)}}{(x[1],\dots,x[k]) ~ DirichletMultinomial(n, \alpha[1],\dots,\alpha[k])}. Probability density function \deqn{ f(x) = \frac{\left(n!\right)\Gamma\left(\sum \alpha_k\right)}{\Gamma\left(n+\sum \alpha_k\right)}\prod_{k=1}^K\frac{\Gamma(x_{k}+\alpha_{k})}{\left(x_{k}!\right)\Gamma(\alpha_{k})} }{ f(x) = (n! * \Gamma(sum(\alpha[k]))) / (\Gamma(n + sum(\alpha[k]))) * prod((\Gamma(x[k] + \alpha[k])) / (x[k]! * \Gamma(\alpha[k])) } } \references{ Gentle, J.E. (2006). Random number generation and Monte Carlo methods. Springer. Kvam, P. and Day, D. (2001) The multivariate Polya distribution in combat modeling. Naval Research Logistics, 48, 1-17. } \seealso{ \code{\link{Dirichlet}}, \code{\link{Multinomial}} } \concept{Discrete} \concept{Multivariate} \keyword{distribution} extraDistr/man/HalfCauchy.Rd0000644000176200001440000000357714532041732015471 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/half-cauchy-distribution.R \name{HalfCauchy} \alias{HalfCauchy} \alias{dhcauchy} \alias{phcauchy} \alias{qhcauchy} \alias{rhcauchy} \title{Half-Cauchy distribution} \usage{ dhcauchy(x, sigma = 1, log = FALSE) phcauchy(q, sigma = 1, lower.tail = TRUE, log.p = FALSE) qhcauchy(p, sigma = 1, lower.tail = TRUE, log.p = FALSE) rhcauchy(n, sigma = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{sigma}{positive valued scale parameter.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the half-Cauchy distribution. } \details{ If \eqn{X} follows Cauchy centered at 0 and parametrized by scale \eqn{\sigma}, then \eqn{|X|} follows half-Cauchy distribution parametrized by scale \eqn{\sigma}. Half-Cauchy distribution is a special case of half-t distribution with \eqn{\nu=1} degrees of freedom. } \examples{ x <- rhcauchy(1e5, 2) hist(x, 2e5, freq = FALSE, xlim = c(0, 100)) curve(dhcauchy(x, 2), 0, 100, col = "red", add = TRUE) hist(phcauchy(x, 2)) plot(ecdf(x), xlim = c(0, 100)) curve(phcauchy(x, 2), col = "red", lwd = 2, add = TRUE) } \references{ Gelman, A. (2006). Prior distributions for variance parameters in hierarchical models (comment on article by Browne and Draper). Bayesian analysis, 1(3), 515-534. Jacob, E. and Jayakumar, K. (2012). On Half-Cauchy Distribution and Process. International Journal of Statistika and Mathematika, 3(2), 77-81. } \seealso{ \code{\link{HalfT}} } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/GEV.Rd0000644000176200001440000000574014532041732014075 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/gev-distribution.R \name{GEV} \alias{GEV} \alias{dgev} \alias{pgev} \alias{qgev} \alias{rgev} \title{Generalized extreme value distribution} \usage{ dgev(x, mu = 0, sigma = 1, xi = 0, log = FALSE) pgev(q, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) qgev(p, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) rgev(n, mu = 0, sigma = 1, xi = 0) } \arguments{ \item{x, q}{vector of quantiles.} \item{mu, sigma, xi}{location, scale, and shape parameters. Scale must be positive.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the generalized extreme value distribution. } \details{ Probability density function \deqn{ f(x) = \left\{\begin{array}{ll} \frac{1}{\sigma} \left(1+\xi \frac{x-\mu}{\sigma}\right)^{-1/\xi-1} \exp\left(-\left(1+\xi \frac{x-\mu}{\sigma}\right)^{-1/\xi}\right) & \xi \neq 0 \\ \frac{1}{\sigma} \exp\left(- \frac{x-\mu}{\sigma}\right) \exp\left(-\exp\left(- \frac{x-\mu}{\sigma}\right)\right) & \xi = 0 \end{array}\right. }{ f(x) = [if \xi != 0:] 1/\sigma * (1+\xi*(x-\mu)/\sigma)^{-1/\xi-1} * exp(-(1+\xi*(x-\mu)/\sigma)^{-1/\xi}) [else:] 1/\sigma * exp(-(x-\mu)/\sigma) * exp(-exp(-(x-\mu)/\sigma)) } Cumulative distribution function \deqn{ F(x) = \left\{\begin{array}{ll} \exp\left(-\left(1+\xi \frac{x-\mu}{\sigma}\right)^{1/\xi}\right) & \xi \neq 0 \\ \exp\left(-\exp\left(- \frac{x-\mu}{\sigma}\right)\right) & \xi = 0 \end{array}\right. }{ F(x) = [if \xi != 0:] exp(-(1+\xi*(x-\mu)/\sigma)^{1/\xi}) [else:] exp(-exp(-(x-\mu)/\sigma)) } Quantile function \deqn{ F^{-1}(p) = \left\{\begin{array}{ll} \mu - \frac{\sigma}{\xi} (1 - (-\log(p))^\xi) & \xi \neq 0 \\ \mu - \sigma \log(-\log(p)) & \xi = 0 \end{array}\right. }{ F^-1(p) = [if \xi != 0:] \mu - \sigma/\xi * (1 - (-log(p))^\xi) [else:] \mu - \sigma * log(-log(p)) } } \examples{ curve(dgev(x, xi = -1/2), -4, 4, col = "green", ylab = "") curve(dgev(x, xi = 0), -4, 4, col = "red", add = TRUE) curve(dgev(x, xi = 1/2), -4, 4, col = "blue", add = TRUE) legend("topleft", col = c("green", "red", "blue"), lty = 1, legend = expression(xi == -1/2, xi == 0, xi == 1/2), bty = "n") x <- rgev(1e5, 5, 2, .5) hist(x, 1000, freq = FALSE, xlim = c(0, 50)) curve(dgev(x, 5, 2, .5), 0, 50, col = "red", add = TRUE, n = 5000) hist(pgev(x, 5, 2, .5)) plot(ecdf(x), xlim = c(0, 50)) curve(pgev(x, 5, 2, .5), 0, 50, col = "red", lwd = 2, add = TRUE) } \references{ Coles, S. (2001). An Introduction to Statistical Modeling of Extreme Values. Springer. } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/PoissonMix.Rd0000644000176200001440000000354214532041732015562 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/mixture-of-poisson-distributions.R \name{PoissonMix} \alias{PoissonMix} \alias{dmixpois} \alias{pmixpois} \alias{rmixpois} \title{Mixture of Poisson distributions} \usage{ dmixpois(x, lambda, alpha, log = FALSE) pmixpois(q, lambda, alpha, lower.tail = TRUE, log.p = FALSE) rmixpois(n, lambda, alpha) } \arguments{ \item{x, q}{vector of quantiles.} \item{lambda}{matrix (or vector) of (non-negative) means.} \item{alpha}{matrix (or vector) of mixing proportions; mixing proportions need to sum up to 1.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} \item{p}{vector of probabilities.} } \description{ Density, distribution function and random generation for the mixture of Poisson distributions. } \details{ Probability density function \deqn{ f(x) = \alpha_1 f_1(x; \lambda_1) + \dots + \alpha_k f_k(x; \lambda_k) }{ f(x) = \alpha[1] * f1(x; \lambda[1]) + \dots + \alpha[k] * fk(x; \lambda[k]) } Cumulative distribution function \deqn{ F(x) = \alpha_1 F_1(x; \lambda_1) + \dots + \alpha_k F_k(x; \lambda_k) }{ F(x) = \alpha[1] * F1(x; \lambda[1]) + \dots + \alpha[k] * Fk(x; \lambda[k]) } where \eqn{\sum_i \alpha_i = 1}{sum(\alpha[i]) == 1}. } \examples{ x <- rmixpois(1e5, c(5, 12, 19), c(1/3, 1/3, 1/3)) xx <- seq(-1, 50) plot(prop.table(table(x))) lines(xx, dmixpois(xx, c(5, 12, 19), c(1/3, 1/3, 1/3)), col = "red") hist(pmixpois(x, c(5, 12, 19), c(1/3, 1/3, 1/3))) xx <- seq(0, 50, by = 0.01) plot(ecdf(x)) lines(xx, pmixpois(xx, c(5, 12, 19), c(1/3, 1/3, 1/3)), col = "red", lwd = 2) } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/extraDistr-package.Rd0000644000176200001440000000437314532041732017177 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/extraDistr-package.R \docType{package} \name{extraDistr-package} \alias{extraDistr} \alias{extraDistr-package} \title{extraDistr: Additional Univariate and Multivariate Distributions} \description{ Density, distribution function, quantile function and random generation for a number of univariate and multivariate distributions. This package implements the following distributions: Bernoulli, beta-binomial, beta-negative binomial, beta prime, Bhattacharjee, Birnbaum-Saunders, bivariate normal, bivariate Poisson, categorical, Dirichlet, Dirichlet-multinomial, discrete gamma, discrete Laplace, discrete normal, discrete uniform, discrete Weibull, Frechet, gamma-Poisson, generalized extreme value, Gompertz, generalized Pareto, Gumbel, half-Cauchy, half-normal, half-t, Huber density, inverse chi-squared, inverse-gamma, Kumaraswamy, Laplace, location-scale t, logarithmic, Lomax, multivariate hypergeometric, multinomial, negative hypergeometric, non-standard beta, normal mixture, Poisson mixture, Pareto, power, reparametrized beta, Rayleigh, shifted Gompertz, Skellam, slash, triangular, truncated binomial, truncated normal, truncated Poisson, Tukey lambda, Wald, zero-inflated binomial, zero-inflated negative binomial, zero-inflated Poisson. Density, distribution function, quantile function and random generation for a number of univariate and multivariate distributions. } \details{ This package follows naming convention that is consistent with base R, where density (or probability mass) functions, distribution functions, quantile functions and random generation functions names are followed by \code{d}*, \code{p}*, \code{q}*, and \code{r}* prefixes. Behaviour of the functions is consistent with base R, where for not valid parameters values \code{NaN}'s are returned, while for values beyond function support \code{0}'s are returned (e.g. for non-integers in discrete distributions, or for negative values in functions with non-negative support). All the functions vectorized and coded in C++ using \pkg{Rcpp}. } \seealso{ Useful links: \itemize{ \item \url{https://github.com/twolodzko/extraDistr} \item Report bugs at \url{https://github.com/twolodzko/extraDistr/issues} } } \keyword{internal} extraDistr/man/PropBeta.Rd0000644000176200001440000000711014532041732015161 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/proportion-distribution.R \name{PropBeta} \alias{PropBeta} \alias{dprop} \alias{pprop} \alias{qprop} \alias{rprop} \title{Beta distribution of proportions} \usage{ dprop(x, size, mean, prior = 0, log = FALSE) pprop(q, size, mean, prior = 0, lower.tail = TRUE, log.p = FALSE) qprop(p, size, mean, prior = 0, lower.tail = TRUE, log.p = FALSE) rprop(n, size, mean, prior = 0) } \arguments{ \item{x, q}{vector of quantiles.} \item{size}{non-negative real number; precision or number of binomial trials.} \item{mean}{mean proportion or probability of success on each trial; \code{0 < mean < 1}.} \item{prior}{(see below) with \code{prior = 0} (default) the distribution corresponds to re-parametrized beta distribution used in beta regression. This parameter needs to be non-negative.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function, distribution function and random generation for the reparametrized beta distribution. } \details{ Beta can be understood as a distribution of \eqn{x = k/\phi} proportions in \eqn{\phi} trials where the average proportion is denoted as \eqn{\mu}, so it's parameters become \eqn{\alpha = \phi\mu} and \eqn{\beta = \phi(1-\mu)} and it's density function becomes \deqn{ f(x) = \frac{x^{\phi\mu+\pi-1} (1-x)^{\phi(1-\mu)+\pi-1}}{\mathrm{B}(\phi\mu+\pi, \phi(1-\mu)+\pi)} }{ f(x) = (x^(\phi\mu+\pi-1) * (1-x)^(\phi(1-\mu)+\pi-1))/B(\phi\mu+\pi, \phi(1-\mu)+\pi) } where \eqn{\pi} is a \emph{prior} parameter, so the distribution is a \emph{posterior} distribution after observing \eqn{\phi\mu} successes and \eqn{\phi(1-\mu)} failures in \eqn{\phi} trials with binomial likelihood and symmetric \eqn{\mathrm{Beta}(\pi, \pi)}{Beta(\pi, \pi)} prior for probability of success. Parameter value \eqn{\pi = 1} corresponds to uniform prior; \eqn{\pi = 1/2} corresponds to Jeffreys prior; \eqn{\pi = 0} corresponds to "uninformative" Haldane prior, this is also the re-parametrized distribution used in beta regression. With \eqn{\pi = 0} the distribution can be understood as a continuous analog to binomial distribution dealing with proportions rather then counts. Alternatively \eqn{\phi} may be understood as precision parameter (as in beta regression). Notice that in pre-1.8.4 versions of this package, \code{prior} was not settable and by default fixed to one, instead of zero. To obtain the same results as in the previous versions, use \code{prior = 1} in each of the functions. } \examples{ x <- rprop(1e5, 100, 0.33) hist(x, 100, freq = FALSE) curve(dprop(x, 100, 0.33), 0, 1, col = "red", add = TRUE) hist(pprop(x, 100, 0.33)) plot(ecdf(x)) curve(pprop(x, 100, 0.33), 0, 1, col = "red", lwd = 2, add = TRUE) n <- 500 p <- 0.23 k <- rbinom(1e5, n, p) hist(k/n, freq = FALSE, 100) curve(dprop(x, n, p), 0, 1, col = "red", add = TRUE, n = 500) } \references{ Ferrari, S., & Cribari-Neto, F. (2004). Beta regression for modelling rates and proportions. Journal of Applied Statistics, 31(7), 799-815. Smithson, M., & Verkuilen, J. (2006). A better lemon squeezer? Maximum-likelihood regression with beta-distributed dependent variables. Psychological Methods, 11(1), 54-71. } \seealso{ \code{\link{beta}}, \code{\link{binomial}} } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/Bhattacharjee.Rd0000644000176200001440000000445314532041731016200 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/bhattacharjee-distribution.R \name{Bhattacharjee} \alias{Bhattacharjee} \alias{dbhatt} \alias{pbhatt} \alias{rbhatt} \title{Bhattacharjee distribution} \usage{ dbhatt(x, mu = 0, sigma = 1, a = sigma, log = FALSE) pbhatt(q, mu = 0, sigma = 1, a = sigma, lower.tail = TRUE, log.p = FALSE) rbhatt(n, mu = 0, sigma = 1, a = sigma) } \arguments{ \item{x, q}{vector of quantiles.} \item{mu, sigma, a}{location, scale and shape parameters. Scale and shape must be positive.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, and random generation for the Bhattacharjee distribution. } \details{ If \eqn{Z \sim \mathrm{Normal}(0, 1)}{Z ~ Normal(0, 1)} and \eqn{U \sim \mathrm{Uniform}(0, 1)}{U ~ Uniform(0, 1)}, then \eqn{Z+U} follows Bhattacharjee distribution. Probability density function \deqn{ f(z) = \frac{1}{2a} \left[\Phi\left(\frac{x-\mu+a}{\sigma}\right) - \Phi\left(\frac{x-\mu-a}{\sigma}\right)\right] }{ f(z) = 1/(2*a) * (\Phi((x-\mu+a)/\sigma) - \Phi((x-\mu+a)/\sigma)) } Cumulative distribution function \deqn{ F(z) = \frac{\sigma}{2a} \left[(x-\mu)\Phi\left(\frac{x-\mu+a}{\sigma}\right) - (x-\mu)\Phi\left(\frac{x-\mu-a}{\sigma}\right) + \phi\left(\frac{x-\mu+a}{\sigma}\right) - \phi\left(\frac{x-\mu-a}{\sigma}\right)\right] }{ F(z) = \sigma/(2*a) * ((x-\mu)*\Phi((x-\mu+a)/\sigma) - (x-\mu)*\Phi((x-\mu-a)/\sigma) + \phi((x-\mu+a)/\sigma) - \phi((x-\mu-a)/\sigma)) } } \examples{ x <- rbhatt(1e5, 5, 3, 5) hist(x, 100, freq = FALSE) curve(dbhatt(x, 5, 3, 5), -20, 20, col = "red", add = TRUE) hist(pbhatt(x, 5, 3, 5)) plot(ecdf(x)) curve(pbhatt(x, 5, 3, 5), -20, 20, col = "red", lwd = 2, add = TRUE) } \references{ Bhattacharjee, G.P., Pandit, S.N.N., and Mohan, R. (1963). Dimensional chains involving rectangular and normal error-distributions. Technometrics, 5, 404-406. } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/LogSeries.Rd0000644000176200001440000000370714532041732015351 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/logarithmic-series-distribution.R \name{LogSeries} \alias{LogSeries} \alias{dlgser} \alias{plgser} \alias{qlgser} \alias{rlgser} \title{Logarithmic series distribution} \usage{ dlgser(x, theta, log = FALSE) plgser(q, theta, lower.tail = TRUE, log.p = FALSE) qlgser(p, theta, lower.tail = TRUE, log.p = FALSE) rlgser(n, theta) } \arguments{ \item{x, q}{vector of quantiles.} \item{theta}{vector; concentration parameter; (\code{0 < theta < 1}).} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the logarithmic series distribution. } \details{ Probability mass function \deqn{ f(x) = \frac{-1}{\log(1-\theta)} \frac{\theta^x}{x} }{ f(x) = (-1/log(1-\theta)*\theta^x) / x } Cumulative distribution function \deqn{ F(x) = \frac{-1}{\log(1-\theta)} \sum_{k=1}^x \frac{\theta^x}{x} }{ F(x) = -1/log(1-\theta) * sum((\theta^x)/x) } Quantile function and random generation are computed using algorithm described in Krishnamoorthy (2006). } \examples{ x <- rlgser(1e5, 0.66) xx <- seq(0, 100, by = 1) plot(prop.table(table(x)), type = "h") lines(xx, dlgser(xx, 0.66), col = "red") # Notice: distribution of F(X) is far from uniform: hist(plgser(x, 0.66), 50) xx <- seq(0, 100, by = 0.01) plot(ecdf(x)) lines(xx, plgser(xx, 0.66), col = "red", lwd = 2) } \references{ Krishnamoorthy, K. (2006). Handbook of Statistical Distributions with Applications. Chapman & Hall/CRC Forbes, C., Evans, M. Hastings, N., & Peacock, B. (2011). Statistical Distributions. John Wiley & Sons. } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/TukeyLambda.Rd0000644000176200001440000000506114532041732015652 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/tukey-lambda-distribution.R \name{TukeyLambda} \alias{TukeyLambda} \alias{qtlambda} \alias{rtlambda} \title{Tukey lambda distribution} \usage{ qtlambda(p, lambda, lower.tail = TRUE, log.p = FALSE) rtlambda(n, lambda) } \arguments{ \item{p}{vector of probabilities.} \item{lambda}{shape parameter.} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Quantile function, and random generation for the Tukey lambda distribution. } \details{ Tukey lambda distribution is a continuous probability distribution defined in terms of its quantile function. It is typically used to identify other distributions. Quantile function: \deqn{F^{-1}(p) = \left\{\begin{array}{ll} \frac{1}{\lambda} [p^\lambda - (1-p)^\lambda] & \lambda \ne 0 \\ \log(\frac{p}{1-p}) & \lambda = 0 \end{array}\right. }{ F^-1(p) = [if \lambda != 0:] (p^\lambda - (1-p)^\lambda)/\lambda [if \lambda = 0:] log(p/(1-p)) } } \examples{ pp = seq(0, 1, by = 0.001) partmp <- par(mfrow = c(2,3)) plot(qtlambda(pp, -1), pp, type = "l", main = "lambda = -1 (Cauchy)") plot(qtlambda(pp, 0), pp, type = "l", main = "lambda = 0 (logistic)") plot(qtlambda(pp, 0.14), pp, type = "l", main = "lambda = 0.14 (normal)") plot(qtlambda(pp, 0.5), pp, type = "l", main = "lambda = 0.5 (concave)") plot(qtlambda(pp, 1), pp, type = "l", main = "lambda = 1 (uniform)") plot(qtlambda(pp, 2), pp, type = "l", main = "lambda = 2 (uniform)") hist(rtlambda(1e5, -1), freq = FALSE, main = "lambda = -1 (Cauchy)") hist(rtlambda(1e5, 0), freq = FALSE, main = "lambda = 0 (logistic)") hist(rtlambda(1e5, 0.14), freq = FALSE, main = "lambda = 0.14 (normal)") hist(rtlambda(1e5, 0.5), freq = FALSE, main = "lambda = 0.5 (concave)") hist(rtlambda(1e5, 1), freq = FALSE, main = "lambda = 1 (uniform)") hist(rtlambda(1e5, 2), freq = FALSE, main = "lambda = 2 (uniform)") par(partmp) } \references{ Joiner, B.L., & Rosenblatt, J.R. (1971). Some properties of the range in samples from Tukey's symmetric lambda distributions. Journal of the American Statistical Association, 66(334), 394-399. Hastings Jr, C., Mosteller, F., Tukey, J.W., & Winsor, C.P. (1947). Low moments for small samples: a comparative study of order statistics. The Annals of Mathematical Statistics, 413-426. } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/NormalMix.Rd0000644000176200001440000000377614532041732015371 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/mixture-of-normal-distributions.R \name{NormalMix} \alias{NormalMix} \alias{dmixnorm} \alias{pmixnorm} \alias{rmixnorm} \title{Mixture of normal distributions} \usage{ dmixnorm(x, mean, sd, alpha, log = FALSE) pmixnorm(q, mean, sd, alpha, lower.tail = TRUE, log.p = FALSE) rmixnorm(n, mean, sd, alpha) } \arguments{ \item{x, q}{vector of quantiles.} \item{mean}{matrix (or vector) of means.} \item{sd}{matrix (or vector) of standard deviations.} \item{alpha}{matrix (or vector) of mixing proportions; mixing proportions need to sum up to 1.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} \item{p}{vector of probabilities.} } \description{ Density, distribution function and random generation for the mixture of normal distributions. } \details{ Probability density function \deqn{ f(x) = \alpha_1 f_1(x; \mu_1, \sigma_1) + \dots + \alpha_k f_k(x; \mu_k, \sigma_k) }{ f(x) = \alpha[1] * f1(x; \mu[1], \sigma[1]) + \dots + \alpha[k] * fk(x; \mu[k], \sigma[k]) } Cumulative distribution function \deqn{ F(x) = \alpha_1 F_1(x; \mu_1, \sigma_1) + \dots + \alpha_k F_k(x; \mu_k, \sigma_k) }{ F(x) = \alpha[1] * F1(x; \mu[1], \sigma[1]) + \dots + \alpha[k] * Fk(x; \mu[k], \sigma[k]) } where \eqn{\sum_i \alpha_i = 1}{sum(\alpha[i]) == 1}. } \examples{ x <- rmixnorm(1e5, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)) hist(x, 100, freq = FALSE) curve(dmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)), -20, 20, n = 500, col = "red", add = TRUE) hist(pmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3))) plot(ecdf(x)) curve(pmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)), -20, 20, n = 500, col = "red", lwd = 2, add = TRUE) } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/TruncBinom.Rd0000644000176200001440000000315014532041732015525 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/truncated-binomial-distribution.R \name{TruncBinom} \alias{TruncBinom} \alias{dtbinom} \alias{ptbinom} \alias{qtbinom} \alias{rtbinom} \title{Truncated binomial distribution} \usage{ dtbinom(x, size, prob, a = -Inf, b = Inf, log = FALSE) ptbinom(q, size, prob, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) qtbinom(p, size, prob, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) rtbinom(n, size, prob, a = -Inf, b = Inf) } \arguments{ \item{x, q}{vector of quantiles.} \item{size}{number of trials (zero or more).} \item{prob}{probability of success on each trial.} \item{a, b}{lower and upper truncation points (\code{a < x <= b}).} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the truncated binomial distribution. } \examples{ x <- rtbinom(1e5, 100, 0.83, 76, 86) xx <- seq(0, 100) plot(prop.table(table(x))) lines(xx, dtbinom(xx, 100, 0.83, 76, 86), col = "red") hist(ptbinom(x, 100, 0.83, 76, 86)) xx <- seq(0, 100, by = 0.01) plot(ecdf(x)) lines(xx, ptbinom(xx, 100, 0.83, 76, 86), col = "red", lwd = 2) uu <- seq(0, 1, by = 0.001) lines(qtbinom(uu, 100, 0.83, 76, 86), uu, col = "blue", lty = 2) } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/BetaNegBinom.Rd0000644000176200001440000000600214532041731015735 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/beta-negative-binomial-distribution.R \name{BetaNegBinom} \alias{BetaNegBinom} \alias{dbnbinom} \alias{pbnbinom} \alias{rbnbinom} \title{Beta-negative binomial distribution} \usage{ dbnbinom(x, size, alpha = 1, beta = 1, log = FALSE) pbnbinom(q, size, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE) rbnbinom(n, size, alpha = 1, beta = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{size}{number of trials (zero or more). Must be strictly positive, need not be integer.} \item{alpha, beta}{non-negative parameters of the beta distribution.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function and random generation for the beta-negative binomial distribution. } \details{ If \eqn{p \sim \mathrm{Beta}(\alpha, \beta)}{p ~ Beta(\alpha, \beta)} and \eqn{X \sim \mathrm{NegBinomial}(r, p)}{X ~ NegBinomial(r, p)}, then \eqn{X \sim \mathrm{BetaNegBinomial}(r, \alpha, \beta)}{X ~ BetaNegBinomial(r, \alpha, \beta)}. Probability mass function \deqn{ f(x) = \frac{\Gamma(r+x)}{x! \,\Gamma(r)} \frac{\mathrm{B}(\alpha+r, \beta+x)}{\mathrm{B}(\alpha, \beta)} }{ f(x) = \Gamma(r+x)/(x! \Gamma(r)) * B(\alpha+r, \beta+x) / B(\alpha, \beta) } Cumulative distribution function is calculated using recursive algorithm that employs the fact that \eqn{\Gamma(x) = (x - 1)!} and \eqn{ \mathrm{B}(x, y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)} }{ B(x, y) = (\Gamma(x)\Gamma(y))/\Gamma(x+y) }. This enables re-writing probability mass function as \deqn{ f(x) = \frac{(r+x-1)!}{x! \, \Gamma(r)} \frac{\frac{(\alpha+r-1)!\,(\beta+x-1)!}{(\alpha+\beta+r+x-1)!}}{\mathrm{B}(\alpha,\beta)} }{ f(x) = ((r+x-1)!)/(x!*\Gamma(r))*(((\alpha+r-1)!*(\beta+x-1)!)/((\alpha+\beta+r+x-1)!))/B(\alpha,\beta) } what makes recursive updating from \eqn{x} to \eqn{x+1} easy using the properties of factorials \deqn{ f(x+1) = \frac{(r+x-1)!\,(r+x)}{x!\,(x+1) \, \Gamma(r)} \frac{\frac{(\alpha+r-1)!\,(\beta+x-1)!\,(\beta+x)}{(\alpha+\beta+r+x-1)!\,(\alpha+\beta+r+x)}}{\mathrm{B}(\alpha,\beta)} }{ f(x+1) = ((r+x-1)!*(r+x))/(x!*(x+1)*\Gamma(r))*(((\alpha+r-1)!*(\beta+x-1)!*(\beta+x))/((\alpha+\beta+r+x-1)!*(\alpha+\beta+r+x)))/B(\alpha,\beta) } and let's us efficiently calculate cumulative distribution function as a sum of probability mass functions \deqn{F(x) = \sum_{k=0}^x f(k)}{F(x) = f(0)+...+f(x)} } \examples{ x <- rbnbinom(1e5, 1000, 5, 13) xx <- 0:1e5 hist(x, 100, freq = FALSE) lines(xx-0.5, dbnbinom(xx, 1000, 5, 13), col = "red") hist(pbnbinom(x, 1000, 5, 13)) xx <- seq(0, 1e5, by = 0.1) plot(ecdf(x)) lines(xx, pbnbinom(xx, 1000, 5, 13), col = "red", lwd = 2) } \seealso{ \code{\link[stats]{Beta}}, \code{\link[stats]{NegBinomial}} } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/Pareto.Rd0000644000176200001440000000322014532041732014675 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/pareto-distribution.R \name{Pareto} \alias{Pareto} \alias{dpareto} \alias{ppareto} \alias{qpareto} \alias{rpareto} \title{Pareto distribution} \usage{ dpareto(x, a = 1, b = 1, log = FALSE) ppareto(q, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) qpareto(p, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) rpareto(n, a = 1, b = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{a, b}{positive valued scale and location parameters.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the Pareto distribution. } \details{ Probability density function \deqn{ f(x) = \frac{ab^a}{x^{a+1}} }{ f(x) = (a*b^a) / x^(a+1) } Cumulative distribution function \deqn{ F(x) = 1 - \left(\frac{b}{x}\right)^a }{ F(x) = 1 - (b/x)^a } Quantile function \deqn{ F^{-1}(p) = \frac{b}{(1-p)^{1-a}} }{ F^-1(p) = b/(1-p)^(1-a) } } \examples{ x <- rpareto(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dpareto(x, 5, 16), 0, 200, col = "red", add = TRUE) hist(ppareto(x, 5, 16)) plot(ecdf(x)) curve(ppareto(x, 5, 16), 0, 200, col = "red", lwd = 2, add = TRUE) } \references{ Krishnamoorthy, K. (2006). Handbook of Statistical Distributions with Applications. Chapman & Hall/CRC } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/BivPoiss.Rd0000644000176200001440000000353114532041731015205 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/bivariate-poisson-distribution.R \name{BivPoiss} \alias{BivPoiss} \alias{dbvpois} \alias{rbvpois} \title{Bivariate Poisson distribution} \usage{ dbvpois(x, y = NULL, a, b, c, log = FALSE) rbvpois(n, a, b, c) } \arguments{ \item{x, y}{vectors of quantiles; alternatively x may be a two-column matrix (or data.frame) and y may be omitted.} \item{a, b, c}{positive valued parameters.} \item{log}{logical; if TRUE, probabilities p are given as log(p).} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function and random generation for the bivariate Poisson distribution. } \details{ Probability mass function \deqn{ f(x) = \exp \{-(a+b+c)\} \frac{a^x}{x!} \frac{b^y}{y!} \sum_{k=0}^{\min(x,y)} {x \choose k} {y \choose k} k! \left( \frac{c}{ab} \right)^k }{ f(x) = exp(-(a+b+c)) * (a^x)/x! * (b^y)/y! * sum(choose(x,k)*choose(y,k)*k!*(c/(a*b))^k) } } \examples{ x <- rbvpois(5000, 7, 8, 5) image(prop.table(table(x[,1], x[,2]))) colMeans(x) } \references{ Karlis, D. and Ntzoufras, I. (2003). Analysis of sports data by using bivariate Poisson models. Journal of the Royal Statistical Society: Series D (The Statistician), 52(3), 381-393. Kocherlakota, S. and Kocherlakota, K. (1992) Bivariate Discrete Distributions. New York: Dekker. Johnson, N., Kotz, S. and Balakrishnan, N. (1997). Discrete Multivariate Distributions. New York: Wiley. Holgate, P. (1964). Estimation for the bivariate Poisson distribution. Biometrika, 51(1-2), 241-287. Kawamura, K. (1984). Direct calculation of maximum likelihood estimator for the bivariate Poisson distribution. Kodai mathematical journal, 7(2), 211-221. } \seealso{ \code{\link[stats]{Poisson}} } \concept{Discrete} \concept{Multivariate} \keyword{distribution} extraDistr/man/NSBeta.Rd0000644000176200001440000000306614532041732014567 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/non-standard-beta-distribution.R \name{NSBeta} \alias{NSBeta} \alias{dnsbeta} \alias{dgbeta} \alias{pnsbeta} \alias{qnsbeta} \alias{rnsbeta} \title{Non-standard beta distribution} \usage{ dnsbeta(x, shape1, shape2, min = 0, max = 1, log = FALSE) pnsbeta(q, shape1, shape2, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE) qnsbeta(p, shape1, shape2, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE) rnsbeta(n, shape1, shape2, min = 0, max = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{shape1, shape2}{non-negative parameters of the Beta distribution.} \item{min, max}{lower and upper bounds.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \leq x]}, otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Non-standard form of beta distribution with lower and upper bounds denoted as \code{min} and \code{max}. By default \code{min=0} and \code{max=1} what leads to standard beta distribution. } \examples{ x <- rnsbeta(1e5, 5, 13, -4, 8) hist(x, 100, freq = FALSE) curve(dnsbeta(x, 5, 13, -4, 8), -4, 6, col = "red", add = TRUE) hist(pnsbeta(x, 5, 13, -4, 8)) plot(ecdf(x)) curve(pnsbeta(x, 5, 13, -4, 8), -4, 6, col = "red", lwd = 2, add = TRUE) } \seealso{ \code{\link[stats]{Beta}} } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/ZINB.Rd0000644000176200001440000000350214532041732014210 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/zero-inflated-negative-binomial-distribution.R \name{ZINB} \alias{ZINB} \alias{dzinb} \alias{pzinb} \alias{qzinb} \alias{rzinb} \title{Zero-inflated negative binomial distribution} \usage{ dzinb(x, size, prob, pi, log = FALSE) pzinb(q, size, prob, pi, lower.tail = TRUE, log.p = FALSE) qzinb(p, size, prob, pi, lower.tail = TRUE, log.p = FALSE) rzinb(n, size, prob, pi) } \arguments{ \item{x, q}{vector of quantiles.} \item{size}{target for number of successful trials, or dispersion parameter (the shape parameter of the gamma mixing distribution). Must be strictly positive, need not be integer.} \item{prob}{probability of success in each trial. \code{0 < prob <= 1}.} \item{pi}{probability of extra zeros.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function and random generation for the zero-inflated negative binomial distribution. } \details{ Probability density function \deqn{ f(x) = \left\{\begin{array}{ll} \pi + (1 - \pi) p^r & x = 0 \\ (1 - \pi) {x+r-1 \choose x} p^r (1-p)^x & x > 0 \\ \end{array}\right. }{ f(x) = [if x = 0:] (1-\pi)+\pi * p^r [else:] (1-\pi) * dnbinom(x, size, prob) } } \examples{ x <- rzinb(1e5, 100, 0.6, 0.33) xx <- -2:200 plot(prop.table(table(x)), type = "h") lines(xx, dzinb(xx, 100, 0.6, 0.33), col = "red") xx <- seq(0, 200, by = 0.01) plot(ecdf(x)) lines(xx, pzinb(xx, 100, 0.6, 0.33), col = "red") } \seealso{ \code{\link[stats]{NegBinomial}} } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/Huber.Rd0000644000176200001440000000407314532041732014517 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/huber-distribution.R \name{Huber} \alias{Huber} \alias{dhuber} \alias{phuber} \alias{qhuber} \alias{rhuber} \title{"Huber density" distribution} \usage{ dhuber(x, mu = 0, sigma = 1, epsilon = 1.345, log = FALSE) phuber(q, mu = 0, sigma = 1, epsilon = 1.345, lower.tail = TRUE, log.p = FALSE) qhuber(p, mu = 0, sigma = 1, epsilon = 1.345, lower.tail = TRUE, log.p = FALSE) rhuber(n, mu = 0, sigma = 1, epsilon = 1.345) } \arguments{ \item{x, q}{vector of quantiles.} \item{mu, sigma, epsilon}{location, and scale, and shape parameters. Scale and shape must be positive.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the "Huber density" distribution. } \details{ Huber density is connected to Huber loss and can be defined as: \deqn{ f(x) = \frac{1}{2 \sqrt{2\pi} \left( \Phi(k) + \phi(k)/k - \frac{1}{2} \right)} e^{-\rho_k(x)} }{ f(x) = 1/(2 * sqrt(2\pi) * (\Phi(k) + \phi(k)/k - 1/2)) * exp(-\rho(x, k)) } where \deqn{ \rho_k(x) = \left\{\begin{array}{ll} \frac{1}{2} x^2 & |x|\le k \\ k|x|- \frac{1}{2} k^2 & |x|>k \end{array}\right. }{ \rho(x, k) = [if abs(x) <= k:] (x^2)/2 [else:] k*abs(x) - (k^2)/2 } } \examples{ x <- rhuber(1e5, 5, 2, 3) hist(x, 100, freq = FALSE) curve(dhuber(x, 5, 2, 3), -20, 20, col = "red", add = TRUE, n = 5000) hist(phuber(x, 5, 2, 3)) plot(ecdf(x)) curve(phuber(x, 5, 2, 3), -20, 20, col = "red", lwd = 2, add = TRUE) } \references{ Huber, P.J. (1964). Robust Estimation of a Location Parameter. Annals of Statistics, 53(1), 73-101. Huber, P.J. (1981). Robust Statistics. Wiley. Schumann, D. (2009). Robust Variable Selection. ProQuest. } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/Multinomial.Rd0000644000176200001440000000264514532041732015747 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/multinomial-distribution.R \name{Multinomial} \alias{Multinomial} \alias{dmnom} \alias{rmnom} \title{Multinomial distribution} \usage{ dmnom(x, size, prob, log = FALSE) rmnom(n, size, prob) } \arguments{ \item{x}{\eqn{k}-column matrix of quantiles.} \item{size}{numeric vector; number of trials (zero or more).} \item{prob}{\eqn{k}-column numeric matrix; probability of success on each trial.} \item{log}{logical; if TRUE, probabilities p are given as log(p).} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function and random generation for the multinomial distribution. } \details{ Probability mass function \deqn{ f(x) = \frac{n!}{\prod_{i=1}^k x_i} \prod_{i=1}^k p_i^{x_i} }{ f(x) = n!/prod(x[i]!) * prod(p[i]^x[i]) } } \examples{ # Generating 10 random draws from multinomial distribution # parametrized using a vector (x <- rmnom(10, 3, c(1/3, 1/3, 1/3))) # Results are consistent with dmultinom() from stats: all.equal(dmultinom(x[1,], 3, c(1/3, 1/3, 1/3)), dmnom(x[1, , drop = FALSE], 3, c(1/3, 1/3, 1/3))) } \references{ Gentle, J.E. (2006). Random number generation and Monte Carlo methods. Springer. } \seealso{ \code{\link[stats]{Binomial}}, \code{\link[stats]{Multinomial}} } \concept{Discrete} \concept{Multivariate} \keyword{distribution} extraDistr/man/PowerDist.Rd0000644000176200001440000000305114532041732015365 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/power-distribution.R \name{PowerDist} \alias{PowerDist} \alias{dpower} \alias{ppower} \alias{qpower} \alias{rpower} \title{Power distribution} \usage{ dpower(x, alpha, beta, log = FALSE) ppower(q, alpha, beta, lower.tail = TRUE, log.p = FALSE) qpower(p, alpha, beta, lower.tail = TRUE, log.p = FALSE) rpower(n, alpha, beta) } \arguments{ \item{x, q}{vector of quantiles.} \item{alpha, beta}{parameters.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the power distribution. } \details{ Probability density function \deqn{ f(x) = \frac{\beta x^{\beta-1}}{\alpha^\beta} }{ f(x) = (\beta*x^(\beta-1)) / (\alpha^\beta) } Cumulative distribution function \deqn{ F(x) = \frac{x^\beta}{\alpha^\beta} }{ F(x) = x^\beta / \alpha^\beta } Quantile function \deqn{ F^{-1}(p) = \alpha p^{1/\beta} }{ F^-1(p) = \alpha * p^(1/\beta) } } \examples{ x <- rpower(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dpower(x, 5, 16), 2, 6, col = "red", add = TRUE, n = 5000) hist(ppower(x, 5, 16)) plot(ecdf(x)) curve(ppower(x, 5, 16), 2, 6, col = "red", lwd = 2, add = TRUE) } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/BetaBinom.Rd0000644000176200001440000000605114532041731015307 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/beta-binomial-distribution.R \name{BetaBinom} \alias{BetaBinom} \alias{dbbinom} \alias{pbbinom} \alias{rbbinom} \title{Beta-binomial distribution} \usage{ dbbinom(x, size, alpha = 1, beta = 1, log = FALSE) pbbinom(q, size, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE) rbbinom(n, size, alpha = 1, beta = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{size}{number of trials (zero or more).} \item{alpha, beta}{non-negative parameters of the beta distribution.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function and random generation for the beta-binomial distribution. } \details{ If \eqn{p \sim \mathrm{Beta}(\alpha, \beta)}{p ~ Beta(\alpha, \beta)} and \eqn{X \sim \mathrm{Binomial}(n, p)}{X ~ Binomial(n, p)}, then \eqn{X \sim \mathrm{BetaBinomial}(n, \alpha, \beta)}{X ~ BetaBinomial(n, \alpha, \beta)}. Probability mass function \deqn{ f(x) = {n \choose x} \frac{\mathrm{B}(x+\alpha, n-x+\beta)}{\mathrm{B}(\alpha, \beta)} }{ f(x) = choose(n, x) * B(x+\alpha, n-x+\beta) / B(\alpha, \beta) } Cumulative distribution function is calculated using recursive algorithm that employs the fact that \eqn{\Gamma(x) = (x - 1)!}, and \eqn{ \mathrm{B}(x, y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)} }{ B(x, y) = (\Gamma(x)\Gamma(y))/\Gamma(x+y) }, and that \eqn{ {n \choose k} = \prod_{i=1}^k \frac{n+1-i}{i} }{ choose(n,k) = prod((n+1-(1:k))/(1:k)) }. This enables re-writing probability mass function as \deqn{ f(x) = \left( \prod_{i=1}^x \frac{n+1-i}{i} \right) \frac{\frac{(\alpha+x-1)!\,(\beta+n-x-1)!}{(\alpha+\beta+n-1)!}}{\mathrm{B}(\alpha,\beta)} }{ f(x) = prod((n+1-(1:x))/(1:x)) * (((\alpha+x-1)!*(\beta+n-x-1)!)/((\alpha+\beta+n+1)!)) / B(\alpha, \beta) } what makes recursive updating from \eqn{x} to \eqn{x+1} easy using the properties of factorials \deqn{ f(x+1) = \left( \prod_{i=1}^x \frac{n+1-i}{i} \right) \frac{n+1-x+1}{x+1} \frac{\frac{(\alpha+x-1)! \,(\alpha+x)\,(\beta+n-x-1)! \, (\beta+n-x)^{-1}}{(\alpha+\beta+n-1)!\,(\alpha+\beta+n)}}{\mathrm{B}(\alpha,\beta)} }{ f(x+1) = prod((n+1-(1:x))/(1:x)) * ((n+1-x+1)/(x+1)) * (((\alpha+x-1)!*(\alpha+x)*(\beta+n-x-1)!/(\beta+n-x))/((\alpha+\beta+n+1)!*(\alpha+\beta+n))) / B(\alpha, \beta) } and let's us efficiently calculate cumulative distribution function as a sum of probability mass functions \deqn{F(x) = \sum_{k=0}^x f(k)}{F(x) = f(0)+...+f(x)} } \examples{ x <- rbbinom(1e5, 1000, 5, 13) xx <- 0:1000 hist(x, 100, freq = FALSE) lines(xx-0.5, dbbinom(xx, 1000, 5, 13), col = "red") hist(pbbinom(x, 1000, 5, 13)) xx <- seq(0, 1000, by = 0.1) plot(ecdf(x)) lines(xx, pbbinom(xx, 1000, 5, 13), col = "red", lwd = 2) } \seealso{ \code{\link[stats]{Beta}}, \code{\link[stats]{Binomial}} } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/TruncNormal.Rd0000644000176200001440000000762014532041732015717 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/truncated-normal-distribution.R \name{TruncNormal} \alias{TruncNormal} \alias{dtnorm} \alias{ptnorm} \alias{qtnorm} \alias{rtnorm} \title{Truncated normal distribution} \usage{ dtnorm(x, mean = 0, sd = 1, a = -Inf, b = Inf, log = FALSE) ptnorm( q, mean = 0, sd = 1, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE ) qtnorm( p, mean = 0, sd = 1, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE ) rtnorm(n, mean = 0, sd = 1, a = -Inf, b = Inf) } \arguments{ \item{x, q}{vector of quantiles.} \item{mean, sd}{location and scale parameters. Scale must be positive.} \item{a, b}{lower and upper truncation points (\code{a < x <= b}, with \code{a = -Inf} and \code{b = Inf} by default).} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the truncated normal distribution. } \details{ Probability density function \deqn{ f(x) = \frac{\phi(\frac{x-\mu}{\sigma})} {\Phi(\frac{b-\mu}{\sigma}) - \Phi(\frac{a-\mu}{\sigma})} }{ f(x) = \phi((x-\mu)/\sigma) / (\Phi((b-\mu)/\sigma) - \Phi((a-\mu)/\sigma)) } Cumulative distribution function \deqn{ F(x) = \frac{\Phi(\frac{x-\mu}{\sigma}) - \Phi(\frac{a-\mu}{\sigma})} {\Phi(\frac{b-\mu}{\sigma}) - \Phi(\frac{a-\mu}{\sigma})} }{ F(x) = (\Phi((x-\mu)/\sigma) - \Phi((a-\mu)/\sigma)) / (\Phi((b-\mu)/\sigma) - \Phi((a-\mu)/\sigma)) } Quantile function \deqn{ F^{-1}(p) = \Phi^{-1}\left(\Phi\left(\frac{a-\mu}{\sigma}\right) + p \times \left[\Phi\left(\frac{b-\mu}{\sigma}\right) - \Phi\left(\frac{a-\mu}{\sigma}\right)\right]\right) }{ F^-1(p) = \Phi^-1(\Phi((a-\mu)/\sigma) + p * (\Phi((b-\mu)/\sigma) - \Phi((a-\mu)/\sigma))) } For random generation algorithm described by Robert (1995) is used. } \examples{ x <- rtnorm(1e5, 5, 3, b = 7) hist(x, 100, freq = FALSE) curve(dtnorm(x, 5, 3, b = 7), -8, 8, col = "red", add = TRUE) hist(ptnorm(x, 5, 3, b = 7)) plot(ecdf(x)) curve(ptnorm(x, 5, 3, b = 7), -8, 8, col = "red", lwd = 2, add = TRUE) R <- 1e5 partmp <- par(mfrow = c(2,4), mar = c(2,2,2,2)) hist(rtnorm(R), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x), -5, 5, col = "red", add = TRUE) hist(rtnorm(R, a = 0), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, a = 0), -1, 5, col = "red", add = TRUE) hist(rtnorm(R, b = 0), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, b = 0), -5, 5, col = "red", add = TRUE) hist(rtnorm(R, a = 0, b = 1), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, a = 0, b = 1), -1, 2, col = "red", add = TRUE) hist(rtnorm(R, a = -1, b = 0), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, a = -1, b = 0), -2, 2, col = "red", add = TRUE) hist(rtnorm(R, mean = -6, a = 0), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, mean = -6, a = 0), -2, 1, col = "red", add = TRUE) hist(rtnorm(R, mean = 8, b = 0), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, mean = 8, b = 0), -2, 1, col = "red", add = TRUE) hist(rtnorm(R, a = 3, b = 5), freq= FALSE, main = "", xlab = "", ylab = "") curve(dtnorm(x, a = 3, b = 5), 2, 5, col = "red", add = TRUE) par(partmp) } \references{ Robert, C.P. (1995). Simulation of truncated normal variables. Statistics and Computing 5(2): 121-125. \url{https://arxiv.org/abs/0907.4010} Burkardt, J. (17 October 2014). The Truncated Normal Distribution. Florida State University. \url{https://people.sc.fsu.edu/~jburkardt/presentations/truncated_normal.pdf} } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/Wald.Rd0000644000176200001440000000371614532041732014344 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/wald-distribution.R \name{Wald} \alias{Wald} \alias{dwald} \alias{pwald} \alias{rwald} \title{Wald (inverse Gaussian) distribution} \usage{ dwald(x, mu, lambda, log = FALSE) pwald(q, mu, lambda, lower.tail = TRUE, log.p = FALSE) rwald(n, mu, lambda) } \arguments{ \item{x, q}{vector of quantiles.} \item{mu, lambda}{location and shape parameters. Scale must be positive.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} \item{p}{vector of probabilities.} } \description{ Density, distribution function and random generation for the Wald distribution. } \details{ Probability density function \deqn{ f(x) = \sqrt{\frac{\lambda}{2\pi x^3}} \exp\left( \frac{-\lambda(x-\mu)^2}{2\mu^2 x} \right) }{ f(x) = sqrt(\lambda/(2*\pi*x^3)) * exp((-\lambda*(x-\mu)^2)/(2*\mu^2*x)) } Cumulative distribution function \deqn{ F(x) = \Phi\left(\sqrt{\frac{\lambda}{x}} \left(\frac{x}{\mu}-1 \right) \right) + \exp\left(\frac{2\lambda}{\mu} \right) \Phi\left(\sqrt{\frac{\lambda}{x}} \left(\frac{x}{\mu}+1 \right) \right) }{ F(x) = \Phi(sqrt(\lambda/\mu)*(x/\mu-1)) - exp((2*\lambda)/\mu) * \Phi(sqrt(\lambda/\mu)*(x/\mu+1)) } Random generation is done using the algorithm described by Michael, Schucany and Haas (1976). } \examples{ x <- rwald(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dwald(x, 5, 16), 0, 50, col = "red", add = TRUE) hist(pwald(x, 5, 16)) plot(ecdf(x)) curve(pwald(x, 5, 16), 0, 50, col = "red", lwd = 2, add = TRUE) } \references{ Michael, J.R., Schucany, W.R., and Haas, R.W. (1976). Generating Random Variates Using Transformations with Multiple Roots. The American Statistician, 30(2): 88-90. } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/ShiftGomp.Rd0000644000176200001440000000516214532041732015352 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/shifted-gompertz-distribution.R \name{ShiftGomp} \alias{ShiftGomp} \alias{dsgomp} \alias{psgomp} \alias{rsgomp} \title{Shifted Gompertz distribution} \usage{ dsgomp(x, b, eta, log = FALSE) psgomp(q, b, eta, lower.tail = TRUE, log.p = FALSE) rsgomp(n, b, eta) } \arguments{ \item{x, q}{vector of quantiles.} \item{b, eta}{positive valued scale and shape parameters; both need to be positive.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, and random generation for the shifted Gompertz distribution. } \details{ If \eqn{X} follows exponential distribution parametrized by scale \eqn{b} and \eqn{Y} follows reparametrized Gumbel distribution with cumulative distribution function \eqn{F(x) = \exp(-\eta e^{-bx})}{F(x) = exp(-\eta*exp(-b*x))} parametrized by scale \eqn{b} and shape \eqn{\eta}, then \eqn{\max(X,Y)}{max(X,Y)} follows shifted Gompertz distribution parametrized by scale \eqn{b>0} and shape \eqn{\eta>0}. The above relation is used by \code{rsgomp} function for random generation from shifted Gompertz distribution. Probability density function \deqn{ f(x) = b e^{-bx} \exp(-\eta e^{-bx}) \left[1 + \eta(1 - e^{-bx})\right] }{ f(x) = b*exp(-b*x) * exp(-\eta*exp(-b*x)) * (1 + \eta*(1 - exp(-b*x))) } Cumulative distribution function \deqn{ F(x) = (1-e^{-bx}) \exp(-\eta e^{-bx}) }{ F(x) = (1-exp(-b*x)) * exp(-\eta*exp(-b*x)) } } \examples{ x <- rsgomp(1e5, 0.4, 1) hist(x, 50, freq = FALSE) curve(dsgomp(x, 0.4, 1), 0, 30, col = "red", add = TRUE) hist(psgomp(x, 0.4, 1)) plot(ecdf(x)) curve(psgomp(x, 0.4, 1), 0, 30, col = "red", lwd = 2, add = TRUE) } \references{ Bemmaor, A.C. (1994). Modeling the Diffusion of New Durable Goods: Word-of-Mouth Effect Versus Consumer Heterogeneity. [In:] G. Laurent, G.L. Lilien & B. Pras. Research Traditions in Marketing. Boston: Kluwer Academic Publishers. pp. 201-223. Jimenez, T.F. and Jodra, P. (2009). A Note on the Moments and Computer Generation of the Shifted Gompertz Distribution. Communications in Statistics - Theory and Methods, 38(1), 78-89. Jimenez T.F. (2014). Estimation of the Parameters of the Shifted Gompertz Distribution, Using Least Squares, Maximum Likelihood and Moments Methods. Journal of Computational and Applied Mathematics, 255(1), 867-877. } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/DiscreteLaplace.Rd0000644000176200001440000000453614532041731016501 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/discrete-laplace-distribution.R \name{DiscreteLaplace} \alias{DiscreteLaplace} \alias{ddlaplace} \alias{pdlaplace} \alias{rdlaplace} \title{Discrete Laplace distribution} \usage{ ddlaplace(x, location, scale, log = FALSE) pdlaplace(q, location, scale, lower.tail = TRUE, log.p = FALSE) rdlaplace(n, location, scale) } \arguments{ \item{x, q}{vector of quantiles.} \item{location}{location parameter.} \item{scale}{scale parameter; \code{0 < scale < 1}.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass, distribution function and random generation for the discrete Laplace distribution parametrized by location and scale. } \details{ If \eqn{U \sim \mathrm{Geometric}(1-p)}{U ~ Geometric(1-p)} and \eqn{V \sim \mathrm{Geometric}(1-p)}{V ~ Geometric(1-p)}, then \eqn{U-V \sim \mathrm{DiscreteLaplace}(p)}{U-V ~ DiscreteLaplace(p)}, where geometric distribution is related to discrete Laplace distribution in similar way as exponential distribution is related to Laplace distribution. Probability mass function \deqn{ f(x) = \frac{1-p}{1+p} p^{|x-\mu|} }{ f(x) = (1-p)/(1+p) * p^(|x-\mu|) } Cumulative distribution function \deqn{ F(x) = \left\{\begin{array}{ll} \frac{p^{-|x-\mu|}}{1+p} & x < 0 \\ 1 - \frac{p^{|x-\mu|+1}}{1+p} & x \ge 0 \end{array}\right. }{ F(x) = [if x < 0:] p^-floor(x-\mu))/(1+p) [else:] 1-(p^(floor(x-\mu)+1))/(1+p) } } \examples{ p <- 0.45 x <- rdlaplace(1e5, 0, p) xx <- seq(-200, 200, by = 1) plot(prop.table(table(x))) lines(xx, ddlaplace(xx, 0, p), col = "red") hist(pdlaplace(x, 0, p)) plot(ecdf(x)) lines(xx, pdlaplace(xx, 0, p), col = "red", type = "s") } \references{ Inusah, S., & Kozubowski, T.J. (2006). A discrete analogue of the Laplace distribution. Journal of statistical planning and inference, 136(3), 1090-1102. Kotz, S., Kozubowski, T., & Podgorski, K. (2012). The Laplace distribution and generalizations: a revisit with applications to communications, economics, engineering, and finance. Springer Science & Business Media. } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/Slash.Rd0000644000176200001440000000352414532041732014524 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/slash-distribution.R \name{Slash} \alias{Slash} \alias{dslash} \alias{pslash} \alias{rslash} \title{Slash distribution} \usage{ dslash(x, mu = 0, sigma = 1, log = FALSE) pslash(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) rslash(n, mu = 0, sigma = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{mu}{vector of locations} \item{sigma}{vector of positive valued scale parameters.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function, distribution function and random generation for slash distribution. } \details{ If \eqn{Z \sim \mathrm{Normal}(0, 1)}{Z ~ Normal(0, 1)} and \eqn{U \sim \mathrm{Uniform}(0, 1)}{U ~ Uniform(0, 1)}, then \eqn{Z/U} follows slash distribution. Probability density function \deqn{ f(x) = \left\{\begin{array}{ll} \frac{\phi(0) - \phi(x)}{x^2} & x \ne 0 \\ \frac{1}{2\sqrt{2\pi}} & x = 0 \end{array}\right. }{ f(x) = [if x != 0:] (\phi(0)-\phi(x))/x^2 [else:] 1/(2*sqrt(2*\pi)) } Cumulative distribution function \deqn{ F(x) = \left\{\begin{array}{ll} \Phi(x) - \frac{\phi(0)-\phi(x)}{x} & x \neq 0 \\ \frac{1}{2} & x = 0 \end{array}\right. }{ F(x) = [if x != 0:] \Phi(x) - [\phi(0)-\phi(x)]/x [else:] 1/2 } } \examples{ x <- rslash(1e5, 5, 3) hist(x, 1e5, freq = FALSE, xlim = c(-100, 100)) curve(dslash(x, 5, 3), -100, 100, col = "red", n = 500, add = TRUE) hist(pslash(x, 5, 3)) plot(ecdf(x), xlim = c(-100, 100)) curve(pslash(x, 5, 3), -100, 100, col = "red", lwd = 2, n = 500, add = TRUE) } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/Lomax.Rd0000644000176200001440000000314414532041732014530 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/lomax-distribution.R \name{Lomax} \alias{Lomax} \alias{dlomax} \alias{plomax} \alias{qlomax} \alias{rlomax} \title{Lomax distribution} \usage{ dlomax(x, lambda, kappa, log = FALSE) plomax(q, lambda, kappa, lower.tail = TRUE, log.p = FALSE) qlomax(p, lambda, kappa, lower.tail = TRUE, log.p = FALSE) rlomax(n, lambda, kappa) } \arguments{ \item{x, q}{vector of quantiles.} \item{lambda, kappa}{positive valued parameters.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the Lomax distribution. } \details{ Probability density function \deqn{ f(x) = \frac{\lambda \kappa}{(1+\lambda x)^{\kappa+1}} }{ f(x) = \lambda*\kappa / (1+\lambda*x)^(\kappa+1) } Cumulative distribution function \deqn{ F(x) = 1-(1+\lambda x)^{-\kappa} }{ F(x) = 1-(1+\lambda*x)^-\kappa } Quantile function \deqn{ F^{-1}(p) = \frac{(1-p)^{-1/\kappa} -1}{\lambda} }{ F^-1(p) = ((1-p)^(-1/\kappa)-1) / \lambda } } \examples{ x <- rlomax(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dlomax(x, 5, 16), 0, 1, col = "red", add = TRUE, n = 5000) hist(plomax(x, 5, 16)) plot(ecdf(x)) curve(plomax(x, 5, 16), 0, 1, col = "red", lwd = 2, add = TRUE) } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/BivNormal.Rd0000644000176200001440000000400314532041731015333 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/bivariate-normal-distribution.R \name{BivNormal} \alias{BivNormal} \alias{dbvnorm} \alias{rbvnorm} \title{Bivariate normal distribution} \usage{ dbvnorm( x, y = NULL, mean1 = 0, mean2 = mean1, sd1 = 1, sd2 = sd1, cor = 0, log = FALSE ) rbvnorm(n, mean1 = 0, mean2 = mean1, sd1 = 1, sd2 = sd1, cor = 0) } \arguments{ \item{x, y}{vectors of quantiles; alternatively x may be a two-column matrix (or data.frame) and y may be omitted.} \item{mean1, mean2}{vectors of means.} \item{sd1, sd2}{vectors of standard deviations.} \item{cor}{vector of correlations (\code{-1 < cor < 1}).} \item{log}{logical; if TRUE, probabilities p are given as log(p).} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function and random generation for the bivariate normal distribution. } \details{ Probability density function \deqn{ f(x) = \frac{1}{2\pi\sqrt{1-\rho^2}\sigma_1\sigma_2} \exp\left\{-\frac{1}{2(1-\rho^2)} \left[\left(\frac{x_1 - \mu_1}{\sigma_1}\right)^2 - 2\rho \left(\frac{x_1 - \mu_1}{\sigma_1}\right) \left(\frac{x_2 - \mu_2}{\sigma_2}\right) + \left(\frac{x_2 - \mu_2}{\sigma_2}\right)^2\right]\right\} }{ f(x) = 1/(2*\pi*sqrt(1-\rho^2)*\sigma1*\sigma2) * exp(-(1/(2*(1-\rho^2)* (((x1-\mu1)/\sigma1)^2 - 2*\rho*((x1-\mu1)/\sigma2)*((x2-\mu2)/\sigma2) * ((x2-\mu2)/\sigma2)^2)))) } } \examples{ y <- x <- seq(-4, 4, by = 0.25) z <- outer(x, y, function(x, y) dbvnorm(x, y, cor = -0.75)) persp(x, y, z) y <- x <- seq(-4, 4, by = 0.25) z <- outer(x, y, function(x, y) dbvnorm(x, y, cor = -0.25)) persp(x, y, z) } \references{ Krishnamoorthy, K. (2006). Handbook of Statistical Distributions with Applications. Chapman & Hall/CRC Mukhopadhyay, N. (2000). Probability and statistical inference. Chapman & Hall/CRC } \seealso{ \code{\link[stats]{Normal}} } \concept{Continuous} \concept{Multivariate} \keyword{distribution} extraDistr/man/HalfT.Rd0000644000176200001440000000352514532041732014451 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/half-t-distribution.R \name{HalfT} \alias{HalfT} \alias{dht} \alias{pht} \alias{qht} \alias{rht} \title{Half-t distribution} \usage{ dht(x, nu, sigma = 1, log = FALSE) pht(q, nu, sigma = 1, lower.tail = TRUE, log.p = FALSE) qht(p, nu, sigma = 1, lower.tail = TRUE, log.p = FALSE) rht(n, nu, sigma = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{nu, sigma}{positive valued degrees of freedom and scale parameters.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the half-t distribution. } \details{ If \eqn{X} follows t distribution parametrized by degrees of freedom \eqn{\nu} and scale \eqn{\sigma}, then \eqn{|X|} follows half-t distribution parametrized by degrees of freedom \eqn{\nu} and scale \eqn{\sigma}. } \examples{ x <- rht(1e5, 2, 2) hist(x, 500, freq = FALSE, xlim = c(0, 100)) curve(dht(x, 2, 2), 0, 100, col = "red", add = TRUE) hist(pht(x, 2, 2)) plot(ecdf(x), xlim = c(0, 100)) curve(pht(x, 2, 2), 0, 100, col = "red", lwd = 2, add = TRUE) } \references{ Gelman, A. (2006). Prior distributions for variance parameters in hierarchical models (comment on article by Browne and Draper). Bayesian analysis, 1(3), 515-534. Jacob, E. and Jayakumar, K. (2012). On Half-Cauchy Distribution and Process. International Journal of Statistika and Mathematika, 3(2), 77-81. } \seealso{ \code{\link{HalfNormal}}, \code{\link{HalfCauchy}} } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/ZIB.Rd0000644000176200001440000000321714532041732014075 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/zero-inflated-binomial-distribution.R \name{ZIB} \alias{ZIB} \alias{dzib} \alias{pzib} \alias{qzib} \alias{rzib} \title{Zero-inflated binomial distribution} \usage{ dzib(x, size, prob, pi, log = FALSE) pzib(q, size, prob, pi, lower.tail = TRUE, log.p = FALSE) qzib(p, size, prob, pi, lower.tail = TRUE, log.p = FALSE) rzib(n, size, prob, pi) } \arguments{ \item{x, q}{vector of quantiles.} \item{size}{number of trials (zero or more).} \item{prob}{probability of success in each trial. \code{0 < prob <= 1}.} \item{pi}{probability of extra zeros.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function and random generation for the zero-inflated binomial distribution. } \details{ Probability density function \deqn{ f(x) = \left\{\begin{array}{ll} \pi + (1 - \pi) (1-p)^n & x = 0 \\ (1 - \pi) {n \choose x} p^x (1-p)^{n-x} & x > 0 \\ \end{array}\right. }{ f(x) = [if x = 0:] (1-\pi)+\pi * p^r [else:] (1-\pi) * dnbinom(x, size, prob) } } \examples{ x <- rzib(1e5, 10, 0.6, 0.33) xx <- -2:20 plot(prop.table(table(x)), type = "h") lines(xx, dzib(xx, 10, 0.6, 0.33), col = "red") xx <- seq(0, 20, by = 0.01) plot(ecdf(x)) lines(xx, pzib(xx, 10, 0.6, 0.33), col = "red") } \seealso{ \code{\link[stats]{Binomial}} } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/Kumaraswamy.Rd0000644000176200001440000000346714532041732015761 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/kumaraswamy-distribution.R \name{Kumaraswamy} \alias{Kumaraswamy} \alias{dkumar} \alias{pkumar} \alias{qkumar} \alias{rkumar} \title{Kumaraswamy distribution} \usage{ dkumar(x, a = 1, b = 1, log = FALSE) pkumar(q, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) qkumar(p, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) rkumar(n, a = 1, b = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{a, b}{positive valued parameters.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the Kumaraswamy distribution. } \details{ Probability density function \deqn{ f(x) = abx^{a-1} (1-x^a)^{b-1} }{ f(x) = a*b*x^(a-1)*(1-x^a)^(b-1) } Cumulative distribution function \deqn{ F(x) = 1-(1-x^a)^b }{ F(x) = 1-(1-x^a)^b } Quantile function \deqn{ F^{-1}(p) = 1-(1-p^{1/b})^{1/a} }{ F^-1(p) = 1-(1-p^(1/b))^(1/a) } } \examples{ x <- rkumar(1e5, 5, 16) hist(x, 100, freq = FALSE) curve(dkumar(x, 5, 16), 0, 1, col = "red", add = TRUE) hist(pkumar(x, 5, 16)) plot(ecdf(x)) curve(pkumar(x, 5, 16), 0, 1, col = "red", lwd = 2, add = TRUE) } \references{ Jones, M. C. (2009). Kumaraswamy's distribution: A beta-type distribution with some tractability advantages. Statistical Methodology, 6, 70-81. Cordeiro, G.M. and de Castro, M. (2009). A new family of generalized distributions. Journal of Statistical Computation & Simulation, 1-17. } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/InvGamma.Rd0000644000176200001440000000370314532041732015150 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/inverse-gamma-distribution.R \name{InvGamma} \alias{InvGamma} \alias{dinvgamma} \alias{pinvgamma} \alias{qinvgamma} \alias{rinvgamma} \title{Inverse-gamma distribution} \usage{ dinvgamma(x, alpha, beta = 1, log = FALSE) pinvgamma(q, alpha, beta = 1, lower.tail = TRUE, log.p = FALSE) qinvgamma(p, alpha, beta = 1, lower.tail = TRUE, log.p = FALSE) rinvgamma(n, alpha, beta = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{alpha, beta}{positive valued shape and scale parameters.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function and random generation for the inverse-gamma distribution. } \details{ Probability mass function \deqn{ f(x) = \frac{\beta^\alpha x^{-\alpha-1} \exp(-\frac{\beta}{x})}{\Gamma(\alpha)} }{ f(x) = (\beta^\alpha * x^(-\alpha-1) * exp(-\beta/x)) / \Gamma(\alpha) } Cumulative distribution function \deqn{ F(x) = \frac{\gamma(\alpha, \frac{\beta}{x})}{\Gamma(\alpha)} }{ F(x) = \gamma(\alpha, \beta/x) / \Gamma(\alpha) } } \examples{ x <- rinvgamma(1e5, 20, 3) hist(x, 100, freq = FALSE) curve(dinvgamma(x, 20, 3), 0, 1, col = "red", add = TRUE, n = 5000) hist(pinvgamma(x, 20, 3)) plot(ecdf(x)) curve(pinvgamma(x, 20, 3), 0, 1, col = "red", lwd = 2, add = TRUE, n = 5000) } \references{ Witkovsky, V. (2001). Computing the distribution of a linear combination of inverted gamma variables. Kybernetika 37(1), 79-90. Leemis, L.M. and McQueston, L.T. (2008). Univariate Distribution Relationships. American Statistician 62(1): 45-53. } \seealso{ \code{\link[stats]{GammaDist}} } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/DiscreteUniform.Rd0000644000176200001440000000262714532041731016556 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/discrete-uniform-distribution.R \name{DiscreteUniform} \alias{DiscreteUniform} \alias{ddunif} \alias{pdunif} \alias{qdunif} \alias{rdunif} \title{Discrete uniform distribution} \usage{ ddunif(x, min, max, log = FALSE) pdunif(q, min, max, lower.tail = TRUE, log.p = FALSE) qdunif(p, min, max, lower.tail = TRUE, log.p = FALSE) rdunif(n, min, max) } \arguments{ \item{x, q}{vector of quantiles.} \item{min, max}{lower and upper limits of the distribution. Must be finite.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function, distribution function, quantile function and random generation for the discrete uniform distribution. } \details{ If \code{min == max}, then discrete uniform distribution is a degenerate distribution. } \examples{ x <- rdunif(1e5, 1, 10) xx <- -1:11 plot(prop.table(table(x)), type = "h") lines(xx, ddunif(xx, 1, 10), col = "red") hist(pdunif(x, 1, 10)) xx <- seq(-1, 11, by = 0.01) plot(ecdf(x)) lines(xx, pdunif(xx, 1, 10), col = "red") } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/DiscreteWeibull.Rd0000644000176200001440000000455514532041731016544 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/discrete-weibull-distribution.R \name{DiscreteWeibull} \alias{DiscreteWeibull} \alias{ddweibull} \alias{pdweibull} \alias{qdweibull} \alias{rdweibull} \title{Discrete Weibull distribution (type I)} \usage{ ddweibull(x, shape1, shape2, log = FALSE) pdweibull(q, shape1, shape2, lower.tail = TRUE, log.p = FALSE) qdweibull(p, shape1, shape2, lower.tail = TRUE, log.p = FALSE) rdweibull(n, shape1, shape2) } \arguments{ \item{x, q}{vector of quantiles.} \item{shape1, shape2}{parameters (named q, \eqn{\beta}). Values of \code{shape2} need to be positive and \code{0 < shape1 < 1}.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the discrete Weibull (type I) distribution. } \details{ Probability mass function \deqn{ f(x) = q^{x^\beta} - q^{(x+1)^\beta} }{ f(x) = q^x^\beta - q^(x+1)^\beta } Cumulative distribution function \deqn{ F(x) = 1-q^{(x+1)^\beta} }{ F(x) = 1-q^(x+1)^\beta } Quantile function \deqn{ F^{-1}(p) = \left \lceil{\left(\frac{\log(1-p)}{\log(q)}\right)^{1/\beta} - 1}\right \rceil }{ F^-1(p) = ceiling((log(1-p)/log(q))^(1/\beta) - 1) } } \examples{ x <- rdweibull(1e5, 0.32, 1) xx <- seq(-2, 100, by = 1) plot(prop.table(table(x)), type = "h") lines(xx, ddweibull(xx, .32, 1), col = "red") # Notice: distribution of F(X) is far from uniform: hist(pdweibull(x, .32, 1), 50) plot(ecdf(x)) lines(xx, pdweibull(xx, .32, 1), col = "red", lwd = 2, type = "s") } \references{ Nakagawa, T. and Osaki, S. (1975). The Discrete Weibull Distribution. IEEE Transactions on Reliability, R-24, 300-301. Kulasekera, K.B. (1994). Approximate MLE's of the parameters of a discrete Weibull distribution with type I censored data. Microelectronics Reliability, 34(7), 1185-1188. Khan, M.A., Khalique, A. and Abouammoh, A.M. (1989). On estimating parameters in a discrete Weibull distribution. IEEE Transactions on Reliability, 38(3), 348-350. } \seealso{ \code{\link[stats]{Weibull}} } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/DiscreteGamma.Rd0000644000176200001440000000352314532041731016155 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/discrete-gamma-distribution.R \name{DiscreteGamma} \alias{DiscreteGamma} \alias{ddgamma} \alias{pdgamma} \alias{rdgamma} \title{Discrete gamma distribution} \usage{ ddgamma(x, shape, rate = 1, scale = 1/rate, log = FALSE) pdgamma(q, shape, rate = 1, scale = 1/rate, lower.tail = TRUE, log.p = FALSE) rdgamma(n, shape, rate = 1, scale = 1/rate) } \arguments{ \item{x, q}{vector of quantiles.} \item{shape, scale}{shape and scale parameters. Must be positive, scale strictly.} \item{rate}{an alternative way to specify the scale.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function, distribution function and random generation for discrete gamma distribution. } \details{ Probability mass function of discrete gamma distribution \eqn{f_Y(y)}{f} is defined by discretization of continuous gamma distribution \eqn{f_Y(y) = S_X(y) - S_X(y+1)}{f(y) = S(x) - S(x+1)} where \eqn{S_X}{S} is a survival function of continuous gamma distribution. } \examples{ x <- rdgamma(1e5, 9, 1) xx <- 0:50 plot(prop.table(table(x))) lines(xx, ddgamma(xx, 9, 1), col = "red") hist(pdgamma(x, 9, 1)) plot(ecdf(x)) xx <- seq(0, 50, 0.1) lines(xx, pdgamma(xx, 9, 1), col = "red", lwd = 2, type = "s") } \references{ Chakraborty, S. and Chakravarty, D. (2012). Discrete Gamma distributions: Properties and parameter estimations. Communications in Statistics-Theory and Methods, 41(18), 3301-3324. } \seealso{ \code{\link[stats]{GammaDist}}, \code{\link{DiscreteNormal}} } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/HalfNormal.Rd0000644000176200001440000000352114532041732015472 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/half-normal-distribution.R \name{HalfNormal} \alias{HalfNormal} \alias{dhnorm} \alias{phnorm} \alias{qhnorm} \alias{rhnorm} \title{Half-normal distribution} \usage{ dhnorm(x, sigma = 1, log = FALSE) phnorm(q, sigma = 1, lower.tail = TRUE, log.p = FALSE) qhnorm(p, sigma = 1, lower.tail = TRUE, log.p = FALSE) rhnorm(n, sigma = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{sigma}{positive valued scale parameter.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the half-normal distribution. } \details{ If \eqn{X} follows normal distribution centered at 0 and parametrized by scale \eqn{\sigma}, then \eqn{|X|} follows half-normal distribution parametrized by scale \eqn{\sigma}. Half-t distribution with \eqn{\nu=\infty} degrees of freedom converges to half-normal distribution. } \examples{ x <- rhnorm(1e5, 2) hist(x, 100, freq = FALSE) curve(dhnorm(x, 2), 0, 8, col = "red", add = TRUE) hist(phnorm(x, 2)) plot(ecdf(x)) curve(phnorm(x, 2), 0, 8, col = "red", lwd = 2, add = TRUE) } \references{ Gelman, A. (2006). Prior distributions for variance parameters in hierarchical models (comment on article by Browne and Draper). Bayesian analysis, 1(3), 515-534. Jacob, E. and Jayakumar, K. (2012). On Half-Cauchy Distribution and Process. International Journal of Statistika and Mathematika, 3(2), 77-81. } \seealso{ \code{\link{HalfT}} } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/Gumbel.Rd0000644000176200001440000000353014532041732014662 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/gumbel-distribution.R \name{Gumbel} \alias{Gumbel} \alias{dgumbel} \alias{pgumbel} \alias{qgumbel} \alias{rgumbel} \title{Gumbel distribution} \usage{ dgumbel(x, mu = 0, sigma = 1, log = FALSE) pgumbel(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) qgumbel(p, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) rgumbel(n, mu = 0, sigma = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{mu, sigma}{location and scale parameters. Scale must be positive.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the Gumbel distribution. } \details{ Probability density function \deqn{ f(x) = \frac{1}{\sigma} \exp\left(-\left(\frac{x-\mu}{\sigma} + \exp\left(-\frac{x-\mu}{\sigma}\right)\right)\right) }{ f(x) = 1/\sigma * exp(-((x-\mu)/\sigma + exp(-(x-\mu)/\sigma))) } Cumulative distribution function \deqn{ F(x) = \exp\left(-\exp\left(-\frac{x-\mu}{\sigma}\right)\right) }{ F(x) = exp(-exp(-(x-\mu)/\sigma)) } Quantile function \deqn{ F^{-1}(p) = \mu - \sigma \log(-\log(p)) }{ F^-1(p) = \mu - \sigma * log(-log(p)) } } \examples{ x <- rgumbel(1e5, 5, 2) hist(x, 100, freq = FALSE) curve(dgumbel(x, 5, 2), 0, 25, col = "red", add = TRUE) hist(pgumbel(x, 5, 2)) plot(ecdf(x)) curve(pgumbel(x, 5, 2), 0, 25, col = "red", lwd = 2, add = TRUE) } \references{ Bury, K. (1999). Statistical Distributions in Engineering. Cambridge University Press. } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/Triangular.Rd0000644000176200001440000000510614532041732015560 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/triangular-distribution.R \name{Triangular} \alias{Triangular} \alias{dtriang} \alias{ptriang} \alias{qtriang} \alias{rtriang} \title{Triangular distribution} \usage{ dtriang(x, a = -1, b = 1, c = (a + b)/2, log = FALSE) ptriang(q, a = -1, b = 1, c = (a + b)/2, lower.tail = TRUE, log.p = FALSE) qtriang(p, a = -1, b = 1, c = (a + b)/2, lower.tail = TRUE, log.p = FALSE) rtriang(n, a = -1, b = 1, c = (a + b)/2) } \arguments{ \item{x, q}{vector of quantiles.} \item{a, b, c}{minimum, maximum and mode of the distribution.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the triangular distribution. } \details{ Probability density function \deqn{ f(x) = \left\{\begin{array}{ll} \frac{2(x-a)}{(b-a)(c-a)} & x < c \\ \frac{2}{b-a} & x = c \\ \frac{2(b-x)}{(b-a)(b-c)} & x > c \end{array}\right. }{ f(x) = [if x < c:] (2*(x-a)) / ((b-a)*(c-a)) [if x = c:] 2/(b-a) [if x >= c:] (2*(b-x)) / ((b-a)*(b-c)) } Cumulative distribution function \deqn{ F(x) = \left\{\begin{array}{ll} \frac{(x-a)^2}{(b-a)(c-a)} & x \leq c \\ 1 - \frac{(b-x)^2}{(b-a)(b-c)} & x > c \end{array}\right. }{ F(x) = [if x <= c:] (x-a)^2 / ((b-a)*(c-a)) [if x > c:] 1 - ((b-x)^2 / ((b-a)*(b-c))) } Quantile function \deqn{ F^{-1}(p) = \left\{\begin{array}{ll} a + \sqrt{p \times (b-a)(c-a)} & p \leq \frac{c-a}{b-a} \\ b - \sqrt{(1-p)(b-a)(b-c)} & p > \frac{c-a}{b-a} \end{array}\right. }{ F^-1(p) = [if p < (c-a)/(b-a):] a + sqrt(p*(b-a)*(c-a)) [else:] b - sqrt((1-p)*(b-a)*(b-c)) } For random generation MINMAX method described by Stein and Keblis (2009) is used. } \examples{ x <- rtriang(1e5, 5, 7, 6) hist(x, 100, freq = FALSE) curve(dtriang(x, 5, 7, 6), 3, 10, n = 500, col = "red", add = TRUE) hist(ptriang(x, 5, 7, 6)) plot(ecdf(x)) curve(ptriang(x, 5, 7, 6), 3, 10, n = 500, col = "red", lwd = 2, add = TRUE) } \references{ Forbes, C., Evans, M. Hastings, N., & Peacock, B. (2011). Statistical Distributions. John Wiley & Sons. Stein, W. E., & Keblis, M. F. (2009). A new method to simulate the triangular distribution. Mathematical and computer modelling, 49(5), 1143-1147. } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/LocationScaleT.Rd0000644000176200001440000000333614532041732016317 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/location-scale-t-distribution.R \name{LocationScaleT} \alias{LocationScaleT} \alias{dlst} \alias{plst} \alias{qlst} \alias{rlst} \title{Location-scale version of the t-distribution} \usage{ dlst(x, df, mu = 0, sigma = 1, log = FALSE) plst(q, df, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) qlst(p, df, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) rlst(n, df, mu = 0, sigma = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{df}{degrees of freedom (> 0, maybe non-integer). \code{df = Inf} is allowed.} \item{mu}{vector of locations} \item{sigma}{vector of positive valued scale parameters.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function, distribution function and random generation for location-scale version of the t-distribution. Location-scale version of the t-distribution besides degrees of freedom \eqn{\nu}, is parametrized using additional parameters \eqn{\mu} for location and \eqn{\sigma} for scale (\eqn{\mu = 0} and \eqn{\sigma = 1} for standard t-distribution). } \examples{ x <- rlst(1e5, 1000, 5, 13) hist(x, 100, freq = FALSE) curve(dlst(x, 1000, 5, 13), -60, 60, col = "red", add = TRUE) hist(plst(x, 1000, 5, 13)) plot(ecdf(x)) curve(plst(x, 1000, 5, 13), -60, 60, col = "red", lwd = 2, add = TRUE) } \seealso{ \code{\link[stats]{TDist}} } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/Dirichlet.Rd0000644000176200001440000000256614532041731015365 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dirichlet-distribution.R \name{Dirichlet} \alias{Dirichlet} \alias{ddirichlet} \alias{rdirichlet} \title{Dirichlet distribution} \usage{ ddirichlet(x, alpha, log = FALSE) rdirichlet(n, alpha) } \arguments{ \item{x}{\eqn{k}-column matrix of quantiles.} \item{alpha}{\eqn{k}-values vector or \eqn{k}-column matrix; concentration parameter. Must be positive.} \item{log}{logical; if TRUE, probabilities p are given as log(p).} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density function, cumulative distribution function and random generation for the Dirichlet distribution. } \details{ Probability density function \deqn{ f(x) = \frac{\Gamma(\sum_k \alpha_k)}{\prod_k \Gamma(\alpha_k)} \prod_k x_k^{k-1} }{ f(x) = \Gamma(sum(\alpha[k])) / prod(\Gamma(\alpha[k])) * prod(x[k]^{k-1}) } } \examples{ # Generating 10 random draws from Dirichlet distribution # parametrized using a vector rdirichlet(10, c(1, 1, 1, 1)) # or parametrized using a matrix where each row # is a vector of parameters alpha <- matrix(c(1, 1, 1, 1:3, 7:9), ncol = 3, byrow = TRUE) rdirichlet(10, alpha) } \references{ Devroye, L. (1986). Non-Uniform Random Variate Generation. Springer-Verlag. } \concept{Continuous} \concept{Multivariate} \keyword{distribution} extraDistr/man/DiscreteNormal.Rd0000644000176200001440000000330114532041731016355 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/discrete-normal-distribution.R \name{DiscreteNormal} \alias{DiscreteNormal} \alias{ddnorm} \alias{pdnorm} \alias{rdnorm} \title{Discrete normal distribution} \usage{ ddnorm(x, mean = 0, sd = 1, log = FALSE) pdnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE) rdnorm(n, mean = 0, sd = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{mean}{vector of means.} \item{sd}{vector of standard deviations.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function, distribution function and random generation for discrete normal distribution. } \details{ Probability mass function \deqn{ f(x) = \Phi\left(\frac{x-\mu+1}{\sigma}\right) - \Phi\left(\frac{x-\mu}{\sigma}\right) }{ f(x) = \Phi((x-\mu+1)/\sigma) - \Phi((x-\mu)/\sigma) } Cumulative distribution function \deqn{ F(x) = \Phi\left(\frac{\lfloor x \rfloor + 1 - \mu}{\sigma}\right) }{ F(x) = \Phi((floor(x)+1-\mu)/\sigma) } } \examples{ x <- rdnorm(1e5, 0, 3) xx <- -15:15 plot(prop.table(table(x))) lines(xx, ddnorm(xx, 0, 3), col = "red") hist(pdnorm(x, 0, 3)) plot(ecdf(x)) xx <- seq(-15, 15, 0.1) lines(xx, pdnorm(xx, 0, 3), col = "red", lwd = 2, type = "s") } \references{ Roy, D. (2003). The discrete normal distribution. Communications in Statistics-Theory and Methods, 32, 1871-1883. } \seealso{ \code{\link[stats]{Normal}} } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/Bernoulli.Rd0000644000176200001440000000215514532041731015403 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/bernoulli-distribution.R \name{Bernoulli} \alias{Bernoulli} \alias{dbern} \alias{pbern} \alias{qbern} \alias{rbern} \title{Bernoulli distribution} \usage{ dbern(x, prob = 0.5, log = FALSE) pbern(q, prob = 0.5, lower.tail = TRUE, log.p = FALSE) qbern(p, prob = 0.5, lower.tail = TRUE, log.p = FALSE) rbern(n, prob = 0.5) } \arguments{ \item{x, q}{vector of quantiles.} \item{prob}{probability of success; (\code{0 < prob < 1}).} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function, distribution function, quantile function and random generation for the Bernoulli distribution. } \examples{ prop.table(table(rbern(1e5, 0.5))) } \seealso{ \code{\link[stats]{Binomial}} } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/Categorical.Rd0000644000176200001440000000655514532041731015675 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/categorical-distribution.R \name{Categorical} \alias{Categorical} \alias{dcat} \alias{pcat} \alias{qcat} \alias{rcat} \alias{rcatlp} \title{Categorical distribution} \usage{ dcat(x, prob, log = FALSE) pcat(q, prob, lower.tail = TRUE, log.p = FALSE) qcat(p, prob, lower.tail = TRUE, log.p = FALSE, labels) rcat(n, prob, labels) rcatlp(n, log_prob, labels) } \arguments{ \item{x, q}{vector of quantiles.} \item{prob, log_prob}{vector of length \eqn{m}, or \eqn{m}-column matrix of non-negative weights (or their logarithms in \code{log_prob}).} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{labels}{if provided, labeled \code{factor} vector is returned. Number of labels needs to be the same as number of categories (number of columns in prob).} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function, distribution function, quantile function and random generation for the categorical distribution. } \details{ Probability mass function \deqn{ \Pr(X = k) = \frac{w_k}{\sum_{j=1}^m w_j} }{ Pr(X = k) = w[k]/sum(w) } Cumulative distribution function \deqn{ \Pr(X \le k) = \frac{\sum_{i=1}^k w_i}{\sum_{j=1}^m w_j} }{ Pr(X <= k) = sum(w[1:k])/sum(w) } It is possible to sample from categorical distribution parametrized by vector of unnormalized log-probabilities \eqn{\alpha_1,\dots,\alpha_m}{\alpha[1],...,\alpha[m]} without leaving the log space by employing the Gumbel-max trick (Maddison, Tarlow and Minka, 2014). If \eqn{g_1,\dots,g_m}{g[1],...,g[m]} are samples from Gumbel distribution with cumulative distribution function \eqn{F(g) = \exp(-\exp(-g))}{F(g) = exp(-exp(-g))}, then \eqn{k = \mathrm{arg\,max}_i \{g_i + \alpha_i\}}{k = argmax(g[i]+\alpha[i])} is a draw from categorical distribution parametrized by vector of probabilities \eqn{p_1,\dots,p_m}{p[1]....,p[m]}, such that \eqn{p_i = \exp(\alpha_i) / [\sum_{j=1}^m \exp(\alpha_j)]}{p[i] = exp(\alpha[i])/sum(exp(\alpha))}. This is implemented in \code{rcatlp} function parametrized by vector of log-probabilities \code{log_prob}. } \examples{ # Generating 10 random draws from categorical distribution # with k=3 categories occuring with equal probabilities # parametrized using a vector rcat(10, c(1/3, 1/3, 1/3)) # or with k=5 categories parametrized using a matrix of probabilities # (generated from Dirichlet distribution) p <- rdirichlet(10, c(1, 1, 1, 1, 1)) rcat(10, p) x <- rcat(1e5, c(0.2, 0.4, 0.3, 0.1)) plot(prop.table(table(x)), type = "h") lines(0:5, dcat(0:5, c(0.2, 0.4, 0.3, 0.1)), col = "red") p <- rdirichlet(1, rep(1, 20)) x <- rcat(1e5, matrix(rep(p, 2), nrow = 2, byrow = TRUE)) xx <- 0:21 plot(prop.table(table(x))) lines(xx, dcat(xx, p), col = "red") xx <- seq(0, 21, by = 0.01) plot(ecdf(x)) lines(xx, pcat(xx, p), col = "red", lwd = 2) pp <- seq(0, 1, by = 0.001) plot(ecdf(x)) lines(qcat(pp, p), pp, col = "red", lwd = 2) } \references{ Maddison, C. J., Tarlow, D., & Minka, T. (2014). A* sampling. [In:] Advances in Neural Information Processing Systems (pp. 3086-3094). \url{https://arxiv.org/abs/1411.0030} } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/Skellam.Rd0000644000176200001440000000310514532041732015035 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/skellam-distribution.R \name{Skellam} \alias{Skellam} \alias{dskellam} \alias{rskellam} \title{Skellam distribution} \usage{ dskellam(x, mu1, mu2, log = FALSE) rskellam(n, mu1, mu2) } \arguments{ \item{x}{vector of quantiles.} \item{mu1, mu2}{positive valued parameters.} \item{log}{logical; if TRUE, probabilities p are given as log(p).} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function and random generation for the Skellam distribution. } \details{ If \eqn{X} and \eqn{Y} follow Poisson distributions with means \eqn{\mu_1}{\mu[1]} and \eqn{\mu_2}{\mu[2]}, than \eqn{X-Y} follows Skellam distribution parametrized by \eqn{\mu_1}{\mu[1]} and \eqn{\mu_2}{\mu[2]}. Probability mass function \deqn{ f(x) = e^{-(\mu_1\!+\!\mu_2)} \left(\frac{\mu_1}{\mu_2}\right)^{k/2}\!\!I_{k}(2\sqrt{\mu_1\mu_2}) }{ f(x) = exp(-(\mu1+\mu2)) * (\mu1/\mu2)^(x/2) * besselI(2*sqrt(\mu1*\mu2), x) } } \examples{ x <- rskellam(1e5, 5, 13) xx <- -40:40 plot(prop.table(table(x)), type = "h") lines(xx, dskellam(xx, 5, 13), col = "red") } \references{ Karlis, D., & Ntzoufras, I. (2006). Bayesian analysis of the differences of count data. Statistics in medicine, 25(11), 1885-1905. Skellam, J.G. (1946). The frequency distribution of the difference between two Poisson variates belonging to different populations. Journal of the Royal Statistical Society, series A, 109(3), 26. } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/man/Rayleigh.Rd0000644000176200001440000000353414532041732015217 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rayleigh-distribution.R \name{Rayleigh} \alias{Rayleigh} \alias{drayleigh} \alias{prayleigh} \alias{qrayleigh} \alias{rrayleigh} \title{Rayleigh distribution} \usage{ drayleigh(x, sigma = 1, log = FALSE) prayleigh(q, sigma = 1, lower.tail = TRUE, log.p = FALSE) qrayleigh(p, sigma = 1, lower.tail = TRUE, log.p = FALSE) rrayleigh(n, sigma = 1) } \arguments{ \item{x, q}{vector of quantiles.} \item{sigma}{positive valued parameter.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the Rayleigh distribution. } \details{ Probability density function \deqn{ f(x) = \frac{x}{\sigma^2} \exp\left(-\frac{x^2}{2\sigma^2}\right) }{ f(x) = x/\sigma^2 * exp(-(x^2 / 2*\sigma^2)) } Cumulative distribution function \deqn{ F(x) = 1 - \exp\left(-\frac{x^2}{2\sigma^2}\right) }{ F(x) = 1 - exp(-x^2 / 2*\sigma^2) } Quantile function \deqn{ F^{-1}(p) = \sqrt{-2\sigma^2 \log(1-p)} }{ F^-1(p) = sqrt(-2*\sigma^2 * log(1-p)) } } \examples{ x <- rrayleigh(1e5, 13) hist(x, 100, freq = FALSE) curve(drayleigh(x, 13), 0, 60, col = "red", add = TRUE) hist(prayleigh(x, 13)) plot(ecdf(x)) curve(prayleigh(x, 13), 0, 60, col = "red", lwd = 2, add = TRUE) } \references{ Krishnamoorthy, K. (2006). Handbook of Statistical Distributions with Applications. Chapman & Hall/CRC. Forbes, C., Evans, M. Hastings, N., & Peacock, B. (2011). Statistical Distributions. John Wiley & Sons. } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/GPD.Rd0000644000176200001440000000463214532041732014065 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/gpd-distribution.R \name{GPD} \alias{GPD} \alias{dgpd} \alias{pgpd} \alias{qgpd} \alias{rgpd} \title{Generalized Pareto distribution} \usage{ dgpd(x, mu = 0, sigma = 1, xi = 0, log = FALSE) pgpd(q, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) qgpd(p, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) rgpd(n, mu = 0, sigma = 1, xi = 0) } \arguments{ \item{x, q}{vector of quantiles.} \item{mu, sigma, xi}{location, scale, and shape parameters. Scale must be positive.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Density, distribution function, quantile function and random generation for the generalized Pareto distribution. } \details{ Probability density function \deqn{ f(x) = \left\{\begin{array}{ll} \frac{1}{\sigma} \left(1+\xi \frac{x-\mu}{\sigma}\right)^{-(\xi+1)/\xi} & \xi \neq 0 \\ \frac{1}{\sigma} \exp\left(-\frac{x-\mu}{\sigma}\right) & \xi = 0 \end{array}\right. }{ f(x) = [if \xi != 0:] (1+\xi*(x-\mu)/\sigma)^{-(\xi+1)/\xi}/\sigma [else:] exp(-(x-\mu)/\sigma)/\sigma } Cumulative distribution function \deqn{ F(x) = \left\{\begin{array}{ll} 1-\left(1+\xi \frac{x-\mu}{\sigma}\right)^{-1/\xi} & \xi \neq 0 \\ 1-\exp\left(-\frac{x-\mu}{\sigma}\right) & \xi = 0 \end{array}\right. }{ F(x) = [if \xi != 0:] 1-(1+\xi*(x-\mu)/\sigma)^{-1/\xi} [else:] 1-exp(-(x-\mu)/\sigma) } Quantile function \deqn{ F^{-1}(x) = \left\{\begin{array}{ll} \mu + \sigma \frac{(1-p)^{-\xi}-1}{\xi} & \xi \neq 0 \\ \mu - \sigma \log(1-p) & \xi = 0 \end{array}\right. }{ F^-1(x) = [if \xi != 0:] \mu + \sigma * ((1-p)^{-\xi}-1)/\xi [else:] \mu - \sigma * log(1-p) } } \examples{ x <- rgpd(1e5, 5, 2, .1) hist(x, 100, freq = FALSE, xlim = c(0, 50)) curve(dgpd(x, 5, 2, .1), 0, 50, col = "red", add = TRUE, n = 5000) hist(pgpd(x, 5, 2, .1)) plot(ecdf(x)) curve(pgpd(x, 5, 2, .1), 0, 50, col = "red", lwd = 2, add = TRUE) } \references{ Coles, S. (2001). An Introduction to Statistical Modeling of Extreme Values. Springer. } \concept{Continuous} \concept{Univariate} \keyword{distribution} extraDistr/man/NegHyper.Rd0000644000176200001440000000663714532041732015203 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/negative-hypergeometric-distribution.R \name{NegHyper} \alias{NegHyper} \alias{dnhyper} \alias{pnhyper} \alias{qnhyper} \alias{rnhyper} \title{Negative hypergeometric distribution} \usage{ dnhyper(x, n, m, r, log = FALSE) pnhyper(q, n, m, r, lower.tail = TRUE, log.p = FALSE) qnhyper(p, n, m, r, lower.tail = TRUE, log.p = FALSE) rnhyper(nn, n, m, r) } \arguments{ \item{x, q}{vector of quantiles representing the number of balls drawn without replacement from an urn which contains both black and white balls.} \item{n}{the number of black balls in the urn.} \item{m}{the number of white balls in the urn.} \item{r}{the number of white balls that needs to be drawn for the sampling to be stopped.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are \eqn{P[X \le x]} otherwise, \eqn{P[X > x]}.} \item{p}{vector of probabilities.} \item{nn}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} } \description{ Probability mass function, distribution function, quantile function and random generation for the negative hypergeometric distribution. } \details{ Negative hypergeometric distribution describes number of balls \eqn{x} observed until drawing without replacement to obtain \eqn{r} white balls from the urn containing \eqn{m} white balls and \eqn{n} black balls, and is defined as \deqn{ f(x) = \frac{{x-1 \choose r-1}{m+n-x \choose m-r}}{{m+n \choose n}} }{ f(x) = choose(x-1, r-1)*choose(m+n-x, m-r)/choose(m+n, n) } The algorithm used for calculating probability mass function, cumulative distribution function and quantile function is based on Fortran program NHYPERG created by Berry and Mielke (1996, 1998). Random generation is done by inverse transform sampling. } \examples{ x <- rnhyper(1e5, 60, 35, 15) xx <- 15:95 plot(prop.table(table(x))) lines(xx, dnhyper(xx, 60, 35, 15), col = "red") hist(pnhyper(x, 60, 35, 15)) xx <- seq(0, 100, by = 0.01) plot(ecdf(x)) lines(xx, pnhyper(xx, 60, 35, 15), col = "red", lwd = 2) } \references{ Berry, K. J., & Mielke, P. W. (1998). The negative hypergeometric probability distribution: Sampling without replacement from a finite population. Perceptual and motor skills, 86(1), 207-210. \url{https://journals.sagepub.com/doi/10.2466/pms.1998.86.1.207} Berry, K. J., & Mielke, P. W. (1996). Exact confidence limits for population proportions based on the negative hypergeometric probability distribution. Perceptual and motor skills, 83(3 suppl), 1216-1218. \url{https://journals.sagepub.com/doi/10.2466/pms.1996.83.3f.1216} Schuster, E. F., & Sype, W. R. (1987). On the negative hypergeometric distribution. International Journal of Mathematical Education in Science and Technology, 18(3), 453-459. Chae, K. C. (1993). Presenting the negative hypergeometric distribution to the introductory statistics courses. International Journal of Mathematical Education in Science and Technology, 24(4), 523-526. Jones, S.N. (2013). A Gaming Application of the Negative Hypergeometric Distribution. UNLV Theses, Dissertations, Professional Papers, and Capstones. Paper 1846. \url{https://digitalscholarship.unlv.edu/cgi/viewcontent.cgi?referer=&httpsredir=1&article=2847&context=thesesdissertations} } \seealso{ \code{\link[stats]{Hypergeometric}} } \concept{Discrete} \concept{Univariate} \keyword{distribution} extraDistr/DESCRIPTION0000755000176200001440000000336014532054172014121 0ustar liggesusersPackage: extraDistr Type: Package Title: Additional Univariate and Multivariate Distributions Version: 1.10.0 Date: 2023-12-30 Author: Tymoteusz Wolodzko Maintainer: Tymoteusz Wolodzko Description: Density, distribution function, quantile function and random generation for a number of univariate and multivariate distributions. This package implements the following distributions: Bernoulli, beta-binomial, beta-negative binomial, beta prime, Bhattacharjee, Birnbaum-Saunders, bivariate normal, bivariate Poisson, categorical, Dirichlet, Dirichlet-multinomial, discrete gamma, discrete Laplace, discrete normal, discrete uniform, discrete Weibull, Frechet, gamma-Poisson, generalized extreme value, Gompertz, generalized Pareto, Gumbel, half-Cauchy, half-normal, half-t, Huber density, inverse chi-squared, inverse-gamma, Kumaraswamy, Laplace, location-scale t, logarithmic, Lomax, multivariate hypergeometric, multinomial, negative hypergeometric, non-standard beta, normal mixture, Poisson mixture, Pareto, power, reparametrized beta, Rayleigh, shifted Gompertz, Skellam, slash, triangular, truncated binomial, truncated normal, truncated Poisson, Tukey lambda, Wald, zero-inflated binomial, zero-inflated negative binomial, zero-inflated Poisson. License: GPL-2 URL: https://github.com/twolodzko/extraDistr BugReports: https://github.com/twolodzko/extraDistr/issues Encoding: UTF-8 Depends: R (>= 3.1.0) LinkingTo: Rcpp Imports: Rcpp Suggests: testthat, LaplacesDemon, VGAM, evd, skellam, triangle, actuar SystemRequirements: C++ RoxygenNote: 7.2.3 NeedsCompilation: yes Packaged: 2023-11-30 08:49:53 UTC; tymek Repository: CRAN Date/Publication: 2023-11-30 09:40:10 UTC extraDistr/tests/0000755000176200001440000000000014475546572013570 5ustar liggesusersextraDistr/tests/testthat/0000755000176200001440000000000014532054172015410 5ustar liggesusersextraDistr/tests/testthat/test-zero-length.R0000755000176200001440000010413014475546572020770 0ustar liggesusers is_zero_length <- function(x) length(x) == 0L test_that("Zero-length in PDF and PMF functions", { expect_true(is_zero_length(dbbinom(numeric(0), 1, 1, 1))) expect_true(is_zero_length(dbbinom(1, numeric(0), 1, 1))) expect_true(is_zero_length(dbbinom(1, 1, numeric(0), 1))) expect_true(is_zero_length(dbbinom(1, 1, 1, numeric(0)))) expect_true(is_zero_length(dbern(numeric(0), 0.5))) expect_true(is_zero_length(dbern(1, numeric(0)))) expect_true(is_zero_length(dbetapr(numeric(0), 1, 1, 1))) expect_true(is_zero_length(dbetapr(1, numeric(0), 1, 1))) expect_true(is_zero_length(dbetapr(1, 1, numeric(0), 1))) expect_true(is_zero_length(dbetapr(1, 1, 1, numeric(0)))) expect_true(is_zero_length(dbhatt(numeric(0), 1, 1, 1))) expect_true(is_zero_length(dbhatt(1, numeric(0), 1, 1))) expect_true(is_zero_length(dbhatt(1, 1, numeric(0), 1))) expect_true(is_zero_length(dbhatt(1, 1, 1, numeric(0)))) expect_true(is_zero_length(dbnbinom(numeric(0), 1, 1, 1))) expect_true(is_zero_length(dbnbinom(1, numeric(0), 1, 1))) expect_true(is_zero_length(dbnbinom(1, 1, numeric(0), 1))) expect_true(is_zero_length(dbnbinom(1, 1, 1, numeric(0)))) expect_true(is_zero_length(dbvnorm(numeric(0), 1, 1, 1, 1, 1, 0.5))) expect_true(is_zero_length(dbvnorm(1, numeric(0), 1, 1, 1, 1, 0.5))) expect_true(is_zero_length(dbvnorm(1, 1, numeric(0), 1, 1, 1, 0.5))) expect_true(is_zero_length(dbvnorm(1, 1, 1, numeric(0), 1, 1, 0.5))) expect_true(is_zero_length(dbvnorm(1, 1, 1, 1, numeric(0), 1, 0.5))) expect_true(is_zero_length(dbvnorm(1, 1, 1, 1, 1, numeric(0), 0.5))) expect_true(is_zero_length(dbvnorm(1, 1, 1, 1, 1, 1, numeric(0)))) expect_true(is_zero_length(dbvpois(numeric(0), 1, 1, 1, 1))) expect_true(is_zero_length(dbvpois(1, numeric(0), 1, 1, 1))) expect_true(is_zero_length(dbvpois(1, 1, numeric(0), 1, 1))) expect_true(is_zero_length(dbvpois(1, 1, 1, numeric(0), 1))) expect_true(is_zero_length(dbvpois(1, 1, 1, 1, numeric(0)))) expect_true(is_zero_length(dcat(numeric(0), c(0.5, 0.5)))) expect_true(is_zero_length(dcat(1, numeric(0)))) expect_true(is_zero_length(dcat(1, matrix(1, 0, 0)))) expect_true(is_zero_length(ddirichlet(numeric(0), c(0.5, 0.5)))) expect_true(is_zero_length(ddirichlet(c(0.5, 0.5), numeric(0)))) expect_true(is_zero_length(ddlaplace(numeric(0), 1, 1))) expect_true(is_zero_length(ddlaplace(1, numeric(0), 1))) expect_true(is_zero_length(ddlaplace(1, 1, numeric(0)))) expect_true(is_zero_length(ddnorm(numeric(0), 1, 1))) expect_true(is_zero_length(ddnorm(1, numeric(0), 1))) expect_true(is_zero_length(ddnorm(1, 1, numeric(0)))) expect_true(is_zero_length(ddgamma(numeric(0), 9, 1))) expect_true(is_zero_length(ddgamma(1, numeric(0), 1))) expect_true(is_zero_length(ddgamma(1, 9, numeric(0)))) expect_true(is_zero_length(ddunif(numeric(0), 1, 10))) expect_true(is_zero_length(ddunif(1, numeric(0), 10))) expect_true(is_zero_length(ddunif(1, 1, numeric(0)))) expect_true(is_zero_length(ddweibull(numeric(0), 1, 1))) expect_true(is_zero_length(ddweibull(1, numeric(0), 1))) expect_true(is_zero_length(ddweibull(1, 1, numeric(0)))) expect_true(is_zero_length(dfatigue(numeric(0), 1, 1))) expect_true(is_zero_length(dfatigue(1, numeric(0), 1))) expect_true(is_zero_length(dfatigue(1, 1, numeric(0)))) expect_true(is_zero_length(dfrechet(numeric(0), 1, 1, 1))) expect_true(is_zero_length(dfrechet(1, numeric(0), 1, 1))) expect_true(is_zero_length(dfrechet(1, 1, numeric(0), 1))) expect_true(is_zero_length(dfrechet(1, 1, 1, numeric(0)))) expect_true(is_zero_length(dgev(numeric(0), 1, 1, 1))) expect_true(is_zero_length(dgev(1, numeric(0), 1, 1))) expect_true(is_zero_length(dgev(1, 1, numeric(0), 1))) expect_true(is_zero_length(dgev(1, 1, 1, numeric(0)))) expect_true(is_zero_length(dgompertz(numeric(0), 1, 1))) expect_true(is_zero_length(dgompertz(1, numeric(0), 1))) expect_true(is_zero_length(dgompertz(1, 1, numeric(0)))) expect_true(is_zero_length(dgpd(numeric(0), 1, 1, 1))) expect_true(is_zero_length(dgpd(1, numeric(0), 1, 1))) expect_true(is_zero_length(dgpd(1, 1, numeric(0), 1))) expect_true(is_zero_length(dgpd(1, 1, 1, numeric(0)))) expect_true(is_zero_length(dgpois(numeric(0), 1, 1))) expect_true(is_zero_length(dgpois(1, numeric(0), 1))) expect_true(is_zero_length(dgpois(1, 1, numeric(0)))) expect_true(is_zero_length(dgumbel(numeric(0), 1, 1))) expect_true(is_zero_length(dgumbel(1, numeric(0), 1))) expect_true(is_zero_length(dgumbel(1, 1, numeric(0)))) expect_true(is_zero_length(dhcauchy(numeric(0), 1))) expect_true(is_zero_length(dhcauchy(1, numeric(0)))) expect_true(is_zero_length(dhnorm(numeric(0), 1))) expect_true(is_zero_length(dhnorm(1, numeric(0)))) expect_true(is_zero_length(dht(numeric(0), 5, 1))) expect_true(is_zero_length(dht(1, numeric(0), 1))) expect_true(is_zero_length(dht(1, 5, numeric(0)))) expect_true(is_zero_length(dhuber(numeric(0), 0, 1, 1))) expect_true(is_zero_length(dhuber(1, numeric(0), 1, 1))) expect_true(is_zero_length(dhuber(1, 0, numeric(0), 1))) expect_true(is_zero_length(dhuber(1, 0, 1, numeric(0)))) expect_true(is_zero_length(dinvgamma(numeric(0), 1, 1))) expect_true(is_zero_length(dinvgamma(1, numeric(0), 1))) expect_true(is_zero_length(dinvgamma(1, 1, numeric(0)))) expect_true(is_zero_length(dinvchisq(numeric(0), 1, 1))) expect_true(is_zero_length(dinvchisq(1, numeric(0), 1))) expect_true(is_zero_length(dinvchisq(1, 1, numeric(0)))) expect_true(is_zero_length(dkumar(numeric(0), 1, 1))) expect_true(is_zero_length(dkumar(0.5, numeric(0), 1))) expect_true(is_zero_length(dkumar(0.5, 1, numeric(0)))) expect_true(is_zero_length(dlaplace(numeric(0), 0, 1))) expect_true(is_zero_length(dlaplace(1, numeric(0), 1))) expect_true(is_zero_length(dlaplace(1, 0, numeric(0)))) expect_true(is_zero_length(dlgser(numeric(0), 0.5))) expect_true(is_zero_length(dlgser(1, numeric(0)))) expect_true(is_zero_length(dlomax(numeric(0), 1, 1))) expect_true(is_zero_length(dlomax(1, numeric(0), 1))) expect_true(is_zero_length(dlomax(1, 1, numeric(0)))) expect_true(is_zero_length(dmixnorm(numeric(0), c(1,2,3), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is_zero_length(dmixnorm(0, numeric(0), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is_zero_length(dmixnorm(0, c(1,2,3), numeric(0), c(1/3,1/3,1/3)))) expect_true(is_zero_length(dmixnorm(0, c(1,2,3), c(1,2,3), numeric(0)))) expect_true(is_zero_length(dmixpois(numeric(0), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is_zero_length(dmixpois(0, numeric(0), c(1/3,1/3,1/3)))) expect_true(is_zero_length(dmixpois(0, c(1,2,3), numeric(0)))) expect_true(is_zero_length(dnhyper(numeric(0), 60, 35, 15))) expect_true(is_zero_length(dnhyper(1, numeric(0), 35, 15))) expect_true(is_zero_length(dnhyper(1, 60, numeric(0), 15))) expect_true(is_zero_length(dnhyper(1, 60, 35, numeric(0)))) expect_true(is_zero_length(ddirmnom(numeric(0), 3, c(1, 1, 1)))) expect_true(is_zero_length(ddirmnom(c(1, 1, 1), numeric(0), c(1, 1, 1)))) expect_true(is_zero_length(ddirmnom(c(1, 1, 1), 3, numeric(0)))) expect_true(is_zero_length(dmnom(numeric(0), 3, c(1/3, 1/3, 1/3)))) expect_true(is_zero_length(dmnom(c(1, 1, 1), numeric(0), c(1/3, 1/3, 1/3)))) expect_true(is_zero_length(dmnom(c(1, 1, 1), 3, numeric(0)))) expect_true(is_zero_length(dmvhyper(numeric(0), c(2,3,4), 5))) expect_true(is_zero_length(dmvhyper(c(1, 2, 2), numeric(0), 5))) expect_true(is_zero_length(dmvhyper(c(1, 2, 2), c(2,3,4), numeric(0)))) expect_true(is_zero_length(dnsbeta(numeric(0), 1, 1, -2, 2))) expect_true(is_zero_length(dnsbeta(0.5, numeric(0), 1, -2, 2))) expect_true(is_zero_length(dnsbeta(0.5, 1, numeric(0), -2, 2))) expect_true(is_zero_length(dnsbeta(0.5, 1, 1, numeric(0), 2))) expect_true(is_zero_length(dnsbeta(0.5, 1, 1, -2, numeric(0)))) expect_true(is_zero_length(dlst(numeric(0), 2, 0, 1))) expect_true(is_zero_length(dlst(1, numeric(0), 0, 1))) expect_true(is_zero_length(dlst(1, 2, numeric(0), 1))) expect_true(is_zero_length(dlst(1, 2, 0, numeric(0)))) expect_true(is_zero_length(dpareto(numeric(0), 1, 1))) expect_true(is_zero_length(dpareto(1, numeric(0), 1))) expect_true(is_zero_length(dpareto(1, 1, numeric(0)))) expect_true(is_zero_length(dprop(numeric(0), 10, 0.5))) expect_true(is_zero_length(dprop(1, numeric(0), 0.5))) expect_true(is_zero_length(dprop(1, 10, numeric(0)))) expect_true(is_zero_length(drayleigh(numeric(0), 1))) expect_true(is_zero_length(drayleigh(1, numeric(0)))) expect_true(is_zero_length(dskellam(numeric(0), 1, 1))) expect_true(is_zero_length(dskellam(1, numeric(0), 1))) expect_true(is_zero_length(dskellam(1, 1, numeric(0)))) expect_true(is_zero_length(dsgomp(numeric(0), 0.4, 1))) expect_true(is_zero_length(dsgomp(1, numeric(0), 1))) expect_true(is_zero_length(dsgomp(1, 0.4, numeric(0)))) expect_true(is_zero_length(dslash(numeric(0), 1, 1))) expect_true(is_zero_length(dslash(1, numeric(0), 1))) expect_true(is_zero_length(dslash(1, 1, numeric(0)))) expect_true(is_zero_length(dtnorm(numeric(0), 0, 1, -2, 2))) expect_true(is_zero_length(dtnorm(1, numeric(0), 1, -2, 2))) expect_true(is_zero_length(dtnorm(1, 0, numeric(0), -2, 2))) expect_true(is_zero_length(dtnorm(1, 0, 1, numeric(0), 2))) expect_true(is_zero_length(dtnorm(1, 0, 1, -2, numeric(0)))) expect_true(is_zero_length(dtpois(numeric(0), 5, 0))) expect_true(is_zero_length(dtpois(1, numeric(0), 0))) expect_true(is_zero_length(dtpois(1, 5, numeric(0)))) expect_true(is_zero_length(dtriang(numeric(0), 0, 1, 0.5))) expect_true(is_zero_length(dtriang(0.5, numeric(0), 1, 0.5))) expect_true(is_zero_length(dtriang(0.5, 0, numeric(0), 0.5))) expect_true(is_zero_length(dtriang(0.5, 0, 1, numeric(0)))) expect_true(is_zero_length(dwald(numeric(0), 1, 1))) expect_true(is_zero_length(dwald(1, numeric(0), 1))) expect_true(is_zero_length(dwald(1, 1, numeric(0)))) expect_true(is_zero_length(dzip(numeric(0), 1, 0.5))) expect_true(is_zero_length(dzip(1, numeric(0), 0.5))) expect_true(is_zero_length(dzip(1, 1, numeric(0)))) expect_true(is_zero_length(dzib(numeric(0), 1, 0.5, 0.5))) expect_true(is_zero_length(dzib(1, numeric(0), 0.5, 0.5))) expect_true(is_zero_length(dzib(1, 1, numeric(0), 0.5))) expect_true(is_zero_length(dzib(1, 1, 0.5, numeric(0)))) expect_true(is_zero_length(dzinb(numeric(0), 1, 0.5, 0.5))) expect_true(is_zero_length(dzinb(1, numeric(0), 0.5, 0.5))) expect_true(is_zero_length(dzinb(1, 1, numeric(0), 0.5))) expect_true(is_zero_length(dzinb(1, 1, 0.5, numeric(0)))) }) test_that("Zero-length in CDF functions", { expect_true(is_zero_length(pbbinom(numeric(0), 1, 1, 1))) expect_true(is_zero_length(pbbinom(1, numeric(0), 1, 1))) expect_true(is_zero_length(pbbinom(1, 1, numeric(0), 1))) expect_true(is_zero_length(pbbinom(1, 1, 1, numeric(0)))) expect_true(is_zero_length(pbern(numeric(0), 0.5))) expect_true(is_zero_length(pbern(1, numeric(0)))) expect_true(is_zero_length(pbetapr(numeric(0), 1, 1, 1))) expect_true(is_zero_length(pbetapr(1, numeric(0), 1, 1))) expect_true(is_zero_length(pbetapr(1, 1, numeric(0), 1))) expect_true(is_zero_length(pbetapr(1, 1, 1, numeric(0)))) expect_true(is_zero_length(pbhatt(numeric(0), 1, 1, 1))) expect_true(is_zero_length(pbhatt(1, numeric(0), 1, 1))) expect_true(is_zero_length(pbhatt(1, 1, numeric(0), 1))) expect_true(is_zero_length(pbhatt(1, 1, 1, numeric(0)))) expect_true(is_zero_length(pbnbinom(numeric(0), 1, 1, 1))) expect_true(is_zero_length(pbnbinom(1, numeric(0), 1, 1))) expect_true(is_zero_length(pbnbinom(1, 1, numeric(0), 1))) expect_true(is_zero_length(pbnbinom(1, 1, 1, numeric(0)))) expect_true(is_zero_length(pcat(numeric(0), c(0.5, 0.5)))) expect_true(is_zero_length(pcat(1, numeric(0)))) expect_true(is_zero_length(pcat(1, matrix(1, 0, 0)))) expect_true(is_zero_length(pdlaplace(numeric(0), 1, 1))) expect_true(is_zero_length(pdlaplace(1, numeric(0), 1))) expect_true(is_zero_length(pdlaplace(1, 1, numeric(0)))) expect_true(is_zero_length(pdnorm(numeric(0), 1, 1))) expect_true(is_zero_length(pdnorm(1, numeric(0), 1))) expect_true(is_zero_length(pdnorm(1, 1, numeric(0)))) expect_true(is_zero_length(pdgamma(numeric(0), 9, 1))) expect_true(is_zero_length(pdgamma(1, numeric(0), 1))) expect_true(is_zero_length(pdgamma(1, 9, numeric(0)))) expect_true(is_zero_length(pdunif(numeric(0), 1, 10))) expect_true(is_zero_length(pdunif(1, numeric(0), 10))) expect_true(is_zero_length(pdunif(1, 1, numeric(0)))) expect_true(is_zero_length(pdweibull(numeric(0), 1, 1))) expect_true(is_zero_length(pdweibull(1, numeric(0), 1))) expect_true(is_zero_length(pdweibull(1, 1, numeric(0)))) expect_true(is_zero_length(pfatigue(numeric(0), 1, 1))) expect_true(is_zero_length(pfatigue(1, numeric(0), 1))) expect_true(is_zero_length(pfatigue(1, 1, numeric(0)))) expect_true(is_zero_length(pfrechet(numeric(0), 1, 1, 1))) expect_true(is_zero_length(pfrechet(1, numeric(0), 1, 1))) expect_true(is_zero_length(pfrechet(1, 1, numeric(0), 1))) expect_true(is_zero_length(pfrechet(1, 1, 1, numeric(0)))) expect_true(is_zero_length(pgev(numeric(0), 1, 1, 1))) expect_true(is_zero_length(pgev(1, numeric(0), 1, 1))) expect_true(is_zero_length(pgev(1, 1, numeric(0), 1))) expect_true(is_zero_length(pgev(1, 1, 1, numeric(0)))) expect_true(is_zero_length(pgompertz(numeric(0), 1, 1))) expect_true(is_zero_length(pgompertz(1, numeric(0), 1))) expect_true(is_zero_length(pgompertz(1, 1, numeric(0)))) expect_true(is_zero_length(pgpd(numeric(0), 1, 1, 1))) expect_true(is_zero_length(pgpd(1, numeric(0), 1, 1))) expect_true(is_zero_length(pgpd(1, 1, numeric(0), 1))) expect_true(is_zero_length(pgpd(1, 1, 1, numeric(0)))) expect_true(is_zero_length(pgpois(numeric(0), 1, 1))) expect_true(is_zero_length(pgpois(1, numeric(0), 1))) expect_true(is_zero_length(pgpois(1, 1, numeric(0)))) expect_true(is_zero_length(pgumbel(numeric(0), 1, 1))) expect_true(is_zero_length(pgumbel(1, numeric(0), 1))) expect_true(is_zero_length(pgumbel(1, 1, numeric(0)))) expect_true(is_zero_length(phcauchy(numeric(0), 1))) expect_true(is_zero_length(phcauchy(1, numeric(0)))) expect_true(is_zero_length(phnorm(numeric(0), 1))) expect_true(is_zero_length(phnorm(1, numeric(0)))) expect_true(is_zero_length(pht(numeric(0), 5, 1))) expect_true(is_zero_length(pht(1, numeric(0), 1))) expect_true(is_zero_length(pht(1, 5, numeric(0)))) expect_true(is_zero_length(phuber(numeric(0), 0, 1, 1))) expect_true(is_zero_length(phuber(1, numeric(0), 1, 1))) expect_true(is_zero_length(phuber(1, 0, numeric(0), 1))) expect_true(is_zero_length(phuber(1, 0, 1, numeric(0)))) expect_true(is_zero_length(pinvgamma(numeric(0), 1, 1))) expect_true(is_zero_length(pinvgamma(1, numeric(0), 1))) expect_true(is_zero_length(pinvgamma(1, 1, numeric(0)))) expect_true(is_zero_length(pinvchisq(numeric(0), 1, 1))) expect_true(is_zero_length(pinvchisq(1, numeric(0), 1))) expect_true(is_zero_length(pinvchisq(1, 1, numeric(0)))) expect_true(is_zero_length(pkumar(numeric(0), 1, 1))) expect_true(is_zero_length(pkumar(0.5, numeric(0), 1))) expect_true(is_zero_length(pkumar(0.5, 1, numeric(0)))) expect_true(is_zero_length(plaplace(numeric(0), 0, 1))) expect_true(is_zero_length(plaplace(1, numeric(0), 1))) expect_true(is_zero_length(plaplace(1, 0, numeric(0)))) expect_true(is_zero_length(plgser(numeric(0), 0.5))) expect_true(is_zero_length(plgser(1, numeric(0)))) expect_true(is_zero_length(plomax(numeric(0), 1, 1))) expect_true(is_zero_length(plomax(1, numeric(0), 1))) expect_true(is_zero_length(plomax(1, 1, numeric(0)))) expect_true(is_zero_length(pmixnorm(numeric(0), c(1,2,3), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is_zero_length(pmixnorm(0, numeric(0), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is_zero_length(pmixnorm(0, c(1,2,3), numeric(0), c(1/3,1/3,1/3)))) expect_true(is_zero_length(pmixnorm(0, c(1,2,3), c(1,2,3), numeric(0)))) expect_true(is_zero_length(pmixpois(numeric(0), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is_zero_length(pmixpois(0, numeric(0), c(1/3,1/3,1/3)))) expect_true(is_zero_length(pmixpois(0, c(1,2,3), numeric(0)))) expect_true(is_zero_length(pnhyper(numeric(0), 60, 35, 15))) expect_true(is_zero_length(pnhyper(1, numeric(0), 35, 15))) expect_true(is_zero_length(pnhyper(1, 60, numeric(0), 15))) expect_true(is_zero_length(pnhyper(1, 60, 35, numeric(0)))) expect_true(is_zero_length(pnsbeta(numeric(0), 1, 1, -2, 2))) expect_true(is_zero_length(pnsbeta(0.5, numeric(0), 1, -2, 2))) expect_true(is_zero_length(pnsbeta(0.5, 1, numeric(0), -2, 2))) expect_true(is_zero_length(pnsbeta(0.5, 1, 1, numeric(0), 2))) expect_true(is_zero_length(pnsbeta(0.5, 1, 1, -2, numeric(0)))) expect_true(is_zero_length(plst(numeric(0), 2, 0, 1))) expect_true(is_zero_length(plst(1, numeric(0), 0, 1))) expect_true(is_zero_length(plst(1, 2, numeric(0), 1))) expect_true(is_zero_length(plst(1, 2, 0, numeric(0)))) expect_true(is_zero_length(ppareto(numeric(0), 1, 1))) expect_true(is_zero_length(ppareto(1, numeric(0), 1))) expect_true(is_zero_length(ppareto(1, 1, numeric(0)))) expect_true(is_zero_length(pprop(numeric(0), 10, 0.5))) expect_true(is_zero_length(pprop(1, numeric(0), 0.5))) expect_true(is_zero_length(pprop(1, 10, numeric(0)))) expect_true(is_zero_length(prayleigh(numeric(0), 1))) expect_true(is_zero_length(prayleigh(1, numeric(0)))) expect_true(is_zero_length(psgomp(numeric(0), 0.4, 1))) expect_true(is_zero_length(psgomp(1, numeric(0), 1))) expect_true(is_zero_length(psgomp(1, 0.4, numeric(0)))) expect_true(is_zero_length(pslash(numeric(0), 1, 1))) expect_true(is_zero_length(pslash(1, numeric(0), 1))) expect_true(is_zero_length(pslash(1, 1, numeric(0)))) expect_true(is_zero_length(ptnorm(numeric(0), 0, 1, -2, 2))) expect_true(is_zero_length(ptnorm(1, numeric(0), 1, -2, 2))) expect_true(is_zero_length(ptnorm(1, 0, numeric(0), -2, 2))) expect_true(is_zero_length(ptnorm(1, 0, 1, numeric(0), 2))) expect_true(is_zero_length(ptnorm(1, 0, 1, -2, numeric(0)))) expect_true(is_zero_length(ptpois(numeric(0), 5, 0))) expect_true(is_zero_length(ptpois(1, numeric(0), 0))) expect_true(is_zero_length(ptpois(1, 5, numeric(0)))) expect_true(is_zero_length(ptriang(numeric(0), 0, 1, 0.5))) expect_true(is_zero_length(ptriang(0.5, numeric(0), 1, 0.5))) expect_true(is_zero_length(ptriang(0.5, 0, numeric(0), 0.5))) expect_true(is_zero_length(ptriang(0.5, 0, 1, numeric(0)))) expect_true(is_zero_length(pwald(numeric(0), 1, 1))) expect_true(is_zero_length(pwald(1, numeric(0), 1))) expect_true(is_zero_length(pwald(1, 1, numeric(0)))) expect_true(is_zero_length(pzip(numeric(0), 1, 0.5))) expect_true(is_zero_length(pzip(1, numeric(0), 0.5))) expect_true(is_zero_length(pzip(1, 1, numeric(0)))) expect_true(is_zero_length(pzib(numeric(0), 1, 0.5, 0.5))) expect_true(is_zero_length(pzib(1, numeric(0), 0.5, 0.5))) expect_true(is_zero_length(pzib(1, 1, numeric(0), 0.5))) expect_true(is_zero_length(pzib(1, 1, 0.5, numeric(0)))) expect_true(is_zero_length(pzinb(numeric(0), 1, 0.5, 0.5))) expect_true(is_zero_length(pzinb(1, numeric(0), 0.5, 0.5))) expect_true(is_zero_length(pzinb(1, 1, numeric(0), 0.5))) expect_true(is_zero_length(pzinb(1, 1, 0.5, numeric(0)))) }) test_that("Zero-length in inverse CDF functions", { expect_true(is_zero_length(qbern(numeric(0), 0.5))) expect_true(is_zero_length(qbern(0.5, numeric(0)))) expect_true(is_zero_length(qbetapr(numeric(0), 1, 1, 1))) expect_true(is_zero_length(qbetapr(0.5, numeric(0), 1, 1))) expect_true(is_zero_length(qbetapr(0.5, 1, numeric(0), 1))) expect_true(is_zero_length(qbetapr(0.5, 1, 1, numeric(0)))) expect_true(is_zero_length(qcat(numeric(0), c(0.5, 0.5)))) expect_true(is_zero_length(qcat(0.5, numeric(0)))) expect_true(is_zero_length(qcat(0.5, matrix(1, 0, 0)))) expect_true(is_zero_length(qdunif(numeric(0), 1, 10))) expect_true(is_zero_length(qdunif(0.5, numeric(0), 10))) expect_true(is_zero_length(qdunif(0.5, 1, numeric(0)))) expect_true(is_zero_length(qdweibull(numeric(0), 1, 1))) expect_true(is_zero_length(qdweibull(0.5, numeric(0), 1))) expect_true(is_zero_length(qdweibull(0.5, 1, numeric(0)))) expect_true(is_zero_length(qfatigue(numeric(0), 1, 1))) expect_true(is_zero_length(qfatigue(0.5, numeric(0), 1))) expect_true(is_zero_length(qfatigue(0.5, 1, numeric(0)))) expect_true(is_zero_length(qfrechet(numeric(0), 1, 1, 1))) expect_true(is_zero_length(qfrechet(0.5, numeric(0), 1, 1))) expect_true(is_zero_length(qfrechet(0.5, 1, numeric(0), 1))) expect_true(is_zero_length(qfrechet(0.5, 1, 1, numeric(0)))) expect_true(is_zero_length(qgev(numeric(0), 1, 1, 1))) expect_true(is_zero_length(qgev(0.5, numeric(0), 1, 1))) expect_true(is_zero_length(qgev(0.5, 1, numeric(0), 1))) expect_true(is_zero_length(qgev(0.5, 1, 1, numeric(0)))) expect_true(is_zero_length(qgompertz(numeric(0), 1, 1))) expect_true(is_zero_length(qgompertz(0.5, numeric(0), 1))) expect_true(is_zero_length(qgompertz(0.5, 1, numeric(0)))) expect_true(is_zero_length(qgpd(numeric(0), 1, 1, 1))) expect_true(is_zero_length(qgpd(0.5, numeric(0), 1, 1))) expect_true(is_zero_length(qgpd(0.5, 1, numeric(0), 1))) expect_true(is_zero_length(qgpd(0.5, 1, 1, numeric(0)))) expect_true(is_zero_length(qgumbel(numeric(0), 1, 1))) expect_true(is_zero_length(qgumbel(0.5, numeric(0), 1))) expect_true(is_zero_length(qgumbel(0.5, 1, numeric(0)))) expect_true(is_zero_length(qhcauchy(numeric(0), 1))) expect_true(is_zero_length(qhcauchy(0.5, numeric(0)))) expect_true(is_zero_length(qhnorm(numeric(0), 1))) expect_true(is_zero_length(qhnorm(0.5, numeric(0)))) expect_true(is_zero_length(qht(numeric(0), 5, 1))) expect_true(is_zero_length(qht(0.5, numeric(0), 1))) expect_true(is_zero_length(qht(0.5, 5, numeric(0)))) expect_true(is_zero_length(qhuber(numeric(0), 0, 1, 1))) expect_true(is_zero_length(qhuber(0.5, numeric(0), 1, 1))) expect_true(is_zero_length(qhuber(0.5, 0, numeric(0), 1))) expect_true(is_zero_length(qhuber(0.5, 0, 1, numeric(0)))) expect_true(is_zero_length(qinvgamma(numeric(0), 1, 1))) expect_true(is_zero_length(qinvgamma(0.5, numeric(0), 1))) expect_true(is_zero_length(qinvgamma(0.5, 1, numeric(0)))) expect_true(is_zero_length(qinvchisq(numeric(0), 1, 1))) expect_true(is_zero_length(qinvchisq(0.5, numeric(0), 1))) expect_true(is_zero_length(qinvchisq(0.5, 1, numeric(0)))) expect_true(is_zero_length(qkumar(numeric(0), 1, 1))) expect_true(is_zero_length(qkumar(0.5, numeric(0), 1))) expect_true(is_zero_length(qkumar(0.5, 1, numeric(0)))) expect_true(is_zero_length(qlaplace(numeric(0), 0, 1))) expect_true(is_zero_length(qlaplace(0.5, numeric(0), 1))) expect_true(is_zero_length(qlaplace(0.5, 0, numeric(0)))) expect_true(is_zero_length(qlgser(numeric(0), 0.5))) expect_true(is_zero_length(qlgser(0.5, numeric(0)))) expect_true(is_zero_length(qlomax(numeric(0), 1, 1))) expect_true(is_zero_length(qlomax(0.5, numeric(0), 1))) expect_true(is_zero_length(qlomax(0.5, 1, numeric(0)))) expect_true(is_zero_length(qnhyper(numeric(0), 60, 35, 15))) expect_true(is_zero_length(qnhyper(0.5, numeric(0), 35, 15))) expect_true(is_zero_length(qnhyper(0.5, 60, numeric(0), 15))) expect_true(is_zero_length(qnhyper(0.5, 60, 35, numeric(0)))) expect_true(is_zero_length(qnsbeta(numeric(0), 1, 1, -2, 2))) expect_true(is_zero_length(qnsbeta(0.5, numeric(0), 1, -2, 2))) expect_true(is_zero_length(qnsbeta(0.5, 1, numeric(0), -2, 2))) expect_true(is_zero_length(qnsbeta(0.5, 1, 1, numeric(0), 2))) expect_true(is_zero_length(qnsbeta(0.5, 1, 1, -2, numeric(0)))) expect_true(is_zero_length(qlst(numeric(0), 2, 0, 1))) expect_true(is_zero_length(qlst(0.5, numeric(0), 0, 1))) expect_true(is_zero_length(qlst(0.5, 2, numeric(0), 1))) expect_true(is_zero_length(qlst(0.5, 2, 0, numeric(0)))) expect_true(is_zero_length(qpareto(numeric(0), 1, 1))) expect_true(is_zero_length(qpareto(0.5, numeric(0), 1))) expect_true(is_zero_length(qpareto(0.5, 1, numeric(0)))) expect_true(is_zero_length(qprop(numeric(0), 10, 0.5))) expect_true(is_zero_length(qprop(0.5, numeric(0), 0.5))) expect_true(is_zero_length(qprop(0.5, 10, numeric(0)))) expect_true(is_zero_length(qrayleigh(numeric(0), 1))) expect_true(is_zero_length(qrayleigh(0.5, numeric(0)))) expect_true(is_zero_length(qtlambda(numeric(0), 0.5))) expect_true(is_zero_length(qtlambda(0, numeric(0)))) expect_true(is_zero_length(qtnorm(numeric(0), 0, 1, -2, 2))) expect_true(is_zero_length(qtnorm(0.5, numeric(0), 1, -2, 2))) expect_true(is_zero_length(qtnorm(0.5, 0, numeric(0), -2, 2))) expect_true(is_zero_length(qtnorm(0.5, 0, 1, numeric(0), 2))) expect_true(is_zero_length(qtnorm(0.5, 0, 1, -2, numeric(0)))) expect_true(is_zero_length(qtpois(numeric(0), 5, 0))) expect_true(is_zero_length(qtpois(0.5, numeric(0), 0))) expect_true(is_zero_length(qtpois(0.5, 5, numeric(0)))) expect_true(is_zero_length(qtriang(numeric(0), 0, 1, 0.5))) expect_true(is_zero_length(qtriang(0.5, numeric(0), 1, 0.5))) expect_true(is_zero_length(qtriang(0.5, 0, numeric(0), 0.5))) expect_true(is_zero_length(qtriang(0.5, 0, 1, numeric(0)))) expect_true(is_zero_length(qzip(numeric(0), 1, 0.5))) expect_true(is_zero_length(qzip(0.5, numeric(0), 0.5))) expect_true(is_zero_length(qzip(0.5, 1, numeric(0)))) expect_true(is_zero_length(qzib(numeric(0), 1, 0.5, 0.5))) expect_true(is_zero_length(qzib(0.5, numeric(0), 0.5, 0.5))) expect_true(is_zero_length(qzib(0.5, 1, numeric(0), 0.5))) expect_true(is_zero_length(qzib(0.5, 1, 0.5, numeric(0)))) expect_true(is_zero_length(qzinb(numeric(0), 1, 0.5, 0.5))) expect_true(is_zero_length(qzinb(0.5, numeric(0), 0.5, 0.5))) expect_true(is_zero_length(qzinb(0.5, 1, numeric(0), 0.5))) expect_true(is_zero_length(qzinb(0.5, 1, 0.5, numeric(0)))) }) test_that("Zero-length in RNG functions", { expect_warning(expect_true(is.na(rbbinom(1, numeric(0), 1, 1)))) expect_warning(expect_true(is.na(rbbinom(1, 1, numeric(0), 1)))) expect_warning(expect_true(is.na(rbbinom(1, 1, 1, numeric(0))))) expect_warning(expect_true(is.na(rbern(1, numeric(0))))) expect_warning(expect_true(is.na(rbetapr(1, numeric(0), 1, 1)))) expect_warning(expect_true(is.na(rbetapr(1, 1, numeric(0), 1)))) expect_warning(expect_true(is.na(rbetapr(1, 1, 1, numeric(0))))) expect_warning(expect_true(is.na(rbhatt(1, numeric(0), 1, 1)))) expect_warning(expect_true(is.na(rbhatt(1, 1, numeric(0), 1)))) expect_warning(expect_true(is.na(rbhatt(1, 1, 1, numeric(0))))) expect_warning(expect_true(is.na(rbnbinom(1, numeric(0), 1, 1)))) expect_warning(expect_true(is.na(rbnbinom(1, 1, numeric(0), 1)))) expect_warning(expect_true(is.na(rbnbinom(1, 1, 1, numeric(0))))) expect_warning(expect_true(all(is.na(rbvnorm(1, numeric(0), 1, 1, 1, 0.5))))) expect_warning(expect_true(all(is.na(rbvnorm(1, 1, numeric(0), 1, 1, 0.5))))) expect_warning(expect_true(all(is.na(rbvnorm(1, 1, 1, numeric(0), 1, 0.5))))) expect_warning(expect_true(all(is.na(rbvnorm(1, 1, 1, 1, numeric(0), 0.5))))) expect_warning(expect_true(all(is.na(rbvnorm(1, 1, 1, 1, 1, numeric(0)))))) expect_warning(expect_true(all(is.na(rbvpois(1, numeric(0), 1, 1))))) expect_warning(expect_true(all(is.na(rbvpois(1, 1, numeric(0), 1))))) expect_warning(expect_true(all(is.na(rbvpois(1, 1, 1, numeric(0)))))) expect_warning(expect_true(is.na(rcat(1, numeric(0))))) expect_warning(expect_true(is.na(rcat(1, matrix(1, 0, 0))))) expect_warning(expect_true(is.na(rcatlp(1, numeric(0))))) expect_warning(expect_true(is.na(rcatlp(1, matrix(1, 0, 0))))) expect_warning(expect_true(all(is.na(rdirichlet(1, numeric(0)))))) expect_warning(expect_true(is.na(rdlaplace(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rdlaplace(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rdnorm(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rdnorm(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rdgamma(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rdgamma(1, 9, numeric(0))))) expect_warning(expect_true(is.na(rdunif(1, numeric(0), 10)))) expect_warning(expect_true(is.na(rdunif(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rdweibull(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rdweibull(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rfatigue(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rfatigue(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rfrechet(1, numeric(0), 1, 1)))) expect_warning(expect_true(is.na(rfrechet(1, 1, numeric(0), 1)))) expect_warning(expect_true(is.na(rfrechet(1, 1, 1, numeric(0))))) expect_warning(expect_true(is.na(rgev(1, numeric(0), 1, 1)))) expect_warning(expect_true(is.na(rgev(1, 1, numeric(0), 1)))) expect_warning(expect_true(is.na(rgev(1, 1, 1, numeric(0))))) expect_warning(expect_true(is.na(rgompertz(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rgompertz(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rgpd(1, numeric(0), 1, 1)))) expect_warning(expect_true(is.na(rgpd(1, 1, numeric(0), 1)))) expect_warning(expect_true(is.na(rgpd(1, 1, 1, numeric(0))))) expect_warning(expect_true(is.na(rgpois(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rgpois(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rgumbel(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rgumbel(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rhcauchy(1, numeric(0))))) expect_warning(expect_true(is.na(rhnorm(1, numeric(0))))) expect_warning(expect_true(is.na(rht(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rht(1, 5, numeric(0))))) expect_warning(expect_true(is.na(rhuber(1, numeric(0), 1, 1)))) expect_warning(expect_true(is.na(rhuber(1, 0, numeric(0), 1)))) expect_warning(expect_true(is.na(rhuber(1, 0, 1, numeric(0))))) expect_warning(expect_true(is.na(rinvgamma(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rinvgamma(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rinvchisq(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rinvchisq(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rkumar(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rkumar(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rlaplace(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rlaplace(1, 0, numeric(0))))) expect_warning(expect_true(is.na(rlgser(1, numeric(0))))) expect_warning(expect_true(is.na(rlomax(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rlomax(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rmixnorm(1, numeric(0), c(1,2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixnorm(1, c(1,2,3), numeric(0), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixnorm(1, c(1,2,3), c(1,2,3), numeric(0))))) expect_warning(expect_true(is.na(rmixpois(1, numeric(0), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixpois(1, c(1,2,3), numeric(0))))) expect_warning(expect_true(is.na(rnhyper(1, numeric(0), 35, 15)))) expect_warning(expect_true(is.na(rnhyper(1, 60, numeric(0), 15)))) expect_warning(expect_true(is.na(rnhyper(1, 60, 35, numeric(0))))) expect_warning(expect_true(all(is.na(rdirmnom(1, numeric(0), c(1, 1, 1)))))) expect_warning(expect_true(all(is.na(rdirmnom(1, 3, numeric(0)))))) expect_warning(expect_true(all(is.na(rmnom(1, numeric(0), c(1/3, 1/3, 1/3)))))) expect_warning(expect_true(all(is.na(rmnom(1, 3, numeric(0)))))) expect_warning(expect_true(all(is.na(rmvhyper(1, numeric(0), 5))))) expect_warning(expect_true(all(is.na(rmvhyper(1, c(2,3,4), numeric(0)))))) expect_warning(expect_true(is.na(rnsbeta(1, numeric(0), 1, -2, 2)))) expect_warning(expect_true(is.na(rnsbeta(1, 1, numeric(0), -2, 2)))) expect_warning(expect_true(is.na(rnsbeta(1, 1, 1, numeric(0), 2)))) expect_warning(expect_true(is.na(rnsbeta(1, 1, 1, -2, numeric(0))))) expect_warning(expect_true(is.na(rlst(1, numeric(0), 0, 1)))) expect_warning(expect_true(is.na(rlst(1, 2, numeric(0), 1)))) expect_warning(expect_true(is.na(rlst(1, 2, 0, numeric(0))))) expect_warning(expect_true(is.na(rpareto(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rpareto(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rprop(1, numeric(0), 0.5)))) expect_warning(expect_true(is.na(rprop(1, 10, numeric(0))))) expect_warning(expect_true(is.na(rrayleigh(1, numeric(0))))) expect_warning(expect_true(is.na(rtlambda(1, numeric(0))))) expect_warning(expect_true(is.na(rsgomp(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rsgomp(1, 0.4, numeric(0))))) expect_warning(expect_true(is.na(rskellam(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rskellam(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rslash(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rslash(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rtnorm(1, numeric(0), 1, -2, 2)))) expect_warning(expect_true(is.na(rtnorm(1, 0, numeric(0), -2, 2)))) expect_warning(expect_true(is.na(rtnorm(1, 0, 1, numeric(0), 2)))) expect_warning(expect_true(is.na(rtnorm(1, 0, 1, -2, numeric(0))))) expect_warning(expect_true(is.na(rtpois(1, numeric(0), 0)))) expect_warning(expect_true(is.na(rtpois(1, 5, numeric(0))))) expect_warning(expect_true(is.na(rtriang(1, numeric(0), 1, 0.5)))) expect_warning(expect_true(is.na(rtriang(1, 0, numeric(0), 0.5)))) expect_warning(expect_true(is.na(rtriang(1, 0, 1, numeric(0))))) expect_warning(expect_true(is.na(rwald(1, numeric(0), 1)))) expect_warning(expect_true(is.na(rwald(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rzip(1, numeric(0), 0.5)))) expect_warning(expect_true(is.na(rzip(1, 1, numeric(0))))) expect_warning(expect_true(is.na(rzib(1, numeric(0), 0.5, 0.5)))) expect_warning(expect_true(is.na(rzib(1, 1, numeric(0), 0.5)))) expect_warning(expect_true(is.na(rzib(1, 1, 0.5, numeric(0))))) expect_warning(expect_true(is.na(rzinb(1, numeric(0), 0.5, 0.5)))) expect_warning(expect_true(is.na(rzinb(1, 1, numeric(0), 0.5)))) expect_warning(expect_true(is.na(rzinb(1, 1, 0.5, numeric(0))))) })extraDistr/tests/testthat/test-discrete-sum-to-unity.R0000755000176200001440000000535014475546572022730 0ustar liggesusers test_that("Discrete probabilities sum to unity", { expect_equal(sum(ddunif(-2:10, -2, 10)), 1) expect_equal(sum(dbbinom(0:10, 10, 1, 1)), 1) expect_equal(sum(dbbinom(0:10, 10, 1, 10)), 1) expect_equal(sum(dbbinom(0:10, 10, 10, 1)), 1) expect_equal(sum(dbbinom(0:10, 10, 10, 10)), 1) expect_equal(sum(dbnbinom(0:1e5, 10, 1, 1)), 1, tolerance = 1e-3) expect_equal(sum(dbnbinom(0:1e5, 10, 1, 10)), 1, tolerance = 1e-3) expect_equal(sum(dbnbinom(0:1e5, 10, 10, 1)), 1, tolerance = 1e-3) expect_equal(sum(dbnbinom(0:1e5, 10, 10, 10)), 1, tolerance = 1e-3) expect_equal(sum(dbvpois(expand.grid(0:100, 0:100), a = 10, b = 10, c = 10)), 1, tolerance = 1e-3) divBySum <- function(x) x/sum(x, na.rm = TRUE) expect_equal(sum(dcat(1:10, divBySum(runif(10)))), 1) expect_equal(sum(ddlaplace(-50:50, 0, 0.5)), 1) expect_equal(sum(ddlaplace(-50:50, 0, 0.1)), 1) expect_equal(sum(ddlaplace(-50:50, 0, 0.7)), 1) expect_equal(sum(ddnorm(-50:50, sd = 5)), 1) expect_equal(sum(ddnorm(-50:50, sd = 7)), 1) expect_equal(sum(dnhyper(0:100, 60, 35, 15)), 1) expect_equal(sum(dgpois(0:100, 10, 1)), 1) expect_equal(sum(dmnom(expand.grid(0:30, 0:30, 0:30), 30, c(0.2, 0.1, 0.7))), 1) expect_equal(sum(ddirmnom(expand.grid(0:30, 0:30, 0:30), 30, c(2, 3, 8))), 1) expect_equal(sum(dmvhyper(expand.grid(0:30, 0:30, 0:30), c(20, 30, 28), 30)), 1) expect_equal(sum(dskellam(-100:100, 10, 20)), 1) expect_equal(sum(dtpois(0:100, 30, a = -Inf, b = Inf)), 1) expect_equal(sum(dtpois(0:100, 30, a = 0, b = Inf)), 1) expect_equal(sum(dtpois(0:100, 30, a = 25, b = Inf)), 1) expect_equal(sum(dtpois(0:100, 30, a = -Inf, b = 32)), 1) expect_equal(sum(dtpois(0:100, 30, a = 25, b = 32)), 1) expect_equal(sum(dtbinom(0:100, 100, 0.29, a = -Inf, b = Inf)), 1) expect_equal(sum(dtbinom(0:100, 100, 0.29, a = 0, b = Inf)), 1) expect_equal(sum(dtbinom(0:100, 100, 0.29, a = 25, b = Inf)), 1) expect_equal(sum(dtbinom(0:100, 100, 0.29, a = -Inf, b = 32)), 1) expect_equal(sum(dtbinom(0:100, 100, 0.29, a = 25, b = 32)), 1) expect_equal(sum(dtbinom(0:100, 100, 0.5, a = -Inf, b = Inf)), 1) expect_equal(sum(dtbinom(0:100, 100, 0.5, a = 0, b = Inf)), 1) expect_equal(sum(dtbinom(0:100, 100, 0.5, a = 25, b = Inf)), 1) expect_equal(sum(dtbinom(0:100, 100, 0.5, a = -Inf, b = 32)), 1) expect_equal(sum(dtbinom(0:100, 100, 0.5, a = 25, b = 32)), 1) expect_equal(sum(dlgser(0:100, 0.6)), 1) expect_equal(sum(dlgser(0:100, 0.1)), 1) expect_equal(sum(dlgser(0:100, 0.8)), 1) expect_equal(sum(dmixpois(0:100, c(10, 20, 5), c(0.2, 0.5, 0.3))), 1) expect_equal(sum(dzib(0:1000, 30, 0.33, 0.4)), 1) expect_equal(sum(dzinb(0:1000, 30, 0.33, 0.4)), 1) expect_equal(sum(dzip(0:1000, 30, 0.4)), 1) }) extraDistr/tests/testthat/test-quantile-functions.R0000755000176200001440000000716614475546572022375 0ustar liggesusers test_that("Zeros in quantile functions", { expect_true(!is.nan(qbetapr(0, 1, 1, 1))) expect_true(!is.nan(qfatigue(0, 1))) expect_true(!is.nan(qcat(0, c(0.5, 0.5)))) expect_true(!is.nan(qdweibull(0, 0.5, 1))) expect_true(!is.nan(qfrechet(0))) expect_true(!is.nan(qgev(0, 1, 1, 1))) expect_true(!is.nan(qgompertz(0, 1, 1))) expect_true(!is.nan(qgpd(0, 1, 1, 1))) expect_true(!is.nan(qgumbel(0))) expect_true(!is.nan(qhuber(0))) expect_true(!is.nan(qhcauchy(0, 1))) expect_true(!is.nan(qhnorm(0, 1))) expect_true(!is.nan(qht(0, 5, 1))) expect_true(!is.nan(qinvgamma(0, 1, 1))) expect_true(!is.nan(qlaplace(0))) expect_true(!is.nan(qlgser(0, 0.5))) expect_true(!is.nan(qlomax(0, 1, 1))) expect_true(!is.nan(qnhyper(0, 60, 35, 15))) expect_true(!is.nan(qlst(0, df = 2))) expect_true(!is.nan(qpareto(0))) expect_true(!is.nan(qpower(0, 1, 1))) expect_true(!is.nan(qprop(0, 10, 0.5))) expect_true(!is.nan(qrayleigh(0))) expect_true(!is.nan(qtlambda(0, 0.5))) expect_true(!is.nan(qtbinom(0, 100, 0.83, 76, 86))) expect_true(!is.nan(qzip(0, 1, 0.5))) expect_true(!is.nan(qzib(0, 1, 1, 0.5))) expect_true(!is.nan(qzinb(0, 1, 1, 0.5))) expect_true(!is.nan(qtpois(0, lambda = 5, a = 0))) expect_true(!is.nan(qtpois(0, lambda = 5, a = 6))) expect_true(!is.nan(pdgamma(0, 9, 1))) expect_true(!is.nan(pdnorm(0, 1, 2))) }) test_that("Ones in quantile functions", { expect_true(!is.nan(qbetapr(1, 1, 1, 1))) expect_true(!is.nan(qfatigue(1, 1))) expect_true(!is.nan(qcat(1, c(0.5, 0.5)))) expect_true(!is.nan(qdweibull(1, 0.5, 1))) expect_true(!is.nan(qfrechet(1))) expect_true(!is.nan(qgev(1, 1, 1, 1))) expect_true(!is.nan(qgompertz(1, 1, 1))) expect_true(!is.nan(qgpd(1, 1, 1, 1))) expect_true(!is.nan(qgumbel(1))) expect_true(!is.nan(qhuber(1))) expect_true(!is.nan(qhcauchy(1, 1))) expect_true(!is.nan(qhnorm(1, 1))) expect_true(!is.nan(qht(1, 5, 1))) expect_true(!is.nan(qinvgamma(1, 1, 1))) expect_true(!is.nan(qlaplace(1))) expect_true(!is.nan(qlgser(1, 0.5))) expect_true(!is.nan(qlomax(1, 1, 1))) expect_true(!is.nan(qnhyper(1, 60, 35, 15))) expect_true(!is.nan(qlst(1, df = 2))) expect_true(!is.nan(qpareto(1))) expect_true(!is.nan(qpower(1, 1, 1))) expect_true(!is.nan(qprop(1, 10, 0.5))) expect_true(!is.nan(qrayleigh(1))) expect_true(!is.nan(qtlambda(1, 0.5))) expect_true(!is.nan(qtbinom(1, 100, 0.83, 76, 86))) expect_true(!is.nan(qzip(1, 1, 0.5))) expect_true(!is.nan(qzib(1, 1, 1, 0.5))) expect_true(!is.nan(qzinb(1, 1, 1, 0.5))) expect_true(!is.nan(qtpois(1, lambda = 5, a = 0))) expect_true(!is.nan(qtpois(1, lambda = 5, a = 6))) }) test_that("Checking p = F(F^-1(p))", { pp <- seq(0, 1, by = 0.001) expect_equal(pp, pbetapr(qbetapr(pp, 1, 1, 1), 1, 1, 1)) expect_equal(pp, pfatigue(qfatigue(pp, 1), 1)) expect_equal(pp, pfrechet(qfrechet(pp))) expect_equal(pp, pgev(qgev(pp, 1, 1, 1), 1, 1, 1)) expect_equal(pp, pgompertz(qgompertz(pp, 1, 1), 1, 1)) expect_equal(pp, pgpd(qgpd(pp, 1, 1, 1), 1, 1, 1)) expect_equal(pp, pgumbel(qgumbel(pp))) expect_equal(pp, phuber(qhuber(pp))) expect_equal(pp, phcauchy(qhcauchy(pp, 1), 1)) expect_equal(pp, phnorm(qhnorm(pp, 1), 1)) expect_equal(pp, pht(qht(pp, 5, 1), 5, 1)) expect_equal(pp, pinvgamma(qinvgamma(pp, 1, 1), 1, 1)) expect_equal(pp, plaplace(qlaplace(pp))) expect_equal(pp, plomax(qlomax(pp, 1, 1), 1, 1)) expect_equal(pp, plst(qlst(pp, df = 2), df = 2)) expect_equal(pp, ppareto(qpareto(pp))) expect_equal(pp, ppower(qpower(pp, 1, 1), 1, 1)) expect_equal(pp, pprop(qprop(pp, 10, 0.5), 10, 0.5)) expect_equal(pp, prayleigh(qrayleigh(pp))) }) extraDistr/tests/testthat/test-rng-coverge.R0000755000176200001440000000527614475546572020763 0ustar liggesusers probCoverage <- function(stub, ..., n = 5000L) { rfoo <- eval(as.name(paste0("r", stub))) pfoo <- eval(as.name(paste0("p", stub))) diff(pfoo(range(rfoo(n, ...)), ...)) } test_that("Coverage of RNG's", { skip_on_cran() expect_gte(probCoverage("betapr", 1, 1, 1), 0.99) expect_gte(probCoverage("bhatt", 1, 1, 1), 0.99) expect_gte(probCoverage("fatigue", 1, 1), 0.99) expect_gte(probCoverage("frechet", 1, 1, 1), 0.99) expect_gte(probCoverage("gev", 1, 1, 1), 0.99) expect_gte(probCoverage("gompertz", 1, 1), 0.99) expect_gte(probCoverage("gpd", 1, 1, 1), 0.99) expect_gte(probCoverage("gumbel", 1, 1), 0.99) expect_gte(probCoverage("hcauchy", 1), 0.99) expect_gte(probCoverage("hnorm", 1), 0.99) expect_gte(probCoverage("ht", 5, 1), 0.99) expect_gte(probCoverage("huber", 0, 1, 1), 0.99) expect_gte(probCoverage("invgamma", 1, 1), 0.99) expect_gte(probCoverage("invchisq", 1, 1), 0.99) expect_gte(probCoverage("kumar", 1, 1), 0.99) expect_gte(probCoverage("kumar", 100, 1), 0.99) expect_gte(probCoverage("kumar", 1, 100), 0.99) expect_gte(probCoverage("kumar", 100, 100), 0.99) expect_gte(probCoverage("laplace", 0, 1), 0.99) expect_gte(probCoverage("laplace", 0, 1000), 0.99) expect_gte(probCoverage("lomax", 1, 0.001), 0.99) expect_gte(probCoverage("lomax", 1, 0.5), 0.99) expect_gte(probCoverage("lomax", 1, 0.999), 0.99) expect_gte(probCoverage("mixnorm", c(1,2,3), c(1,2,3), c(1/3,1/3,1/3)), 0.99) expect_gte(probCoverage("nsbeta", 1, 1, -2, 2), 0.99) expect_gte(probCoverage("lst", 2, 0, 1), 0.99) expect_gte(probCoverage("pareto", 1, 1), 0.99) expect_gte(probCoverage("prop", 10, 0.5), 0.99) expect_gte(probCoverage("prop", 100, 0.5), 0.99) expect_gte(probCoverage("prop", 1000, 0.5), 0.99) expect_gte(probCoverage("prop", 10, 0.01), 0.99) expect_gte(probCoverage("prop", 10, 0.5), 0.99) expect_gte(probCoverage("prop", 10, 0.99), 0.99) expect_gte(probCoverage("rayleigh", 1), 0.99) expect_gte(probCoverage("sgomp", 0.4, 1), 0.99) expect_gte(probCoverage("slash", 1, 1), 0.99) expect_gte(probCoverage("tnorm", 0, 1, -1, 1), 0.99) expect_gte(probCoverage("tnorm", 0, 1, -2, 2), 0.99) expect_gte(probCoverage("tnorm", 0, 1, 2, Inf), 0.99) expect_gte(probCoverage("tnorm", 0, 1, 4, Inf), 0.99) expect_gte(probCoverage("tnorm", 0, 1, -Inf, -2), 0.99) expect_gte(probCoverage("tnorm", 0, 1, -Inf, -4), 0.99) expect_gte(probCoverage("tnorm", 0, 1, -6, -4), 0.99) expect_gte(probCoverage("tnorm", 0, 1, 4, 6), 0.99) expect_gte(probCoverage("triang"), 0.99) expect_gte(probCoverage("triang", 0, 1, 0.5), 0.99) expect_gte(probCoverage("wald", 1, 1), 0.99) }) extraDistr/tests/testthat/test-log-probs.R0000755000176200001440000002537514475546572020453 0ustar liggesusers test_that("Check if log-probabilities are logs of probabilities (PMF's and PDF's)", { x <- c(-Inf, -100, -10, -5, -1, -0.5, 0, 0.5, 1, 5, 10, 100, Inf) expect_equal(suppressWarnings(dbbinom(x, 1, 1, 1, log = TRUE)), log(suppressWarnings(dbbinom(x, 1, 1, 1)))) expect_equal(suppressWarnings(dbern(x, 0.5, log = TRUE)), log(suppressWarnings(dbern(x, 0.5)))) expect_equal(suppressWarnings(dbetapr(x, 1, 1, 1, log = TRUE)), log(suppressWarnings(dbetapr(x, 1, 1, 1)))) expect_equal(dbhatt(x, sigma = 1, log = TRUE), log(dbhatt(x, sigma = 1))) expect_equal(suppressWarnings(dbnbinom(x, 1, 1, 1, log = TRUE)), log(suppressWarnings(dbnbinom(x, 1, 1, 1)))) expect_equal(dbvnorm(x, x, sd1 = 1, log = TRUE), log(dbvnorm(x, x, sd1 = 1))) expect_equal(suppressWarnings(dbvpois(x, x, 1, 1, 1, log = TRUE)), log(suppressWarnings(dbvpois(x, x, 1, 1, 1)))) expect_equal(suppressWarnings(dcat(x, c(0.5, 0.5), log = TRUE)), log(suppressWarnings(dcat(x, c(0.5, 0.5))))) expect_equal(ddirichlet(c(0.5, 0.5), c(1, 0.5), log = TRUE), log(ddirichlet(c(0.5, 0.5), c(1, 0.5)))) expect_equal(suppressWarnings(ddlaplace(x, 0, scale = 0.5, log = TRUE)), log(suppressWarnings(ddlaplace(x, 0, scale = 0.5)))) expect_equal(suppressWarnings(ddnorm(x, sd = 1, log = TRUE)), log(suppressWarnings(ddnorm(x, sd = 1)))) expect_equal(suppressWarnings(ddgamma(x, 9, 1, log = TRUE)), log(suppressWarnings(ddgamma(x, 9, 1)))) expect_equal(suppressWarnings(ddunif(x, min = 10, max = 100, log = TRUE)), log(suppressWarnings(ddunif(x, min = 10, max = 100)))) expect_equal(suppressWarnings(ddweibull(x, 0.5, 1, log = TRUE)), log(suppressWarnings(ddweibull(x, 0.5, 1)))) expect_equal(dfatigue(x, 1, 1, log = TRUE), log(dfatigue(x, 1, 1))) expect_equal(dfrechet(x, lambda = 1, log = TRUE), log(dfrechet(x, lambda = 1))) expect_equal(dgev(x, 1, 1, 1, log = TRUE), log(dgev(x, 1, 1, 1))) # expect_equal(dgompertz(x, 1, 1, log = TRUE), # log(dgompertz(x, 1, 1))) expect_equal(dgpd(x, 1, 1, 1, log = TRUE), log(dgpd(x, 1, 1, 1))) expect_equal(suppressWarnings(dgpois(x, 1, 1, log = TRUE)), log(suppressWarnings(dgpois(x, 1, 1)))) # expect_equal(dgumbel(x, sigma = 1, log = TRUE), # log(dgumbel(x, sigma = 1))) expect_equal(dhcauchy(x, 1, log = TRUE), log(dhcauchy(x, 1))) # expect_equal(dhnorm(x, 1, log = TRUE), # log(dhnorm(x, 1))) # numerical precission expect_equal(dht(x, 5, 1, log = TRUE), log(dht(x, 5, 1))) expect_equal(dhuber(x, 0, 1, 1, log = TRUE), log(dhuber(x, 0, 1, 1))) expect_equal(dinvgamma(x, 1, 1, log = TRUE), log(dinvgamma(x, 1, 1))) expect_equal(dinvchisq(x, 1, 1, log = TRUE), log(dinvchisq(x, 1, 1))) expect_equal(dkumar(x, 1, 1, log = TRUE), log(dkumar(x, 1, 1))) expect_equal(dlaplace(x, 0, 1, log = TRUE), log(dlaplace(x, 0, 1))) expect_equal(suppressWarnings(dlgser(x, 0.5, log = TRUE)), log(suppressWarnings(dlgser(x, 0.5)))) expect_equal(dlomax(x, 1, 1, log = TRUE), log(dlomax(x, 1, 1))) expect_equal(dmixnorm(x, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3), log = TRUE), log(dmixnorm(x, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3)))) expect_equal(suppressWarnings(dmixpois(x, c(1,2,3), c(1/3,1/3,1/3), log = TRUE)), log(suppressWarnings(dmixpois(x, c(1,2,3), c(1/3,1/3,1/3))))) expect_equal(suppressWarnings(dnhyper(x, 60, 35, 15, log = TRUE)), log(suppressWarnings(dnhyper(x, 60, 35, 15)))) expect_equal(ddirmnom(c(1, 1, 1), 2, c(1, 1, 1), log = TRUE), log(ddirmnom(c(1, 1, 1), 2, c(1, 1, 1)))) expect_equal(dmnom(c(1, 1, 1), 2, c(1/3, 1/3, 1/3), log = TRUE), log(dmnom(c(1, 1, 1), 2, c(1/3, 1/3, 1/3)))) expect_equal(dmvhyper(c(1, 2, 2), c(2,3,4), 5, log = TRUE), log(dmvhyper(c(1, 2, 2), c(2,3,4), 5))) expect_equal(dnsbeta(x, 1, 1, -2, 2, log = TRUE), log(dnsbeta(x, 1, 1, -2, 2))) expect_equal(dlst(x, 2, 0, 1, log = TRUE), log(dlst(x, 2, 0, 1))) expect_equal(dpareto(x, 1, 1, log = TRUE), log(dpareto(x, 1, 1))) expect_equal(dprop(x, 10, 0.5, log = TRUE), log(dprop(x, 10, 0.5))) # expect_equal(drayleigh(x, 1, log = TRUE), # log(drayleigh(x, 1))) expect_equal(suppressWarnings(dskellam(x, 1, 1, log = TRUE)), log(suppressWarnings(dskellam(x, 1, 1)))) expect_equal(dsgomp(x, 0.4, 1, log = TRUE), log(dsgomp(x, 0.4, 1))) expect_equal(dslash(x, sigma = 1, log = TRUE), log(dslash(x, sigma = 1))) expect_equal(dtnorm(x, 0, 1, 1, 2, log = TRUE), log(dtnorm(x, 0, 1, 1, 2))) expect_equal(suppressWarnings(dtpois(x, lambda = 25, a = 0, log = TRUE)), log(suppressWarnings(dtpois(x, lambda = 25, a = 0)))) expect_equal(suppressWarnings(dtbinom(x, 100, 0.67, a = 60, b = 70, log = TRUE)), log(suppressWarnings(dtbinom(x, 100, 0.67, a = 60, b = 70)))) expect_equal(dtriang(x, 1, 2, 1.5, log = TRUE), log(dtriang(x, 1, 2, 1.5))) expect_equal(dwald(x, 1, 1, log = TRUE), log(dwald(x, 1, 1))) expect_equal(suppressWarnings(dzip(x, 1, 0.5, log = TRUE)), log(suppressWarnings(dzip(x, 1, 0.5)))) expect_equal(suppressWarnings(dzib(x, 1, 0.5, 0.5, log = TRUE)), log(suppressWarnings(dzib(x, 1, 0.5, 0.5)))) expect_equal(suppressWarnings(dzinb(x, 1, 0.5, 0.5, log = TRUE)), log(suppressWarnings(dzinb(x, 1, 0.5, 0.5)))) }) test_that("Check if log-probabilities are logs of probabilities (CDF's)", { x <- c(-Inf, -100, -10, -5, -1, -0.5, 0, 0.5, 1, 5, 10, 100, Inf) expect_equal(suppressWarnings(pbbinom(x, 1, 1, 1, log.p = TRUE)), log(suppressWarnings(pbbinom(x, 1, 1, 1)))) expect_equal(suppressWarnings(pbern(x, 0.5, log.p = TRUE)), log(suppressWarnings(pbern(x, 0.5)))) expect_equal(suppressWarnings(pbetapr(x, 1, 1, 1, log.p = TRUE)), log(suppressWarnings(pbetapr(x, 1, 1, 1)))) expect_equal(pbhatt(x, sigma = 1, log.p = TRUE), log(pbhatt(x, sigma = 1))) expect_equal(suppressWarnings(pbnbinom(x, 1, 1, 1, log.p = TRUE)), log(suppressWarnings(pbnbinom(x, 1, 1, 1)))) expect_equal(suppressWarnings(pcat(x, c(0.5, 0.5), log.p = TRUE)), log(suppressWarnings(pcat(x, c(0.5, 0.5))))) expect_equal(suppressWarnings(pdlaplace(x, 0, scale = 0.5, log.p = TRUE)), log(suppressWarnings(pdlaplace(x, 0, scale = 0.5)))) # expect_equal(suppressWarnings(pdnorm(x, sd = 1, log.p = TRUE)), # log(suppressWarnings(pdnorm(x, sd = 1)))) expect_equal(suppressWarnings(pdgamma(x, 9, 1, log.p = TRUE)), log(suppressWarnings(pdgamma(x, 9, 1)))) expect_equal(suppressWarnings(pdunif(x, min = 10, max = 100, log.p = TRUE)), log(suppressWarnings(pdunif(x, min = 10, max = 100)))) expect_equal(suppressWarnings(pdweibull(x, 0.5, 1, log.p = TRUE)), log(suppressWarnings(pdweibull(x, 0.5, 1)))) expect_equal(pfatigue(x, 1, 1, log.p = TRUE), log(pfatigue(x, 1, 1))) expect_equal(pfrechet(x, lambda = 1, log.p = TRUE), log(pfrechet(x, lambda = 1))) expect_equal(pgev(x, 1, 1, 1, log.p = TRUE), log(pgev(x, 1, 1, 1))) # expect_equal(pgompertz(x, 1, 1, log.p = TRUE), # log(pgompertz(x, 1, 1))) expect_equal(pgpd(x, 1, 1, 1, log.p = TRUE), log(pgpd(x, 1, 1, 1))) expect_equal(suppressWarnings(pgpois(x, 1, 1, log.p = TRUE)), log(suppressWarnings(pgpois(x, 1, 1)))) # expect_equal(pgumbel(x, sigma = 1, log.p = TRUE), # log(pgumbel(x, sigma = 1))) expect_equal(phcauchy(x, 1, log.p = TRUE), log(phcauchy(x, 1))) expect_equal(phnorm(x, 1, log.p = TRUE), log(phnorm(x, 1))) expect_equal(pht(x, 5, 1, log.p = TRUE), log(pht(x, 5, 1))) expect_equal(phuber(x, 0, 1, 1, log.p = TRUE), log(phuber(x, 0, 1, 1))) expect_equal(pinvgamma(x, 1, 1, log.p = TRUE), log(pinvgamma(x, 1, 1))) expect_equal(pinvchisq(x, 1, 1, log.p = TRUE), log(pinvchisq(x, 1, 1))) expect_equal(pkumar(x, 1, 1, log.p = TRUE), log(pkumar(x, 1, 1))) expect_equal(plaplace(x, 0, 1, log.p = TRUE), log(plaplace(x, 0, 1))) expect_equal(suppressWarnings(plgser(x, 0.5, log.p = TRUE)), log(suppressWarnings(plgser(x, 0.5)))) expect_equal(plomax(x, 1, 1, log.p = TRUE), log(plomax(x, 1, 1))) expect_equal(pmixnorm(x, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3), log.p = TRUE), log(pmixnorm(x, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3)))) expect_equal(suppressWarnings(pmixpois(x, c(1,2,3), c(1/3,1/3,1/3), log.p = TRUE)), log(suppressWarnings(pmixpois(x, c(1,2,3), c(1/3,1/3,1/3))))) expect_equal(suppressWarnings(pnhyper(x, 60, 35, 15, log.p = TRUE)), log(suppressWarnings(pnhyper(x, 60, 35, 15)))) expect_equal(pnsbeta(x, 1, 1, -2, 2, log.p = TRUE), log(pnsbeta(x, 1, 1, -2, 2))) expect_equal(plst(x, 2, 0, 1, log.p = TRUE), log(plst(x, 2, 0, 1))) expect_equal(ppareto(x, 1, 1, log.p = TRUE), log(ppareto(x, 1, 1))) expect_equal(pprop(x, 10, 0.5, log.p = TRUE), log(pprop(x, 10, 0.5))) # expect_equal(prayleigh(x, 1, log.p = TRUE), # log(prayleigh(x, 1))) expect_equal(psgomp(x, 0.4, 1, log.p = TRUE), log(psgomp(x, 0.4, 1))) expect_equal(pslash(x, sigma = 1, log.p = TRUE), log(pslash(x, sigma = 1))) expect_equal(ptnorm(x, 0, 1, 1, 2, log.p = TRUE), log(ptnorm(x, 0, 1, 1, 2))) expect_equal(suppressWarnings(ptpois(x, lambda = 25, a = 0, log.p = TRUE)), log(suppressWarnings(ptpois(x, lambda = 25, a = 0)))) expect_equal(suppressWarnings(ptbinom(x, 100, 0.67, a = 60, b = 70, log.p = TRUE)), log(suppressWarnings(ptbinom(x, 100, 0.67, a = 60, b = 70)))) expect_equal(ptriang(x, 1, 2, 1.5, log.p = TRUE), log(ptriang(x, 1, 2, 1.5))) expect_equal(pwald(x, 1, 1, log.p = TRUE), log(pwald(x, 1, 1))) expect_equal(suppressWarnings(pzip(x, 1, 0.5, log.p = TRUE)), log(suppressWarnings(pzip(x, 1, 0.5)))) expect_equal(suppressWarnings(pzib(x, 1, 0.5, 0.5, log.p = TRUE)), log(suppressWarnings(pzib(x, 1, 0.5, 0.5)))) expect_equal(suppressWarnings(pzinb(x, 1, 0.5, 0.5, log.p = TRUE)), log(suppressWarnings(pzinb(x, 1, 0.5, 0.5)))) }) extraDistr/tests/testthat/test-p-r-random-tests.R0000755000176200001440000001206614475546572021654 0ustar liggesusers # Tests from 'tests/p-r-random-tests.R' from base R superror <- function(rfoo,pfoo,sample.size,...) { x <- rfoo(sample.size,...) tx <- table(signif(x, 12)) # such that xi will be sort(unique(x)) xi <- as.numeric(names(tx)) f <- pfoo(xi,...) fhat <- cumsum(tx)/sample.size max(abs(fhat-f)) } pdkwbound <- function(n,t) 2*exp(-2*n*t*t) qdkwbound <- function(n,p) sqrt(log(p/2)/(-2*n)) dkwtest <- function(stub = "norm", ..., sample.size = 10000, pthreshold = 0.001, print.result = FALSE, print.detail = FALSE, # don't print by default stop.on.failure = FALSE) # don't stop by default { rfoo <- eval(as.name(paste0("r", stub))) pfoo <- eval(as.name(paste0("p", stub))) s <- superror(rfoo, pfoo, sample.size, ...) if (print.result || print.detail) { printargs <- substitute(list(...)) printargs[[1]] <- as.name(stub) cat(deparse(printargs)) if (print.detail) cat("\nsupremum error = ",signif(s,2), " with p-value=",min(1,round(pdkwbound(sample.size,s),4)),"\n") } rval <- (s < qdkwbound(sample.size,pthreshold)) if (print.result) cat(c(" FAILED\n"," PASSED\n")[rval+1]) if (stop.on.failure && !rval) stop("dkwtest failed") rval } test_that("p-r random tests", { skip_on_cran() expect_true(dkwtest("bbinom", 1, 1, 1)) expect_true(dkwtest("bbinom", 10, 1, 1)) expect_true(dkwtest("bbinom", 10, 100, 1)) expect_true(dkwtest("bbinom", 10, 1, 100)) expect_true(dkwtest("bbinom", 100, 1, 1)) expect_true(dkwtest("bbinom", 100, 100, 1)) expect_true(dkwtest("bbinom", 100, 1, 100)) expect_true(dkwtest("bern", 0.5)) expect_true(dkwtest("betapr", 1, 1, 1)) expect_true(dkwtest("bhatt", 1, 1, 1)) expect_true(dkwtest("bnbinom", 1, 1, 1)) expect_true(dkwtest("bnbinom", 10, 1, 1)) expect_true(dkwtest("bnbinom", 10, 100, 1)) expect_true(dkwtest("cat", c(0.5, 0.5))) expect_true(dkwtest("cat", c(1e-6, 1, 2.5, 100))) expect_true(dkwtest("dlaplace", 1, 0.001)) expect_true(dkwtest("dlaplace", 0, 0.5)) expect_true(dkwtest("dlaplace", 0, 0.999)) expect_true(dkwtest("dnorm", 1, 1)) expect_true(dkwtest("dgamma", 9, 1)) expect_true(dkwtest("dunif", 1, 10)) expect_true(dkwtest("dweibull", 0.5, 1)) expect_true(dkwtest("dweibull", 0.001, 1)) expect_true(dkwtest("dweibull", 0.999, 1)) expect_true(dkwtest("fatigue", 1, 1)) expect_true(dkwtest("frechet", 1, 1, 1)) expect_true(dkwtest("gev", 1, 1, 1)) expect_true(dkwtest("gompertz", 1, 1)) expect_true(dkwtest("gpd", 1, 1, 1)) expect_true(dkwtest("gpois", 1, 1)) expect_true(dkwtest("gumbel", 1, 1)) expect_true(dkwtest("hcauchy", 1)) expect_true(dkwtest("hnorm", 1)) expect_true(dkwtest("ht", 5, 1)) expect_true(dkwtest("huber", 0, 1, 1)) expect_true(dkwtest("invgamma", 1, 1)) expect_true(dkwtest("invchisq", 1, 1)) expect_true(dkwtest("kumar", 1, 1)) expect_true(dkwtest("kumar", 100, 1)) expect_true(dkwtest("kumar", 1, 100)) expect_true(dkwtest("kumar", 100, 100)) expect_true(dkwtest("laplace", 0, 1)) expect_true(dkwtest("laplace", 0, 1000)) expect_true(dkwtest("lgser", 0.001)) expect_true(dkwtest("lgser", 0.5)) expect_true(dkwtest("lgser", 0.999)) expect_true(dkwtest("lomax", 1, 0.001)) expect_true(dkwtest("lomax", 1, 0.5)) expect_true(dkwtest("lomax", 1, 0.999)) expect_true(dkwtest("mixnorm", c(1,2,3), c(1,2,3), c(1/3,1/3,1/3))) expect_true(dkwtest("mixpois", c(1,2,3), c(1/3,1/3,1/3))) expect_true(dkwtest("nhyper", 60, 35, 15)) expect_true(dkwtest("nhyper", 1, 100, 15)) expect_true(dkwtest("nhyper", 5, 5, 4)) expect_true(dkwtest("nhyper", 1000, 5, 4)) expect_true(dkwtest("nsbeta", 1, 1, -2, 2)) expect_true(dkwtest("lst", 2, 0, 1)) expect_true(dkwtest("pareto", 1, 1)) expect_true(dkwtest("power", 1, 1)) expect_true(dkwtest("power", 5, 16)) expect_true(dkwtest("prop", 10, 0.5)) expect_true(dkwtest("prop", 100, 0.5)) expect_true(dkwtest("prop", 1000, 0.5)) expect_true(dkwtest("prop", 10, 0.01)) expect_true(dkwtest("prop", 10, 0.5)) expect_true(dkwtest("prop", 10, 0.99)) expect_true(dkwtest("rayleigh", 1)) expect_true(dkwtest("sgomp", 0.4, 1)) expect_true(dkwtest("slash", 1, 1)) expect_true(dkwtest("tbinom", 200, 0.5, a = 100)) expect_true(dkwtest("tbinom", 200, 0.5, b = 100)) expect_true(dkwtest("tnorm", 0, 1, -1, 1)) expect_true(dkwtest("tnorm", 0, 1, -2, 2)) expect_true(dkwtest("tnorm", 0, 1, 2, Inf)) expect_true(dkwtest("tnorm", 0, 1, 4, Inf)) expect_true(dkwtest("tnorm", 0, 1, -Inf, -2)) expect_true(dkwtest("tnorm", 0, 1, -Inf, -4)) expect_true(dkwtest("tnorm", 0, 1, -6, -4)) expect_true(dkwtest("tnorm", 0, 1, 4, 6)) expect_true(dkwtest("tpois", 5, 0)) expect_true(dkwtest("tpois", 50, 45, 55)) expect_true(dkwtest("triang")) expect_true(dkwtest("triang", 0, 1, 0.5)) expect_true(dkwtest("wald", 1, 1)) expect_true(dkwtest("zip", 1, 0.5)) expect_true(dkwtest("zib", 1, 0.5, 0.5)) expect_true(dkwtest("zinb", 1, 0.5, 0.5)) }) extraDistr/tests/testthat/test-discrete.R0000755000176200001440000000700414475546572020336 0ustar liggesusers test_that("Zero probabilities for non-integers", { expect_warning(expect_equal(0, ddlaplace(0.5, 0, 0.5))) expect_warning(expect_equal(0, ddnorm(0.5))) expect_warning(expect_equal(0, ddgamma(0.5, 9, 1))) expect_warning(expect_equal(0, ddweibull(0.5, 0.5, 1))) expect_warning(expect_equal(0, ddunif(0.5, 0, 5))) expect_warning(expect_equal(0, dcat(0.5, c(0.5, 0.5)))) expect_warning(expect_equal(0, dmnom(c(0.5, 1), 5, c(0.5, 0.5)))) expect_warning(expect_equal(0, dnhyper(0.5, 60, 35, 15))) expect_warning(expect_equal(0, dbern(0.5))) expect_warning(expect_equal(0, dbbinom(0.5, 1, 1, 1))) expect_warning(expect_equal(0, dbnbinom(0.5, 1, 1, 1))) expect_warning(expect_equal(0, dgpois(0.5, 1, 1))) expect_warning(expect_equal(0, dlgser(0.5, 0.5))) expect_warning(expect_equal(0, dmvhyper(c(1, 1, 0.5), c(2, 2, 2), 3))) expect_warning(expect_equal(0, dskellam(0.5, 1, 1))) expect_warning(expect_equal(0, dtpois(0.5, lambda = 25, a = 0))) expect_warning(expect_equal(0, dtbinom(0.5, 100, 0.56, a = 0))) expect_warning(expect_equal(0, dzip(0.5, 1, 0.5))) expect_warning(expect_equal(0, dzib(0.5, 1, 0.5, 0.5))) expect_warning(expect_equal(0, dzinb(0.5, 1, 0.5, 0.5))) expect_warning(expect_equal(0, dmixpois(0.5, c(1,2,3), c(1/3,1/3,1/3)))) }) test_that("cdf vs cumsum(pdf)", { xx <- seq(-500, 500, by = 1) epsilon <- 1e-4 # sqrt(.Machine$double.eps) expect_equal(cumsum(ddlaplace(xx, 0, 0.5)), pdlaplace(xx, 0, 0.5), tolerance = epsilon) expect_equal(cumsum(ddnorm(xx, 0, 15)), pdnorm(xx, 0, 15), tolerance = epsilon) xx <- seq(0, 200, by = 1) expect_equal(cumsum(ddweibull(xx, .32, 1)), pdweibull(xx, .32, 1), tolerance = epsilon) expect_equal(cumsum(ddunif(xx, 1, 199)), pdunif(xx, 1, 199), tolerance = epsilon) expect_equal(cumsum(ddgamma(xx, 9, 1)), pdgamma(xx, 9, 1), tolerance = epsilon) p <- rdirichlet(1, rep(1, 100)) expect_equal(cumsum(dcat(xx, p)), pcat(xx, p), tolerance = epsilon) expect_equal(cumsum(dnhyper(xx, 60, 35, 15)), pnhyper(xx, 60, 35, 15), tolerance = epsilon) dnhyper2 <- function(x, n, m, r) ifelse(x=(n+r), 0, choose(x-1, r-1)*choose(m+n-x, m-r)/choose(m+n, n)) expect_equal(dnhyper2(xx, 60, 35, 15), dnhyper(xx, 60, 35, 15), tolerance = epsilon) expect_equal(cumsum(dnhyper2(xx, 60, 35, 15)), pnhyper(xx, 60, 35, 15), tolerance = epsilon) expect_equal(cumsum(dtbinom(xx, 200, 0.5, a = 100)), ptbinom(xx, 200, 0.5, a = 100), tolerance = epsilon) expect_equal(cumsum(dtbinom(xx, 200, 0.5, b = 100)), ptbinom(xx, 200, 0.5, b = 100), tolerance = epsilon) expect_equal(cumsum(dbbinom(xx, 200, 5, 13)), pbbinom(xx, 200, 5, 13), tolerance = epsilon) expect_equal(cumsum(dbnbinom(xx, 70, 5, 13)), pbnbinom(xx, 70, 5, 13), tolerance = epsilon) expect_equal(cumsum(dgpois(xx, 500, 16)), pgpois(xx, 500, 16), tolerance = epsilon) expect_equal(cumsum(dlgser(xx, 0.9)), plgser(xx, 0.9), tolerance = epsilon) expect_equal(cumsum(dtpois(xx, 100, a = 80, b = 150)), ptpois(xx, 100, a = 80, b = 150), tolerance = epsilon) expect_equal(cumsum(dtbinom(xx, 100, 0.5, a = 80, b = 150)), ptbinom(xx, 100, 0.5, a = 80, b = 150), tolerance = epsilon) expect_equal(cumsum(dzip(xx, 70, 0.5)), pzip(xx, 70, 0.5), tolerance = epsilon) expect_equal(cumsum(dzib(xx, 200, 0.5, 0.5)), pzib(xx, 200, 0.5, 0.5), tolerance = epsilon) expect_equal(cumsum(dzinb(xx, 70, 0.5, 0.5)), pzinb(xx, 70, 0.5, 0.5), tolerance = epsilon) expect_equal(cumsum(dmixpois(xx, c(40,50,70), c(1/3,1/3,1/3))), pmixpois(xx, c(40,50,70), c(1/3,1/3,1/3)), tolerance = epsilon) }) extraDistr/tests/testthat/test-non-negative.R0000755000176200001440000000370214523122435021105 0ustar liggesuserstest_that("Zero probabilities for values <0", { expect_equal(c(0, 0), dbetapr(c(-1, 0), 1, 1, 1)) expect_equal(0, ddweibull(-1, 0.5, 1)) expect_equal(0, ddunif(-1, 0, 5)) expect_equal(0, dcat(-1, c(0.5, 0.5))) expect_equal(0, dmnom(c(-1, 1), 5, c(0.5, 0.5))) expect_warning(expect_equal(0, dbern(-1))) expect_equal(0, dbbinom(-1, 1, 1, 1)) expect_equal(0, dbnbinom(-1, 1, 1, 1)) expect_equal(0, dgpois(-1, 1, 1)) expect_equal(0, dmvhyper(c(1, 1, -1), c(2, 2, 2), 3)) expect_equal(0, dzip(-1, 1, 0.5)) expect_equal(0, dzib(-1, 1, 0.5, 0.5)) expect_equal(0, dzinb(-1, 1, 0.5, 0.5)) expect_equal(0, dbvpois(-1, 1, 1, 1, 1)) expect_equal(0, dbvpois(1, -1, 1, 1, 1)) expect_equal(0, dinvchisq(-1, 1)) expect_equal(0, dinvchisq(-1, 1, 1)) expect_equal(0, dinvgamma(-1, 1, 1)) expect_equal(0, dgompertz(-1, 1, 1)) expect_equal(0, dgpois(-1, 1, 1)) expect_equal(0, dlomax(-1, 1, 1)) expect_equal(0, dpower(-1, 1, 0.5)) expect_equal(0, dsgomp(-1, 0.4, 1)) expect_equal(0, drayleigh(-1, 1)) expect_equal(0, dwald(-1, 1, 1)) expect_equal(0, dhcauchy(-1, 1)) expect_equal(0, dhnorm(-1, 1)) expect_equal(0, dht(-1, 5, 1)) expect_equal(0, dmixpois(-1, c(1, 2, 3), c(1 / 3, 1 / 3, 1 / 3))) expect_equal(0, dtpois(-1, lambda = 5, a = 6)) expect_equal(0, dnhyper(-1, 60, 35, 15)) expect_equal(0, ddgamma(-1, 9, 1)) }) test_that("Zero probabilities for values x < mean", { expect_equal(0, dfatigue(-1, 1, 1, 0)) expect_equal(0, dfrechet(-1, 1, 0, 1)) expect_equal(0, dgpd(-1, 0, 1, 1)) }) test_that("Zero probabilities for values < 1", { expect_equal(c(0, 0), dlgser(c(-1, 0), 0.5)) expect_equal(c(0, 0), dpareto(c(-1, 0), 1, 1)) expect_equal(c(0, 0), dtpois(c(-1, 0), lambda = 5, a = 0)) }) test_that("No negative samples for distributions with positive support", { set.seed(42) expect_true(all(rgpd(1000, xi = 0) > 0)) expect_true(all(rgpd(1000, xi = 0.1) > 0)) expect_true(all(rgpd(1000, xi = -0.1) > 0)) }) extraDistr/tests/testthat/test-infinity.R0000755000176200001440000003114514475546572020370 0ustar liggesusers test_that("Testing PDFs & PMFs against infinite values", { expect_true(!is.nan(dbetapr(Inf, 1, 1, 1)) && is.finite(dbetapr(Inf, 1, 1, 1))) expect_true(!is.nan(dbbinom(Inf, 10, 1, 1)) && is.finite(dbbinom(Inf, 10, 1, 1))) expect_true(!is.nan(dbnbinom(Inf, 10, 1, 1)) && is.finite(dbnbinom(Inf, 10, 1, 1))) expect_true(!is.nan(dbhatt(Inf)) && is.finite(dbhatt(Inf))) expect_true(!is.nan(dfatigue(Inf, 1)) && is.finite(dfatigue(Inf, 1))) expect_true(!is.nan(dcat(Inf, c(0.5, 0.5))) && is.finite(dcat(Inf, c(0.5, 0.5)))) expect_true(!is.nan(ddlaplace(Inf, 0, 0.5)) && is.finite(ddlaplace(Inf, 0, 0.5))) expect_true(!is.nan(ddnorm(Inf)) && is.finite(ddnorm(Inf))) expect_true(!is.nan(ddgamma(Inf, 9, 1) && is.finite(ddgamma(Inf, 9, 1)))) expect_true(!is.nan(ddweibull(Inf, 0.5, 1)) && is.finite(ddweibull(Inf, 0.5, 1))) expect_true(!is.nan(dfrechet(Inf)) && is.finite(dfrechet(Inf))) expect_true(!is.nan(dgpois(Inf, 1, 1)) && is.finite(dgpois(Inf, 1, 1))) expect_true(!is.nan(dgev(Inf, 1, 1, 1)) && is.finite(dgev(Inf, 1, 1, 1))) expect_true(!is.nan(dgompertz(Inf, 1, 1)) && is.finite(dgompertz(Inf, 1, 1))) expect_true(!is.nan(dgpd(Inf, 1, 1, 1)) && is.finite(dgpd(Inf, 1, 1, 1))) expect_true(!is.nan(dgumbel(Inf)) && is.finite(dgumbel(Inf))) expect_true(!is.nan(dhuber(Inf)) && is.finite(dhuber(Inf))) expect_true(!is.nan(dhcauchy(Inf, 1)) && is.finite(dhcauchy(Inf, 1))) expect_true(!is.nan(dhnorm(Inf, 1)) && is.finite(dhnorm(Inf, 1))) expect_true(!is.nan(dht(Inf, 5, 1)) && is.finite(dht(Inf, 5, 1))) expect_true(!is.nan(dinvgamma(Inf, 1, 1)) && is.finite(dinvgamma(Inf, 1, 1))) expect_true(!is.nan(dlaplace(Inf)) && is.finite(dlaplace(Inf))) expect_true(!is.nan(dlgser(Inf, 0.5)) && is.finite(dlgser(Inf, 0.5))) expect_true(!is.nan(dlomax(Inf, 1, 1)) && is.finite(dlomax(Inf, 1, 1))) expect_true(!is.nan(dmixnorm(Inf, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3))) && is.finite(dmixnorm(Inf, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(!is.nan(dmixpois(Inf, c(1,2,3), c(1/3,1/3,1/3))) && is.finite(dmixpois(Inf, c(1,2,3), c(1/3,1/3,1/3)))) expect_true(!is.nan(dnhyper(Inf, 60, 35, 15)) && is.finite(dnhyper(Inf, 60, 35, 15))) expect_true(!is.nan(dlst(Inf, df = 2)) && is.finite(dlst(Inf, df = 2))) expect_true(!is.nan(dpareto(Inf)) && is.finite(dpareto(Inf))) expect_true(!is.nan(dpower(Inf, 1, 1)) && is.finite(dpower(Inf, 1, 1))) expect_true(!is.nan(dprop(Inf, 10, 0.5)) && is.finite(dprop(Inf, 10, 0.5))) expect_true(!is.nan(drayleigh(Inf)) && is.finite(drayleigh(Inf))) expect_true(!is.nan(dsgomp(Inf, 0.4, 1)) && is.finite(dsgomp(Inf, 0.4, 1))) expect_true(!is.nan(dslash(Inf)) && is.finite(dslash(Inf))) expect_true(!is.nan(dtpois(Inf, lambda = 5)) && is.finite(dtpois(Inf, lambda = 5))) expect_true(!is.nan(dtpois(Inf, lambda = 5, a = 6)) && is.finite(dtpois(Inf, lambda = 5, a = 6))) expect_true(!is.nan(dwald(Inf, 1, 1)) && is.finite(dwald(Inf, 1, 1))) expect_true(!is.nan(dzip(Inf, 1, 0.5)) && is.finite(dzip(Inf, 1, 0.5))) expect_true(!is.nan(dzib(Inf, 1, 1, 0.5)) && is.finite(dzinb(Inf, 1, 1, 0.5))) expect_true(!is.nan(dzinb(Inf, 1, 1, 0.5)) && is.finite(dzinb(Inf, 1, 1, 0.5))) }) test_that("Testing CDFs against infinite values", { expect_true(!is.nan(pbetapr(Inf, 1, 1, 1)) && is.finite(pbetapr(Inf, 1, 1, 1))) expect_true(!is.nan(pbbinom(Inf, 10, 1, 1)) && is.finite(pbbinom(Inf, 10, 1, 1))) expect_true(!is.nan(pbnbinom(Inf, 10, 1, 1)) && is.finite(pbnbinom(Inf, 10, 1, 1))) expect_true(!is.nan(pbhatt(Inf)) && is.finite(pbhatt(Inf))) expect_true(!is.nan(pfatigue(Inf, 1)) && is.finite(pfatigue(Inf, 1))) expect_true(!is.nan(pcat(Inf, c(0.5, 0.5))) && is.finite(pcat(Inf, c(0.5, 0.5)))) expect_true(!is.nan(pdlaplace(Inf, 0, 0.5)) && is.finite(pdlaplace(Inf, 0, 0.5))) expect_true(!is.nan(pdnorm(Inf)) && is.finite(pdnorm(Inf))) expect_true(!is.nan(pdgamma(Inf, 9, 1) && is.finite(pdgamma(Inf, 9, 1)))) expect_true(!is.nan(pdweibull(Inf, 0.5, 1)) && is.finite(pdweibull(Inf, 0.5, 1))) expect_true(!is.nan(pfrechet(Inf)) && is.finite(pfrechet(Inf))) expect_true(!is.nan(pgpois(Inf, 1, 1)) && is.finite(pgpois(Inf, 1, 1))) expect_true(!is.nan(pgev(Inf, 1, 1, 1)) && is.finite(pgev(Inf, 1, 1, 1))) expect_true(!is.nan(pgompertz(Inf, 1, 1)) && is.finite(pgompertz(Inf, 1, 1))) expect_true(!is.nan(pgpd(Inf, 1, 1, 1)) && is.finite(pgpd(Inf, 1, 1, 1))) expect_true(!is.nan(pgumbel(Inf)) && is.finite(pgumbel(Inf))) expect_true(!is.nan(phuber(Inf)) && is.finite(phuber(Inf))) expect_true(!is.nan(phcauchy(Inf, 1)) && is.finite(phcauchy(Inf, 1))) expect_true(!is.nan(phnorm(Inf, 1)) && is.finite(phnorm(Inf, 1))) expect_true(!is.nan(pht(Inf, 5, 1)) && is.finite(pht(Inf, 5, 1))) expect_true(!is.nan(pinvgamma(Inf, 1, 1)) && is.finite(pinvgamma(Inf, 1, 1))) expect_true(!is.nan(plaplace(Inf)) && is.finite(plaplace(Inf))) expect_true(!is.nan(plgser(Inf, 0.5)) && is.finite(plgser(Inf, 0.5))) expect_true(!is.nan(plomax(Inf, 1, 1)) && is.finite(plomax(Inf, 1, 1))) expect_true(!is.nan(pmixnorm(Inf, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3))) && is.finite(pmixnorm(Inf, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(!is.nan(pmixpois(Inf, c(1,2,3), c(1/3,1/3,1/3))) && is.finite(pmixpois(Inf, c(1,2,3), c(1/3,1/3,1/3)))) expect_true(!is.nan(pnhyper(Inf, 60, 35, 15)) && is.finite(pnhyper(Inf, 60, 35, 15))) expect_true(!is.nan(plst(Inf, df = 2)) && is.finite(plst(Inf, df = 2))) expect_true(!is.nan(ppareto(Inf)) && is.finite(ppareto(Inf))) expect_true(!is.nan(ppower(Inf, 1, 1)) && is.finite(ppower(Inf, 1, 1))) expect_true(!is.nan(pprop(Inf, 10, 0.5)) && is.finite(pprop(Inf, 10, 0.5))) expect_true(!is.nan(prayleigh(Inf)) && is.finite(prayleigh(Inf))) expect_true(!is.nan(psgomp(Inf, 0.4, 1)) && is.finite(psgomp(Inf, 0.4, 1))) expect_true(!is.nan(pslash(Inf)) && is.finite(pslash(Inf))) expect_true(!is.nan(ptpois(Inf, lambda = 5)) && is.finite(ptpois(Inf, lambda = 5))) expect_true(!is.nan(ptpois(Inf, lambda = 5, a = 6)) && is.finite(ptpois(Inf, lambda = 5, a = 6))) expect_true(!is.nan(pwald(Inf, 1, 1)) && is.finite(pwald(Inf, 1, 1))) expect_true(!is.nan(pzip(Inf, 1, 0.5)) && is.finite(pzip(Inf, 1, 0.5))) expect_true(!is.nan(pzib(Inf, 1, 1, 0.5)) && is.finite(pzinb(Inf, 1, 1, 0.5))) expect_true(!is.nan(pzinb(Inf, 1, 1, 0.5)) && is.finite(pzinb(Inf, 1, 1, 0.5))) }) test_that("Testing PDFs & PMFs against negatively infinite values", { expect_true(!is.nan(dbetapr(-Inf, 1, 1, 1)) && is.finite(dbetapr(-Inf, 1, 1, 1))) expect_true(!is.nan(dbbinom(-Inf, 10, 1, 1)) && is.finite(dbbinom(-Inf, 10, 1, 1))) expect_true(!is.nan(dbnbinom(-Inf, 10, 1, 1)) && is.finite(dbnbinom(-Inf, 10, 1, 1))) expect_true(!is.nan(dbhatt(-Inf)) && is.finite(dbhatt(-Inf))) expect_true(!is.nan(dfatigue(-Inf, 1)) && is.finite(dfatigue(-Inf, 1))) expect_true(!is.nan(dcat(-Inf, c(0.5, 0.5))) && is.finite(dcat(-Inf, c(0.5, 0.5)))) expect_true(!is.nan(ddlaplace(-Inf, 0, 0.5)) && is.finite(ddlaplace(-Inf, 0, 0.5))) expect_true(!is.nan(ddnorm(-Inf)) && is.finite(ddnorm(-Inf))) expect_true(!is.nan(ddgamma(-Inf, 9, 1) && is.finite(ddgamma(-Inf, 9, 1)))) expect_true(!is.nan(ddweibull(-Inf, 0.5, 1)) && is.finite(ddweibull(-Inf, 0.5, 1))) expect_true(!is.nan(dfrechet(-Inf)) && is.finite(dfrechet(-Inf))) expect_true(!is.nan(dgpois(-Inf, 1, 1)) && is.finite(dgpois(-Inf, 1, 1))) expect_true(!is.nan(dgev(-Inf, 1, 1, 1)) && is.finite(dgev(-Inf, 1, 1, 1))) expect_true(!is.nan(dgompertz(-Inf, 1, 1)) && is.finite(dgompertz(-Inf, 1, 1))) expect_true(!is.nan(dgpd(-Inf, 1, 1, 1)) && is.finite(dgpd(-Inf, 1, 1, 1))) expect_true(!is.nan(dgumbel(-Inf)) && is.finite(dgumbel(-Inf))) expect_true(!is.nan(dhuber(-Inf)) && is.finite(dhuber(-Inf))) expect_true(!is.nan(dhcauchy(-Inf, 1)) && is.finite(dhcauchy(-Inf, 1))) expect_true(!is.nan(dhnorm(-Inf, 1)) && is.finite(dhnorm(-Inf, 1))) expect_true(!is.nan(dht(-Inf, 5, 1)) && is.finite(dht(-Inf, 5, 1))) expect_true(!is.nan(dinvgamma(-Inf, 1, 1)) && is.finite(dinvgamma(-Inf, 1, 1))) expect_true(!is.nan(dlaplace(-Inf)) && is.finite(dlaplace(-Inf))) expect_true(!is.nan(dlgser(-Inf, 0.5)) && is.finite(dlgser(-Inf, 0.5))) expect_true(!is.nan(dlomax(-Inf, 1, 1)) && is.finite(dlomax(-Inf, 1, 1))) expect_true(!is.nan(dmixnorm(-Inf, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3))) && is.finite(dmixnorm(-Inf, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(!is.nan(dmixpois(-Inf, c(1,2,3), c(1/3,1/3,1/3))) && is.finite(dmixpois(-Inf, c(1,2,3), c(1/3,1/3,1/3)))) expect_true(!is.nan(dnhyper(-Inf, 60, 35, 15)) && is.finite(dnhyper(-Inf, 60, 35, 15))) expect_true(!is.nan(dlst(-Inf, df = 2)) && is.finite(dlst(-Inf, df = 2))) expect_true(!is.nan(dpareto(-Inf)) && is.finite(dpareto(-Inf))) expect_true(!is.nan(dpower(-Inf, 1, 1)) && is.finite(dpower(-Inf, 1, 1))) expect_true(!is.nan(dprop(-Inf, 10, 0.5)) && is.finite(dprop(-Inf, 10, 0.5))) expect_true(!is.nan(drayleigh(-Inf)) && is.finite(drayleigh(-Inf))) expect_true(!is.nan(dsgomp(-Inf, 0.4, 1)) && is.finite(dsgomp(-Inf, 0.4, 1))) expect_true(!is.nan(dslash(-Inf)) && is.finite(dslash(-Inf))) expect_true(!is.nan(dtpois(-Inf, lambda = 5)) && is.finite(dtpois(-Inf, lambda = 5))) expect_true(!is.nan(dtpois(-Inf, lambda = 5, a = 6)) && is.finite(dtpois(-Inf, lambda = 5, a = 6))) expect_true(!is.nan(dwald(-Inf, 1, 1)) && is.finite(dwald(-Inf, 1, 1))) expect_true(!is.nan(dzip(-Inf, 1, 0.5)) && is.finite(dzip(-Inf, 1, 0.5))) expect_true(!is.nan(dzib(-Inf, 1, 1, 0.5)) && is.finite(dzinb(-Inf, 1, 1, 0.5))) expect_true(!is.nan(dzinb(-Inf, 1, 1, 0.5)) && is.finite(dzinb(-Inf, 1, 1, 0.5))) }) test_that("Testing CDFs against negatively infinite values", { expect_true(!is.nan(pbetapr(-Inf, 1, 1, 1)) && is.finite(pbetapr(-Inf, 1, 1, 1))) expect_true(!is.nan(pbbinom(-Inf, 10, 1, 1)) && is.finite(pbbinom(-Inf, 10, 1, 1))) expect_true(!is.nan(pbnbinom(-Inf, 10, 1, 1)) && is.finite(pbnbinom(-Inf, 10, 1, 1))) expect_true(!is.nan(pbhatt(-Inf)) && is.finite(pbhatt(-Inf))) expect_true(!is.nan(pfatigue(-Inf, 1)) && is.finite(pfatigue(-Inf, 1))) expect_true(!is.nan(pcat(-Inf, c(0.5, 0.5))) && is.finite(pcat(-Inf, c(0.5, 0.5)))) expect_true(!is.nan(pdlaplace(-Inf, 0, 0.5)) && is.finite(pdlaplace(-Inf, 0, 0.5))) expect_true(!is.nan(pdnorm(-Inf)) && is.finite(pdnorm(-Inf))) expect_true(!is.nan(pdgamma(-Inf, 9, 1) && is.finite(pdgamma(-Inf, 9, 1)))) expect_true(!is.nan(pdweibull(-Inf, 0.5, 1)) && is.finite(pdweibull(-Inf, 0.5, 1))) expect_true(!is.nan(pfrechet(-Inf)) && is.finite(pfrechet(-Inf))) expect_true(!is.nan(pgpois(-Inf, 1, 1)) && is.finite(pgpois(-Inf, 1, 1))) expect_true(!is.nan(pgev(-Inf, 1, 1, 1)) && is.finite(pgev(-Inf, 1, 1, 1))) expect_true(!is.nan(pgompertz(-Inf, 1, 1)) && is.finite(pgompertz(-Inf, 1, 1))) expect_true(!is.nan(pgpd(-Inf, 1, 1, 1)) && is.finite(pgpd(-Inf, 1, 1, 1))) expect_true(!is.nan(pgumbel(-Inf)) && is.finite(pgumbel(-Inf))) expect_true(!is.nan(phuber(-Inf)) && is.finite(phuber(-Inf))) expect_true(!is.nan(phcauchy(-Inf, 1)) && is.finite(phcauchy(-Inf, 1))) expect_true(!is.nan(phnorm(-Inf, 1)) && is.finite(phnorm(-Inf, 1))) expect_true(!is.nan(pht(-Inf, 5, 1)) && is.finite(pht(-Inf, 5, 1))) expect_true(!is.nan(pinvgamma(-Inf, 1, 1)) && is.finite(pinvgamma(-Inf, 1, 1))) expect_true(!is.nan(plaplace(-Inf)) && is.finite(plaplace(-Inf))) expect_true(!is.nan(plgser(-Inf, 0.5)) && is.finite(plgser(-Inf, 0.5))) expect_true(!is.nan(plomax(-Inf, 1, 1)) && is.finite(plomax(-Inf, 1, 1))) expect_true(!is.nan(pmixnorm(-Inf, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3))) && is.finite(pmixnorm(-Inf, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(!is.nan(pmixpois(-Inf, c(1,2,3), c(1/3,1/3,1/3))) && is.finite(pmixpois(-Inf, c(1,2,3), c(1/3,1/3,1/3)))) expect_true(!is.nan(pnhyper(-Inf, 60, 35, 15)) && is.finite(pnhyper(-Inf, 60, 35, 15))) expect_true(!is.nan(plst(-Inf, df = 2)) && is.finite(plst(-Inf, df = 2))) expect_true(!is.nan(ppareto(-Inf)) && is.finite(ppareto(-Inf))) expect_true(!is.nan(ppower(-Inf, 1, 1)) && is.finite(ppower(-Inf, 1, 1))) expect_true(!is.nan(pprop(-Inf, 10, 0.5)) && is.finite(pprop(-Inf, 10, 0.5))) expect_true(!is.nan(prayleigh(-Inf)) && is.finite(prayleigh(-Inf))) expect_true(!is.nan(psgomp(-Inf, 0.4, 1)) && is.finite(psgomp(-Inf, 0.4, 1))) expect_true(!is.nan(pslash(-Inf)) && is.finite(pslash(-Inf))) expect_true(!is.nan(ptpois(-Inf, lambda = 5)) && is.finite(ptpois(-Inf, lambda = 5))) expect_true(!is.nan(ptpois(-Inf, lambda = 5, a = 6)) && is.finite(ptpois(-Inf, lambda = 5, a = 6))) expect_true(!is.nan(pwald(-Inf, 1, 1)) && is.finite(pwald(-Inf, 1, 1))) expect_true(!is.nan(pzip(-Inf, 1, 0.5)) && is.finite(pzip(-Inf, 1, 0.5))) expect_true(!is.nan(pzib(-Inf, 1, 1, 0.5)) && is.finite(pzinb(-Inf, 1, 1, 0.5))) expect_true(!is.nan(pzinb(-Inf, 1, 1, 0.5)) && is.finite(pzinb(-Inf, 1, 1, 0.5))) }) extraDistr/tests/testthat/test_vectorization.R0000644000176200001440000000050014475546572021505 0ustar liggesusers test_that("Fix for #16 works", { test_dat <- data.frame( q = c(1, 10, 10, 100), size = c(10, 100, 1000, 1000) ) # This failed in #16 testthat::expect_visible(with( test_dat, pbbinom(q, size, 1, 1) )) testthat::expect_visible(with( test_dat, pbnbinom(q, size, 1, 1) )) }) extraDistr/tests/testthat/test-multivariate-distributions.R0000755000176200001440000000412214475546572024140 0ustar liggesusers # extraDistr::ddirichlet was compared to MCMCpack::ddirichlet test_that("Testing multivariate distributions", { skip_on_cran() expect_true(all.equal(rowSums(rmnom(5000, 50, c(2/10, 5/10, 3/10))), rep(50, 5000))) expect_true(all.equal(rowSums(rdirichlet(5000, c(2/10, 5/10, 3/10))), rep(1.0, 5000))) xx <- expand.grid(0:20, 0:20, 0:20) expect_equal(sum(ddirmnom(xx[rowSums(xx) == 20,], 20, c(2, 5, 3))), 1) expect_equal(sum(dmnom(xx[rowSums(xx) == 20,], 20, c(2/10, 5/10, 3/10))), 1) expect_equal(sum(dmvhyper(xx[rowSums(xx) == 35,], c(20, 20, 20), 35)), 1) p <- c(4, 5, 1, 6, 2) expect_equal(prop.table(colSums(rmnom(1e5, 100, p/sum(p)))), p/sum(p), tolerance = 1e-2) expect_equal(as.numeric(prop.table(table(rcat(1e5, p/sum(p))))), p/sum(p), tolerance = 1e-2) expect_equal(prop.table(colSums(rdirichlet(1e5, p))), p/sum(p), tolerance = 1e-2) expect_equal(prop.table(colSums(rdirmnom(1e5, 100, p))), p/sum(p), tolerance = 1e-2) n <- c(11, 24, 43, 7, 56) expect_equal(prop.table(colSums(rmvhyper(1e5, n, 100))), n/sum(n), tolerance = 1e-2) }) test_that("Evaluate wrong parameters first", { expect_warning(expect_true(is.nan(dbvpois(-1, -1, -1, 1, 1)))) expect_warning(expect_true(is.nan(ddirichlet(c(2, 2), c(-1, 0.5))))) expect_warning(expect_true(is.nan(ddirmnom(c(-1, 1, 1), 1.5, c(1, 1, 1))))) expect_warning(expect_true(is.nan(dmnom(c(-1, 1, 1), 1.5, c(1/3, 1/3, 1/3))))) expect_warning(expect_true(is.nan(dmvhyper(c(-1, 2, 2), c(2,3,4), -5)))) }) test_that("Check if rmnom and rdirmnom deal with underflow (#3, #7)", { skip_on_cran() expect_false(anyNA(rmnom(5000, 100, c(0.504115095275327, 2.669522645838e-39, 0, 2.58539638831141, 0)))) expect_false(anyNA(rdirmnom(5000, 100, c(1.480592e+00, 1.394943e-03, 4.529932e-06, 3.263573e+00, 4.554952e-06)))) p <- c(0, 0, 1, 0, 2.77053929981958e-18) expect_false(anyNA(rmnom(5000, 100, p))) expect_false(anyNA(rdirmnom(5000, 100, p + 1e-5))) }) extraDistr/tests/testthat/helper_pure_r_implementations.R0000755000176200001440000001147014475546572023704 0ustar liggesusers is_int <- function(x) x %% 1 == 0 dbbinomR <- function(k, n, alpha, beta) { ifelse(k<0 | k>n | !is_int(k), 0, choose(n, k) * (beta(k+alpha, n-k+beta)) / (beta(alpha, beta))) } dbnbinomR <- function(k, r, alpha, beta) { ifelse(k<0 | !is_int(k), 0, gamma(r+k)/(factorial(k) * gamma(r)) * beta(alpha+r, beta+k)/beta(alpha, beta)) } dbetaprR <- function(x, alpha, beta, sigma) { z <- x/sigma ifelse(x<=0, 0, z^(alpha-1.0) * (z+1.0)^(-alpha-beta) / beta(alpha, beta) / sigma) } dfatigueR <- function(x, alpha, beta, mu) { z <- x-mu zb <- suppressWarnings(sqrt(z/beta)) # warns when x <= mu bz <- suppressWarnings(sqrt(beta/z)) # warns when x <= mu ifelse(x<=mu, 0, (zb+bz)/(2.0*alpha*z) * dnorm((zb-bz)/alpha)) } ddlaplaceR <- function(x, mu, p) { ifelse(!is_int(x), 0, (1.0-p)/(1.0+p) * p^abs(x-mu)) } ddweibullR <- function(x, q, beta) { ifelse(x<0 | !is_int(x), 0, q^x^beta - q^(x+1)^beta) } dfrechetR <- function(x, lambda, mu, sigma) { z <- (x-mu)/sigma ifelse(x<=mu, 0, lambda/sigma * z^(-1-lambda) * exp(-z^(-lambda))) } dgpoisR <- function(x, alpha, beta) { ifelse(x<0 | !is_int(x), 0, (gamma(x+beta)*alpha^x)/(gamma(beta)*(1+alpha)^(beta+x)*factorial(x))) } dgevR <- function(x, mu, sigma, xi) { z <- (x-mu)/sigma if (xi != 0) { ifelse((1.0+xi*z) <= 0.0, 0, 1/sigma * (1+xi*z)^(-1/xi-1) * exp(-(1+xi*z)^(-1/xi))) } else { ifelse((1.0+xi*z) <= 0.0, 0, 1/sigma * exp(-z) * exp(-exp(-z))) } } dgompertzR <- function(x, a, b) { ifelse(x<0, 0, a*exp(b*x - a/b * (exp(b*x)-1))) } dgpdR <- function(x, mu, sigma, xi) { z <- (x-mu)/sigma if (xi != 0) { ifelse((1.0+xi*z) <= 0.0 | z <= 0, 0, (1+xi*z)^(-(xi+1)/xi)/sigma) } else { ifelse((1.0+xi*z) <= 0.0 | z <= 0, 0, exp(-z)/sigma) } } dgumbelR <- function(x, mu, sigma) { z <- (x-mu)/sigma 1/sigma * exp(-(z+exp(-z))) } dgumbelR_log <- function(x, mu, sigma) { z <- (x-mu)/sigma exp(-(z+exp(-z)) - log(sigma)) } dinvgammaR <- function(x, alpha, beta) { ifelse(x<=0, 0, (beta^alpha * x^(-alpha-1) * exp(-beta/x)) / gamma(alpha)) } dlaplaceR <- function(x, mu, sigma) { z <- (x-mu)/sigma 1/(2*sigma) * exp(-abs(z)) } dlaplaceR_log <- function(x, mu, sigma) { LOG_2F <- 0.6931471805599452862268 z <- abs(x-mu)/sigma exp(-z - LOG_2F - log(sigma)) } dlgserR <- function(x, theta) { ifelse(x<1 | !is_int(x), 0, (-1/log(1-theta)*theta^x) / x) } dlgserR_log <- function(x, theta) { a <- suppressWarnings(-1.0/log1p(-theta)) ifelse(x<1 | !is_int(x), 0, exp(log(a) + (log(theta) * x) - log(x))) } dlomaxR <- function(x, lambda, kappa) { ifelse(x<=0, 0, lambda*kappa / (1+lambda*x)^(kappa+1)) } dparetoR <- function(x, a, b) { ifelse(x=alpha, 0, (beta*x^(beta-1)) / (alpha^beta)) } drayleighR <- function(x, sigma) { ifelse(x<=0, 0, x/sigma^2 * exp(-(x^2 / 2*sigma^2))) } dsgompR <- function(x, b, eta) { ebx <- exp(-b*x) ifelse(x<0, 0, b*ebx * exp(-eta*ebx) * (1 + eta*(1 - ebx))) } # Below code was taken from bivpois package ver 0.50-3 (CRAN archive) pbivpois <- function(x, y=NULL, a, b, c, log=FALSE) { # ------------------------------------------------------------------------------ # Karlis and Ntzoufras (2003, 2004) # EM algorithms for Bivariate Poisson Models # ------------------------------------------------------------------------------ # x : matrix or vector of length n # y : vector of length n. If x is matrix then it is not used # lambda : parameters of the bivariate poisson distribution # log : argument controlling the calculation of the log-probability or the # probability function. # ------------------------------------------------------------------------------ # lambda <- c(a, b, c) # edited here if ( is.matrix(x) ) { var1<-x[,1] var2<-x[,2] } else if (is.vector(x)&is.vector(y)){ if (length(x)==length(y)){ var1<-x var2<-y } else{ stop('lengths of x and y are not equal') } } else{ stop('x is not a matrix or x and y are not vectors') } n <- length(var1) logbp<-vector(length=n) # for (k in 1:n){ x0<-var1[k] y0<-var2[k] xymin<-min( x0,y0 ) lambdaratio<-lambda[3]/(lambda[1]*lambda[2]) # i<-0:xymin sums<- -lgamma(var1[k]-i+1)-lgamma(i+1)-lgamma(var2[k]-i+1)+i*log(lambdaratio) maxsums <- max(sums) sums<- sums - maxsums logsummation<- log( sum(exp(sums)) ) + maxsums logbp[k]<- -sum(lambda) + var1[k] * log( lambda[1] ) + var2[k] * log( lambda[2] ) + logsummation } if (log) { result<- logbp } else { result<-exp(logbp) } result # end of function bivpois } extraDistr/tests/testthat/test-NAs.R0000755000176200001440000007343114475546572017224 0ustar liggesusers test_that("Missing values in PDF and PMF functions", { expect_true(is.na(dbbinom(NA, 1, 1, 1))) expect_true(is.na(dbbinom(1, NA, 1, 1))) expect_true(is.na(dbbinom(1, 1, NA, 1))) expect_true(is.na(dbbinom(1, 1, 1, NA))) expect_true(is.na(dbern(NA, 0.5))) expect_true(is.na(dbern(1, NA))) expect_true(is.na(dbetapr(NA, 1, 1, 1))) expect_true(is.na(dbetapr(1, NA, 1, 1))) expect_true(is.na(dbetapr(1, 1, NA, 1))) expect_true(is.na(dbetapr(1, 1, 1, NA))) expect_true(is.na(dbhatt(NA, 1, 1, 1))) expect_true(is.na(dbhatt(1, NA, 1, 1))) expect_true(is.na(dbhatt(1, 1, NA, 1))) expect_true(is.na(dbhatt(1, 1, 1, NA))) expect_true(is.na(dbnbinom(NA, 1, 1, 1))) expect_true(is.na(dbnbinom(1, NA, 1, 1))) expect_true(is.na(dbnbinom(1, 1, NA, 1))) expect_true(is.na(dbnbinom(1, 1, 1, NA))) expect_true(is.na(dbvnorm(NA, 1, 1, 1, 1, 1, 0.5))) expect_true(is.na(dbvnorm(1, NA, 1, 1, 1, 1, 0.5))) expect_true(is.na(dbvnorm(1, 1, NA, 1, 1, 1, 0.5))) expect_true(is.na(dbvnorm(1, 1, 1, NA, 1, 1, 0.5))) expect_true(is.na(dbvnorm(1, 1, 1, 1, NA, 1, 0.5))) expect_true(is.na(dbvnorm(1, 1, 1, 1, 1, NA, 0.5))) expect_true(is.na(dbvnorm(1, 1, 1, 1, 1, 1, NA))) expect_true(is.na(dbvpois(NA, 1, 1, 1, 1))) expect_true(is.na(dbvpois(1, NA, 1, 1, 1))) expect_true(is.na(dbvpois(1, 1, NA, 1, 1))) expect_true(is.na(dbvpois(1, 1, 1, NA, 1))) expect_true(is.na(dbvpois(1, 1, 1, 1, NA))) expect_true(is.na(dcat(NA, c(0.5, 0.5)))) expect_true(is.na(dcat(1, c(NA, 0.5)))) expect_true(is.na(dcat(1, c(0.5, NA)))) expect_true(is.na(ddirichlet(c(NA, 0.5), c(0.5, 0.5)))) expect_true(is.na(ddirichlet(c(0.5, NA), c(0.5, 0.5)))) expect_true(is.na(ddirichlet(c(0.5, 0.5), c(NA, 0.5)))) expect_true(is.na(ddirichlet(c(0.5, 0.5), c(0.5, NA)))) expect_true(is.na(ddlaplace(NA, 1, 1))) expect_true(is.na(ddlaplace(1, NA, 1))) expect_true(is.na(ddlaplace(1, 1, NA))) expect_true(is.na(ddnorm(NA, 1, 1))) expect_true(is.na(ddnorm(1, NA, 1))) expect_true(is.na(ddnorm(1, 1, NA))) expect_true(is.na(ddgamma(NA, 9, 1))) expect_true(is.na(ddgamma(1, NA, 1))) expect_true(is.na(ddgamma(1, 9, NA))) expect_true(is.na(ddunif(NA, 1, 10))) expect_true(is.na(ddunif(1, NA, 10))) expect_true(is.na(ddunif(1, 1, NA))) expect_true(is.na(ddweibull(NA, 1, 1))) expect_true(is.na(ddweibull(1, NA, 1))) expect_true(is.na(ddweibull(1, 1, NA))) expect_true(is.na(dfatigue(NA, 1, 1))) expect_true(is.na(dfatigue(1, NA, 1))) expect_true(is.na(dfatigue(1, 1, NA))) expect_true(is.na(dfrechet(NA, 1, 1, 1))) expect_true(is.na(dfrechet(1, NA, 1, 1))) expect_true(is.na(dfrechet(1, 1, NA, 1))) expect_true(is.na(dfrechet(1, 1, 1, NA))) expect_true(is.na(dgev(NA, 1, 1, 1))) expect_true(is.na(dgev(1, NA, 1, 1))) expect_true(is.na(dgev(1, 1, NA, 1))) expect_true(is.na(dgev(1, 1, 1, NA))) expect_true(is.na(dgompertz(NA, 1, 1))) expect_true(is.na(dgompertz(1, NA, 1))) expect_true(is.na(dgompertz(1, 1, NA))) expect_true(is.na(dgpd(NA, 1, 1, 1))) expect_true(is.na(dgpd(1, NA, 1, 1))) expect_true(is.na(dgpd(1, 1, NA, 1))) expect_true(is.na(dgpd(1, 1, 1, NA))) expect_true(is.na(dgpois(NA, 1, 1))) expect_true(is.na(dgpois(1, NA, 1))) expect_true(is.na(dgpois(1, 1, NA))) expect_true(is.na(dgumbel(NA, 1, 1))) expect_true(is.na(dgumbel(1, NA, 1))) expect_true(is.na(dgumbel(1, 1, NA))) expect_true(is.na(dhcauchy(NA, 1))) expect_true(is.na(dhcauchy(1, NA))) expect_true(is.na(dhnorm(NA, 1))) expect_true(is.na(dhnorm(1, NA))) expect_true(is.na(dht(NA, 5, 1))) expect_true(is.na(dht(1, NA, 1))) expect_true(is.na(dht(1, 5, NA))) expect_true(is.na(dhuber(NA, 0, 1, 1))) expect_true(is.na(dhuber(1, NA, 1, 1))) expect_true(is.na(dhuber(1, 0, NA, 1))) expect_true(is.na(dhuber(1, 0, 1, NA))) expect_true(is.na(dinvgamma(NA, 1, 1))) expect_true(is.na(dinvgamma(1, NA, 1))) expect_true(is.na(dinvgamma(1, 1, NA))) expect_true(is.na(dinvchisq(NA, 1, 1))) expect_true(is.na(dinvchisq(1, NA, 1))) expect_true(is.na(dinvchisq(1, 1, NA))) expect_true(is.na(dkumar(NA, 1, 1))) expect_true(is.na(dkumar(0.5, NA, 1))) expect_true(is.na(dkumar(0.5, 1, NA))) expect_true(is.na(dlaplace(NA, 0, 1))) expect_true(is.na(dlaplace(1, NA, 1))) expect_true(is.na(dlaplace(1, 0, NA))) expect_true(is.na(dlgser(NA, 0.5))) expect_true(is.na(dlgser(1, NA))) expect_true(is.na(dlomax(NA, 1, 1))) expect_true(is.na(dlomax(1, NA, 1))) expect_true(is.na(dlomax(1, 1, NA))) expect_true(is.na(dmixnorm(NA, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is.na(dmixnorm(0, c(NA,2,3), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is.na(dmixnorm(0, c(1,NA,3), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is.na(dmixnorm(0, c(1,2,NA), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is.na(dmixnorm(0, c(1,2,3), c(NA,2,3), c(1/3,1/3,1/3)))) expect_true(is.na(dmixnorm(0, c(1,2,3), c(1,NA,3), c(1/3,1/3,1/3)))) expect_true(is.na(dmixnorm(0, c(1,2,3), c(1,2,3), c(NA,1/3,1/3)))) expect_true(is.na(dmixnorm(0, c(1,2,3), c(1,2,3), c(1/3,NA,1/3)))) expect_true(is.na(dmixnorm(0, c(1,2,3), c(1,2,3), c(1/3,1/3,NA)))) expect_true(is.na(dmixpois(NA, c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is.na(dmixpois(0, c(NA,2,3), c(1/3,1/3,1/3)))) expect_true(is.na(dmixpois(0, c(1,NA,3), c(1/3,1/3,1/3)))) expect_true(is.na(dmixpois(0, c(1,2,NA), c(1/3,1/3,1/3)))) expect_true(is.na(dmixpois(0, c(1,2,3), c(NA,1/3,1/3)))) expect_true(is.na(dmixpois(0, c(1,2,3), c(1/3,NA,1/3)))) expect_true(is.na(dmixpois(0, c(1,2,3), c(1/3,1/3,NA)))) expect_true(is.na(dnhyper(NA, 60, 35, 15))) expect_true(is.na(dnhyper(1, NA, 35, 15))) expect_true(is.na(dnhyper(1, 60, NA, 15))) expect_true(is.na(dnhyper(1, 60, 35, NA))) expect_true(is.na(ddirmnom(c(NA, 1, 1), 3, c(1, 1, 1)))) expect_true(is.na(ddirmnom(c(1, NA, 1), 3, c(1, 1, 1)))) expect_true(is.na(ddirmnom(c(1, 1, NA), 3, c(1, 1, 1)))) expect_true(is.na(ddirmnom(c(1, 1, 1), NA, c(1, 1, 1)))) expect_true(is.na(ddirmnom(c(1, 1, 1), 3, c(NA, 1, 1)))) expect_true(is.na(ddirmnom(c(1, 1, 1), 3, c(1, NA, 1)))) expect_true(is.na(ddirmnom(c(1, 1, 1), 3, c(1, 1, NA)))) expect_true(is.na(dmnom(c(NA, 1, 1), 3, c(1/3, 1/3, 1/3)))) expect_true(is.na(dmnom(c(1, NA, 1), 3, c(1/3, 1/3, 1/3)))) expect_true(is.na(dmnom(c(1, 1, NA), 3, c(1/3, 1/3, 1/3)))) expect_true(is.na(dmnom(c(1, 1, 1), NA, c(1/3, 1/3, 1/3)))) expect_true(is.na(dmnom(c(1, 1, 1), 3, c(NA, 1/3, 1/3)))) expect_true(is.na(dmnom(c(1, 1, 1), 3, c(1/3, NA, 1/3)))) expect_true(is.na(dmnom(c(1, 1, 1), 3, c(1/3, 1/3, NA)))) expect_true(is.na(dmvhyper(c(NA, 2, 2), c(2,3,4), 5))) expect_true(is.na(dmvhyper(c(1, NA, 2), c(2,3,4), 5))) expect_true(is.na(dmvhyper(c(1, 2, NA), c(2,3,4), 5))) expect_true(is.na(dmvhyper(c(1, 2, 2), c(NA,3,4), 5))) expect_true(is.na(dmvhyper(c(1, 2, 2), c(2,NA,4), 5))) expect_true(is.na(dmvhyper(c(1, 2, 2), c(2,3,NA), 5))) expect_true(is.na(dmvhyper(c(1, 2, 2), c(2,3,4), NA))) expect_true(is.na(dnsbeta(NA, 1, 1, -2, 2))) expect_true(is.na(dnsbeta(0.5, NA, 1, -2, 2))) expect_true(is.na(dnsbeta(0.5, 1, NA, -2, 2))) expect_true(is.na(dnsbeta(0.5, 1, 1, NA, 2))) expect_true(is.na(dnsbeta(0.5, 1, 1, -2, NA))) expect_true(is.na(dlst(NA, 2, 0, 1))) expect_true(is.na(dlst(1, NA, 0, 1))) expect_true(is.na(dlst(1, 2, NA, 1))) expect_true(is.na(dlst(1, 2, 0, NA))) expect_true(is.na(dpareto(NA, 1, 1))) expect_true(is.na(dpareto(1, NA, 1))) expect_true(is.na(dpareto(1, 1, NA))) expect_true(is.na(dpower(NA, 1, 1))) expect_true(is.na(dpower(1, NA, 1))) expect_true(is.na(dpower(1, 1, NA))) expect_true(is.na(dprop(NA, 10, 0.5))) expect_true(is.na(dprop(1, NA, 0.5))) expect_true(is.na(dprop(1, 10, NA))) expect_true(is.na(drayleigh(NA, 1))) expect_true(is.na(drayleigh(1, NA))) expect_true(is.na(dskellam(NA, 1, 1))) expect_true(is.na(dskellam(1, NA, 1))) expect_true(is.na(dskellam(1, 1, NA))) expect_true(is.na(dsgomp(NA, 0.4, 1))) expect_true(is.na(dsgomp(1, NA, 1))) expect_true(is.na(dsgomp(1, 0.4, NA))) expect_true(is.na(dslash(NA, 1, 1))) expect_true(is.na(dslash(1, NA, 1))) expect_true(is.na(dslash(1, 1, NA))) expect_true(is.na(dtnorm(NA, 0, 1, -2, 2))) expect_true(is.na(dtnorm(1, NA, 1, -2, 2))) expect_true(is.na(dtnorm(1, 0, NA, -2, 2))) expect_true(is.na(dtnorm(1, 0, 1, NA, 2))) expect_true(is.na(dtnorm(1, 0, 1, -2, NA))) expect_true(is.na(dtpois(NA, 5, 0))) expect_true(is.na(dtpois(1, NA, 0))) expect_true(is.na(dtpois(1, 5, NA))) expect_true(is.na(dtriang(NA, 0, 1, 0.5))) expect_true(is.na(dtriang(0.5, NA, 1, 0.5))) expect_true(is.na(dtriang(0.5, 0, NA, 0.5))) expect_true(is.na(dtriang(0.5, 0, 1, NA))) expect_true(is.na(dwald(NA, 1, 1))) expect_true(is.na(dwald(1, NA, 1))) expect_true(is.na(dwald(1, 1, NA))) expect_true(is.na(dzip(NA, 1, 0.5))) expect_true(is.na(dzip(1, NA, 0.5))) expect_true(is.na(dzip(1, 1, NA))) expect_true(is.na(dzib(NA, 1, 0.5, 0.5))) expect_true(is.na(dzib(1, NA, 0.5, 0.5))) expect_true(is.na(dzib(1, 1, NA, 0.5))) expect_true(is.na(dzib(1, 1, 0.5, NA))) expect_true(is.na(dzinb(NA, 1, 0.5, 0.5))) expect_true(is.na(dzinb(1, NA, 0.5, 0.5))) expect_true(is.na(dzinb(1, 1, NA, 0.5))) expect_true(is.na(dzinb(1, 1, 0.5, NA))) }) test_that("Wrong parameter values in CDF functions", { expect_true(is.na(pbbinom(NA, 1, 1, 1))) expect_true(is.na(pbbinom(1, NA, 1, 1))) expect_true(is.na(pbbinom(1, 1, NA, 1))) expect_true(is.na(pbbinom(1, 1, 1, NA))) expect_true(is.na(pbern(NA, 0.5))) expect_true(is.na(pbern(1, NA))) expect_true(is.na(pbetapr(NA, 1, 1, 1))) expect_true(is.na(pbetapr(1, NA, 1, 1))) expect_true(is.na(pbetapr(1, 1, NA, 1))) expect_true(is.na(pbetapr(1, 1, 1, NA))) expect_true(is.na(pbhatt(NA, 1, 1, 1))) expect_true(is.na(pbhatt(1, NA, 1, 1))) expect_true(is.na(pbhatt(1, 1, NA, 1))) expect_true(is.na(pbhatt(1, 1, 1, NA))) expect_true(is.na(pbnbinom(NA, 1, 1, 1))) expect_true(is.na(pbnbinom(1, NA, 1, 1))) expect_true(is.na(pbnbinom(1, 1, NA, 1))) expect_true(is.na(pbnbinom(1, 1, 1, NA))) expect_true(is.na(pcat(NA, c(0.5, 0.5)))) expect_true(is.na(pcat(1, c(NA, 0.5)))) expect_true(is.na(pcat(1, c(0.5, NA)))) expect_true(is.na(pdlaplace(NA, 1, 1))) expect_true(is.na(pdlaplace(1, NA, 1))) expect_true(is.na(pdlaplace(1, 1, NA))) expect_true(is.na(pdnorm(NA, 1, 1))) expect_true(is.na(pdnorm(1, NA, 1))) expect_true(is.na(pdnorm(1, 1, NA))) expect_true(is.na(pdgamma(NA, 9, 1))) expect_true(is.na(pdgamma(1, NA, 1))) expect_true(is.na(pdgamma(1, 9, NA))) expect_true(is.na(pdunif(NA, 1, 10))) expect_true(is.na(pdunif(1, NA, 10))) expect_true(is.na(pdunif(1, 1, NA))) expect_true(is.na(pdweibull(NA, 1, 1))) expect_true(is.na(pdweibull(1, NA, 1))) expect_true(is.na(pdweibull(1, 1, NA))) expect_true(is.na(pfatigue(NA, 1, 1))) expect_true(is.na(pfatigue(1, NA, 1))) expect_true(is.na(pfatigue(1, 1, NA))) expect_true(is.na(pfrechet(NA, 1, 1, 1))) expect_true(is.na(pfrechet(1, NA, 1, 1))) expect_true(is.na(pfrechet(1, 1, NA, 1))) expect_true(is.na(pfrechet(1, 1, 1, NA))) expect_true(is.na(pgev(NA, 1, 1, 1))) expect_true(is.na(pgev(1, NA, 1, 1))) expect_true(is.na(pgev(1, 1, NA, 1))) expect_true(is.na(pgev(1, 1, 1, NA))) expect_true(is.na(pgompertz(NA, 1, 1))) expect_true(is.na(pgompertz(1, NA, 1))) expect_true(is.na(pgompertz(1, 1, NA))) expect_true(is.na(pgpd(NA, 1, 1, 1))) expect_true(is.na(pgpd(1, NA, 1, 1))) expect_true(is.na(pgpd(1, 1, NA, 1))) expect_true(is.na(pgpd(1, 1, 1, NA))) expect_true(is.na(pgpois(NA, 1, 1))) expect_true(is.na(pgpois(1, NA, 1))) expect_true(is.na(pgpois(1, 1, NA))) expect_true(is.na(pgumbel(NA, 1, 1))) expect_true(is.na(pgumbel(1, NA, 1))) expect_true(is.na(pgumbel(1, 1, NA))) expect_true(is.na(phcauchy(NA, 1))) expect_true(is.na(phcauchy(1, NA))) expect_true(is.na(phnorm(NA, 1))) expect_true(is.na(phnorm(1, NA))) expect_true(is.na(pht(NA, 5, 1))) expect_true(is.na(pht(1, NA, 1))) expect_true(is.na(pht(1, 5, NA))) expect_true(is.na(phuber(NA, 0, 1, 1))) expect_true(is.na(phuber(1, NA, 1, 1))) expect_true(is.na(phuber(1, 0, NA, 1))) expect_true(is.na(phuber(1, 0, 1, NA))) expect_true(is.na(pinvgamma(NA, 1, 1))) expect_true(is.na(pinvgamma(1, NA, 1))) expect_true(is.na(pinvgamma(1, 1, NA))) expect_true(is.na(pinvchisq(NA, 1, 1))) expect_true(is.na(pinvchisq(1, NA, 1))) expect_true(is.na(pinvchisq(1, 1, NA))) expect_true(is.na(pkumar(NA, 1, 1))) expect_true(is.na(pkumar(0.5, NA, 1))) expect_true(is.na(pkumar(0.5, 1, NA))) expect_true(is.na(plaplace(NA, 0, 1))) expect_true(is.na(plaplace(1, NA, 1))) expect_true(is.na(plaplace(1, 0, NA))) expect_true(is.na(plgser(NA, 0.5))) expect_true(is.na(plgser(1, NA))) expect_true(is.na(plomax(NA, 1, 1))) expect_true(is.na(plomax(1, NA, 1))) expect_true(is.na(plomax(1, 1, NA))) expect_true(is.na(pmixnorm(NA, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is.na(pmixnorm(0, c(NA,2,3), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is.na(pmixnorm(0, c(1,NA,3), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is.na(pmixnorm(0, c(1,2,NA), c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is.na(pmixnorm(0, c(1,2,3), c(NA,2,3), c(1/3,1/3,1/3)))) expect_true(is.na(pmixnorm(0, c(1,2,3), c(1,NA,3), c(1/3,1/3,1/3)))) expect_true(is.na(pmixnorm(0, c(1,2,3), c(1,2,3), c(NA,1/3,1/3)))) expect_true(is.na(pmixnorm(0, c(1,2,3), c(1,2,3), c(1/3,NA,1/3)))) expect_true(is.na(pmixnorm(0, c(1,2,3), c(1,2,3), c(1/3,1/3,NA)))) expect_true(is.na(pmixpois(NA, c(1,2,3), c(1/3,1/3,1/3)))) expect_true(is.na(pmixpois(0, c(NA,2,3), c(1/3,1/3,1/3)))) expect_true(is.na(pmixpois(0, c(1,NA,3), c(1/3,1/3,1/3)))) expect_true(is.na(pmixpois(0, c(1,2,NA), c(1/3,1/3,1/3)))) expect_true(is.na(pmixpois(0, c(1,2,3), c(NA,1/3,1/3)))) expect_true(is.na(pmixpois(0, c(1,2,3), c(1/3,NA,1/3)))) expect_true(is.na(pmixpois(0, c(1,2,3), c(1/3,1/3,NA)))) expect_true(is.na(pnhyper(NA, 60, 35, 15))) expect_true(is.na(pnhyper(1, NA, 35, 15))) expect_true(is.na(pnhyper(1, 60, NA, 15))) expect_true(is.na(pnhyper(1, 60, 35, NA))) expect_true(is.na(pnsbeta(NA, 1, 1, -2, 2))) expect_true(is.na(pnsbeta(0.5, NA, 1, -2, 2))) expect_true(is.na(pnsbeta(0.5, 1, NA, -2, 2))) expect_true(is.na(pnsbeta(0.5, 1, 1, NA, 2))) expect_true(is.na(pnsbeta(0.5, 1, 1, -2, NA))) expect_true(is.na(plst(NA, 2, 0, 1))) expect_true(is.na(plst(1, NA, 0, 1))) expect_true(is.na(plst(1, 2, NA, 1))) expect_true(is.na(plst(1, 2, 0, NA))) expect_true(is.na(ppareto(NA, 1, 1))) expect_true(is.na(ppareto(1, NA, 1))) expect_true(is.na(ppareto(1, 1, NA))) expect_true(is.na(ppower(NA, 1, 1))) expect_true(is.na(ppower(1, NA, 1))) expect_true(is.na(ppower(1, 1, NA))) expect_true(is.na(pprop(NA, 10, 0.5))) expect_true(is.na(pprop(1, NA, 0.5))) expect_true(is.na(pprop(1, 10, NA))) expect_true(is.na(prayleigh(NA, 1))) expect_true(is.na(prayleigh(1, NA))) expect_true(is.na(psgomp(NA, 0.4, 1))) expect_true(is.na(psgomp(1, NA, 1))) expect_true(is.na(psgomp(1, 0.4, NA))) expect_true(is.na(pslash(NA, 1, 1))) expect_true(is.na(pslash(1, NA, 1))) expect_true(is.na(pslash(1, 1, NA))) expect_true(is.na(ptnorm(NA, 0, 1, -2, 2))) expect_true(is.na(ptnorm(1, NA, 1, -2, 2))) expect_true(is.na(ptnorm(1, 0, NA, -2, 2))) expect_true(is.na(ptnorm(1, 0, 1, NA, 2))) expect_true(is.na(ptnorm(1, 0, 1, -2, NA))) expect_true(is.na(ptpois(NA, 5, 0))) expect_true(is.na(ptpois(1, NA, 0))) expect_true(is.na(ptpois(1, 5, NA))) expect_true(is.na(ptriang(NA, 0, 1, 0.5))) expect_true(is.na(ptriang(0.5, NA, 1, 0.5))) expect_true(is.na(ptriang(0.5, 0, NA, 0.5))) expect_true(is.na(ptriang(0.5, 0, 1, NA))) expect_true(is.na(pwald(NA, 1, 1))) expect_true(is.na(pwald(1, NA, 1))) expect_true(is.na(pwald(1, 1, NA))) expect_true(is.na(pzip(NA, 1, 0.5))) expect_true(is.na(pzip(1, NA, 0.5))) expect_true(is.na(pzip(1, 1, NA))) expect_true(is.na(pzib(NA, 1, 0.5, 0.5))) expect_true(is.na(pzib(1, NA, 0.5, 0.5))) expect_true(is.na(pzib(1, 1, NA, 0.5))) expect_true(is.na(pzib(1, 1, 0.5, NA))) expect_true(is.na(pzinb(NA, 1, 0.5, 0.5))) expect_true(is.na(pzinb(1, NA, 0.5, 0.5))) expect_true(is.na(pzinb(1, 1, NA, 0.5))) expect_true(is.na(pzinb(1, 1, 0.5, NA))) }) test_that("Wrong parameter values in inverse CDF functions", { expect_true(is.na(qbern(NA, 0.5))) expect_true(is.na(qbern(0.5, NA))) expect_true(is.na(qbetapr(NA, 1, 1, 1))) expect_true(is.na(qbetapr(0.5, NA, 1, 1))) expect_true(is.na(qbetapr(0.5, 1, NA, 1))) expect_true(is.na(qbetapr(0.5, 1, 1, NA))) expect_true(is.na(qcat(NA, c(0.5, 0.5)))) expect_true(is.na(qcat(0.5, c(NA, 0.5)))) expect_true(is.na(qcat(0.5, c(0.5, NA)))) expect_true(is.na(qdunif(NA, 1, 10))) expect_true(is.na(qdunif(0.5, NA, 10))) expect_true(is.na(qdunif(0.5, 1, NA))) expect_true(is.na(qdweibull(NA, 1, 1))) expect_true(is.na(qdweibull(0.5, NA, 1))) expect_true(is.na(qdweibull(0.5, 1, NA))) expect_true(is.na(qfatigue(NA, 1, 1))) expect_true(is.na(qfatigue(0.5, NA, 1))) expect_true(is.na(qfatigue(0.5, 1, NA))) expect_true(is.na(qfrechet(NA, 1, 1, 1))) expect_true(is.na(qfrechet(0.5, NA, 1, 1))) expect_true(is.na(qfrechet(0.5, 1, NA, 1))) expect_true(is.na(qfrechet(0.5, 1, 1, NA))) expect_true(is.na(qgev(NA, 1, 1, 1))) expect_true(is.na(qgev(0.5, NA, 1, 1))) expect_true(is.na(qgev(0.5, 1, NA, 1))) expect_true(is.na(qgev(0.5, 1, 1, NA))) expect_true(is.na(qgompertz(NA, 1, 1))) expect_true(is.na(qgompertz(0.5, NA, 1))) expect_true(is.na(qgompertz(0.5, 1, NA))) expect_true(is.na(qgpd(NA, 1, 1, 1))) expect_true(is.na(qgpd(0.5, NA, 1, 1))) expect_true(is.na(qgpd(0.5, 1, NA, 1))) expect_true(is.na(qgpd(0.5, 1, 1, NA))) expect_true(is.na(qgumbel(NA, 1, 1))) expect_true(is.na(qgumbel(0.5, NA, 1))) expect_true(is.na(qgumbel(0.5, 1, NA))) expect_true(is.na(qhcauchy(NA, 1))) expect_true(is.na(qhcauchy(0.5, NA))) expect_true(is.na(qhnorm(NA, 1))) expect_true(is.na(qhnorm(0.5, NA))) expect_true(is.na(qht(NA, 5, 1))) expect_true(is.na(qht(0.5, NA, 1))) expect_true(is.na(qht(0.5, 5, NA))) expect_true(is.na(qhuber(NA, 0, 1, 1))) expect_true(is.na(qhuber(0.5, NA, 1, 1))) expect_true(is.na(qhuber(0.5, 0, NA, 1))) expect_true(is.na(qhuber(0.5, 0, 1, NA))) expect_true(is.na(qinvgamma(NA, 1, 1))) expect_true(is.na(qinvgamma(0.5, NA, 1))) expect_true(is.na(qinvgamma(0.5, 1, NA))) expect_true(is.na(qinvchisq(NA, 1, 1))) expect_true(is.na(qinvchisq(0.5, NA, 1))) expect_true(is.na(qinvchisq(0.5, 1, NA))) expect_true(is.na(qkumar(NA, 1, 1))) expect_true(is.na(qkumar(0.5, NA, 1))) expect_true(is.na(qkumar(0.5, 1, NA))) expect_true(is.na(qlaplace(NA, 0, 1))) expect_true(is.na(qlaplace(0.5, NA, 1))) expect_true(is.na(qlaplace(0.5, 0, NA))) expect_true(is.na(qlgser(NA, 0.5))) expect_true(is.na(qlgser(0.5, NA))) expect_true(is.na(qlomax(NA, 1, 1))) expect_true(is.na(qlomax(0.5, NA, 1))) expect_true(is.na(qlomax(0.5, 1, NA))) expect_true(is.na(qnhyper(NA, 60, 35, 15))) expect_true(is.na(qnhyper(0.5, NA, 35, 15))) expect_true(is.na(qnhyper(0.5, 60, NA, 15))) expect_true(is.na(qnhyper(0.5, 60, 35, NA))) expect_true(is.na(qnsbeta(NA, 1, 1, -2, 2))) expect_true(is.na(qnsbeta(0.5, NA, 1, -2, 2))) expect_true(is.na(qnsbeta(0.5, 1, NA, -2, 2))) expect_true(is.na(qnsbeta(0.5, 1, 1, NA, 2))) expect_true(is.na(qnsbeta(0.5, 1, 1, -2, NA))) expect_true(is.na(qlst(NA, 2, 0, 1))) expect_true(is.na(qlst(0.5, NA, 0, 1))) expect_true(is.na(qlst(0.5, 2, NA, 1))) expect_true(is.na(qlst(0.5, 2, 0, NA))) expect_true(is.na(qpareto(NA, 1, 1))) expect_true(is.na(qpareto(0.5, NA, 1))) expect_true(is.na(qpareto(0.5, 1, NA))) expect_true(is.na(dpower(NA, 1, 1))) expect_true(is.na(dpower(0.5, NA, 1))) expect_true(is.na(dpower(0.5, 1, NA))) expect_true(is.na(qprop(NA, 10, 0.5))) expect_true(is.na(qprop(0.5, NA, 0.5))) expect_true(is.na(qprop(0.5, 10, NA))) expect_true(is.na(qrayleigh(NA, 1))) expect_true(is.na(qrayleigh(0.5, NA))) expect_true(is.na(qtlambda(NA, 0.5))) expect_true(is.na(qtlambda(0, NA))) expect_true(is.na(qtnorm(NA, 0, 1, -2, 2))) expect_true(is.na(qtnorm(0.5, NA, 1, -2, 2))) expect_true(is.na(qtnorm(0.5, 0, NA, -2, 2))) expect_true(is.na(qtnorm(0.5, 0, 1, NA, 2))) expect_true(is.na(qtnorm(0.5, 0, 1, -2, NA))) expect_true(is.na(qtpois(NA, 5, 0))) expect_true(is.na(qtpois(0.5, NA, 0))) expect_true(is.na(qtpois(0.5, 5, NA))) expect_true(is.na(qtriang(NA, 0, 1, 0.5))) expect_true(is.na(qtriang(0.5, NA, 1, 0.5))) expect_true(is.na(qtriang(0.5, 0, NA, 0.5))) expect_true(is.na(qtriang(0.5, 0, 1, NA))) expect_true(is.na(qzip(NA, 1, 0.5))) expect_true(is.na(qzip(0.5, NA, 0.5))) expect_true(is.na(qzip(0.5, 1, NA))) expect_true(is.na(qzib(NA, 1, 0.5, 0.5))) expect_true(is.na(qzib(0.5, NA, 0.5, 0.5))) expect_true(is.na(qzib(0.5, 1, NA, 0.5))) expect_true(is.na(qzib(0.5, 1, 0.5, NA))) expect_true(is.na(qzinb(NA, 1, 0.5, 0.5))) expect_true(is.na(qzinb(0.5, NA, 0.5, 0.5))) expect_true(is.na(qzinb(0.5, 1, NA, 0.5))) expect_true(is.na(qzinb(0.5, 1, 0.5, NA))) }) test_that("Wrong parameter values in RNG functions", { expect_warning(expect_true(is.na(rbbinom(1, NA, 1, 1)))) expect_warning(expect_true(is.na(rbbinom(1, 1, NA, 1)))) expect_warning(expect_true(is.na(rbbinom(1, 1, 1, NA)))) expect_warning(expect_true(is.na(rbern(1, NA)))) expect_warning(expect_true(is.na(rbetapr(1, NA, 1, 1)))) expect_warning(expect_true(is.na(rbetapr(1, 1, NA, 1)))) expect_warning(expect_true(is.na(rbetapr(1, 1, 1, NA)))) expect_warning(expect_true(is.na(rbhatt(1, NA, 1, 1)))) expect_warning(expect_true(is.na(rbhatt(1, 1, NA, 1)))) expect_warning(expect_true(is.na(rbhatt(1, 1, 1, NA)))) expect_warning(expect_true(is.na(rbnbinom(1, NA, 1, 1)))) expect_warning(expect_true(is.na(rbnbinom(1, 1, NA, 1)))) expect_warning(expect_true(is.na(rbnbinom(1, 1, 1, NA)))) expect_warning(expect_true(all(is.na(rbvnorm(1, NA, 1, 1, 1, 0.5))))) expect_warning(expect_true(all(is.na(rbvnorm(1, 1, NA, 1, 1, 0.5))))) expect_warning(expect_true(all(is.na(rbvnorm(1, 1, 1, NA, 1, 0.5))))) expect_warning(expect_true(all(is.na(rbvnorm(1, 1, 1, 1, NA, 0.5))))) expect_warning(expect_true(all(is.na(rbvnorm(1, 1, 1, 1, 1, NA))))) expect_warning(expect_true(all(is.na(rbvpois(1, NA, 1, 1))))) expect_warning(expect_true(all(is.na(rbvpois(1, 1, NA, 1))))) expect_warning(expect_true(all(is.na(rbvpois(1, 1, 1, NA))))) expect_warning(expect_true(is.na(rcat(1, c(NA, 0.5))))) expect_warning(expect_true(is.na(rcat(1, c(0.5, NA))))) expect_warning(expect_true(is.na(rcatlp(1, c(NA, 0.5))))) expect_warning(expect_true(is.na(rcatlp(1, c(0.5, NA))))) expect_warning(expect_true(all(is.na(rdirichlet(1, c(NA, 0.5)))))) expect_warning(expect_true(all(is.na(rdirichlet(1, c(0.5, NA)))))) expect_warning(expect_true(is.na(rdlaplace(1, NA, 1)))) expect_warning(expect_true(is.na(rdlaplace(1, 1, NA)))) expect_warning(expect_true(is.na(rdnorm(1, NA, 1)))) expect_warning(expect_true(is.na(rdnorm(1, 1, NA)))) expect_warning(expect_true(is.na(rdgamma(1, NA, 1)))) expect_warning(expect_true(is.na(rdgamma(1, 9, NA)))) expect_warning(expect_true(is.na(rdunif(1, NA, 10)))) expect_warning(expect_true(is.na(rdunif(1, 1, NA)))) expect_warning(expect_true(is.na(rdweibull(1, NA, 1)))) expect_warning(expect_true(is.na(rdweibull(1, 1, NA)))) expect_warning(expect_true(is.na(rfatigue(1, NA, 1)))) expect_warning(expect_true(is.na(rfatigue(1, 1, NA)))) expect_warning(expect_true(is.na(rfrechet(1, NA, 1, 1)))) expect_warning(expect_true(is.na(rfrechet(1, 1, NA, 1)))) expect_warning(expect_true(is.na(rfrechet(1, 1, 1, NA)))) expect_warning(expect_true(is.na(rgev(1, NA, 1, 1)))) expect_warning(expect_true(is.na(rgev(1, 1, NA, 1)))) expect_warning(expect_true(is.na(rgev(1, 1, 1, NA)))) expect_warning(expect_true(is.na(rgompertz(1, NA, 1)))) expect_warning(expect_true(is.na(rgompertz(1, 1, NA)))) expect_warning(expect_true(is.na(rgpd(1, NA, 1, 1)))) expect_warning(expect_true(is.na(rgpd(1, 1, NA, 1)))) expect_warning(expect_true(is.na(rgpd(1, 1, 1, NA)))) expect_warning(expect_true(is.na(rgpois(1, NA, 1)))) expect_warning(expect_true(is.na(rgpois(1, 1, NA)))) expect_warning(expect_true(is.na(rgumbel(1, NA, 1)))) expect_warning(expect_true(is.na(rgumbel(1, 1, NA)))) expect_warning(expect_true(is.na(rhcauchy(1, NA)))) expect_warning(expect_true(is.na(rhnorm(1, NA)))) expect_warning(expect_true(is.na(rht(1, NA, 1)))) expect_warning(expect_true(is.na(rht(1, 5, NA)))) expect_warning(expect_true(is.na(rhuber(1, NA, 1, 1)))) expect_warning(expect_true(is.na(rhuber(1, 0, NA, 1)))) expect_warning(expect_true(is.na(rhuber(1, 0, 1, NA)))) # expect_warning(expect_true(is.na(rinvgamma(1, NA, 1)))) # expect_warning(expect_true(is.na(rinvgamma(1, 1, NA)))) # # expect_warning(expect_true(is.na(rinvchisq(1, NA, 1)))) # expect_warning(expect_true(is.na(rinvchisq(1, 1, NA)))) expect_warning(expect_true(is.na(rkumar(1, NA, 1)))) expect_warning(expect_true(is.na(rkumar(1, 1, NA)))) expect_warning(expect_true(is.na(rlaplace(1, NA, 1)))) expect_warning(expect_true(is.na(rlaplace(1, 0, NA)))) expect_warning(expect_true(is.na(rlgser(1, NA)))) expect_warning(expect_true(is.na(rlomax(1, NA, 1)))) expect_warning(expect_true(is.na(rlomax(1, 1, NA)))) expect_warning(expect_true(is.na(rmixnorm(1, c(NA,2,3), c(1,2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixnorm(1, c(1,NA,3), c(1,2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixnorm(1, c(1,2,NA), c(1,2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixnorm(1, c(1,2,3), c(NA,2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixnorm(1, c(1,2,3), c(1,NA,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixnorm(1, c(1,2,3), c(1,2,3), c(NA,1/3,1/3))))) expect_warning(expect_true(is.na(rmixnorm(1, c(1,2,3), c(1,2,3), c(1/3,NA,1/3))))) expect_warning(expect_true(is.na(rmixnorm(1, c(1,2,3), c(1,2,3), c(1/3,1/3,NA))))) expect_warning(expect_true(is.na(rmixpois(1, c(NA,2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixpois(1, c(1,NA,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixpois(1, c(1,2,NA), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixpois(1, c(1,2,3), c(NA,1/3,1/3))))) expect_warning(expect_true(is.na(rmixpois(1, c(1,2,3), c(1/3,NA,1/3))))) expect_warning(expect_true(is.na(rmixpois(1, c(1,2,3), c(1/3,1/3,NA))))) expect_warning(expect_true(is.na(rnhyper(1, NA, 35, 15)))) expect_warning(expect_true(is.na(rnhyper(1, 60, NA, 15)))) expect_warning(expect_true(is.na(rnhyper(1, 60, 35, NA)))) expect_warning(expect_true(all(is.na(rdirmnom(1, NA, c(1, 1, 1)))))) expect_warning(expect_true(all(is.na(rdirmnom(1, 3, c(NA, 1, 1)))))) expect_warning(expect_true(all(is.na(rdirmnom(1, 3, c(1, NA, 1)))))) expect_warning(expect_true(all(is.na(rdirmnom(1, 3, c(1, 1, NA)))))) expect_warning(expect_true(all(is.na(rmnom(1, NA, c(1/3, 1/3, 1/3)))))) expect_warning(expect_true(all(is.na(rmnom(1, 3, c(NA, 1/3, 1/3)))))) expect_warning(expect_true(all(is.na(rmnom(1, 3, c(1/3, NA, 1/3)))))) expect_warning(expect_true(all(is.na(rmnom(1, 3, c(1/3, 1/3, NA)))))) expect_warning(expect_true(all(is.na(rmvhyper(1, c(NA,3,4), 5))))) expect_warning(expect_true(all(is.na(rmvhyper(1, c(2,NA,4), 5))))) expect_warning(expect_true(all(is.na(rmvhyper(1, c(2,3,NA), 5))))) expect_warning(expect_true(all(is.na(rmvhyper(1, c(2,3,4), NA))))) expect_warning(expect_true(is.na(rnsbeta(1, NA, 1, -2, 2)))) expect_warning(expect_true(is.na(rnsbeta(1, 1, NA, -2, 2)))) expect_warning(expect_true(is.na(rnsbeta(1, 1, 1, NA, 2)))) expect_warning(expect_true(is.na(rnsbeta(1, 1, 1, -2, NA)))) expect_warning(expect_true(is.na(rlst(1, NA, 0, 1)))) expect_warning(expect_true(is.na(rlst(1, 2, NA, 1)))) expect_warning(expect_true(is.na(rlst(1, 2, 0, NA)))) expect_warning(expect_true(is.na(rpareto(1, NA, 1)))) expect_warning(expect_true(is.na(rpareto(1, 1, NA)))) expect_warning(expect_true(is.na(rpower(1, NA, 1)))) expect_warning(expect_true(is.na(rpower(1, 1, NA)))) expect_warning(expect_true(is.na(rprop(1, NA, 0.5)))) expect_warning(expect_true(is.na(rprop(1, 10, NA)))) expect_warning(expect_true(is.na(rrayleigh(1, NA)))) expect_warning(expect_true(is.na(rtlambda(1, NA)))) expect_warning(expect_true(is.na(rsgomp(1, NA, 1)))) expect_warning(expect_true(is.na(rsgomp(1, 0.4, NA)))) expect_warning(expect_true(is.na(rskellam(1, NA, 1)))) expect_warning(expect_true(is.na(rskellam(1, 1, NA)))) expect_warning(expect_true(is.na(rslash(1, NA, 1)))) expect_warning(expect_true(is.na(rslash(1, 1, NA)))) expect_warning(expect_true(is.na(rtnorm(1, NA, 1, -2, 2)))) expect_warning(expect_true(is.na(rtnorm(1, 0, NA, -2, 2)))) expect_warning(expect_true(is.na(rtnorm(1, 0, 1, NA, 2)))) expect_warning(expect_true(is.na(rtnorm(1, 0, 1, -2, NA)))) expect_warning(expect_true(is.na(rtpois(1, NA, 0)))) expect_warning(expect_true(is.na(rtpois(1, 5, NA)))) expect_warning(expect_true(is.na(rtriang(1, NA, 1, 0.5)))) expect_warning(expect_true(is.na(rtriang(1, 0, NA, 0.5)))) expect_warning(expect_true(is.na(rtriang(1, 0, 1, NA)))) expect_warning(expect_true(is.na(rwald(1, NA, 1)))) expect_warning(expect_true(is.na(rwald(1, 1, NA)))) expect_warning(expect_true(is.na(rzip(1, NA, 0.5)))) expect_warning(expect_true(is.na(rzip(1, 1, NA)))) expect_warning(expect_true(is.na(rzib(1, NA, 0.5, 0.5)))) expect_warning(expect_true(is.na(rzib(1, 1, NA, 0.5)))) expect_warning(expect_true(is.na(rzib(1, 1, 0.5, NA)))) expect_warning(expect_true(is.na(rzinb(1, NA, 0.5, 0.5)))) expect_warning(expect_true(is.na(rzinb(1, 1, NA, 0.5)))) expect_warning(expect_true(is.na(rzinb(1, 1, 0.5, NA)))) })extraDistr/tests/testthat/test-pure-r-benchmarks.R0000755000176200001440000002613414475546572022066 0ustar liggesusers test_that("Compare PDF's/PMF's to pure-R benchmarks", { x <- c(-1e5, -100, -10, -5.5, -5, -1.01, -1, -0.5, 0.001, 0, 0.001, 0.5, 1, 1.01, 5, 5.5, 10, 100, 1e5) n <- length(x) expect_warning(expect_equal(dbbinom(x, 100, 1, 10), dbbinomR(x, 100, 1, 10))) expect_warning(expect_equal(dbbinom(x, 100, 1000, 0.001), dbbinomR(x, 100, 1000, 0.001))) expect_warning(expect_equal(dbnbinom(x[1:(n-2)], 100, 1, 10), dbnbinomR(x[1:(n-2)], 100, 1, 10))) # numerical precission in R version expect_equal(dbetapr(x, 1, 1, 1), dbetaprR(x, 1, 1, 1)) expect_equal(dbetapr(x, 0.0001, 0.0001, 0.0001), dbetaprR(x, 0.0001, 0.0001, 0.0001)) expect_equal(dbetapr(x, 100, 100, 100), dbetaprR(x, 100, 100, 100)) expect_equal(dfatigue(x, 1, 1, 0), dfatigueR(x, 1, 1, 0)) expect_equal(dfatigue(x, 0.0001, 0.0001, -100), dfatigueR(x, 0.0001, 0.0001, -100)) expect_warning(expect_equal(ddlaplace(x, 0, 0.5), ddlaplaceR(x, 0, 0.5))) expect_warning(expect_equal(ddlaplace(x, 0, 0.999), ddlaplaceR(x, 0, 0.999))) expect_warning(expect_equal(ddlaplace(x, 0, 0.0001), ddlaplaceR(x, 0, 0.0001))) expect_warning(expect_equal(ddweibull(x, 0.5, 1), ddweibullR(x, 0.5, 1))) expect_warning(expect_equal(ddweibull(x, 0.0001, 0.0001), ddweibullR(x, 0.0001, 0.0001))) expect_warning(expect_equal(ddweibull(x, 0.9999, 1000), ddweibullR(x, 0.9999, 1000))) expect_equal(dfrechet(x, 1, 1, 1), dfrechetR(x, 1, 1, 1)) expect_warning(expect_equal(dgpois(x[1:(n-1)], 1, 1), dgpoisR(x[1:(n-1)], 1, 1))) # numerical precission in R version expect_equal(dgev(x, 1, 1, 1), dgevR(x, 1, 1, 1)) expect_equal(dgev(x[2:n], 1, 1, 0), dgevR(x[2:n], 1, 1, 0)) # numerical precission in R version expect_equal(dgev(x, 1, 1, -1), dgevR(x, 1, 1, -1)) expect_equal(dgompertz(x, 1, 1), dgompertzR(x, 1, 1)) expect_equal(dgpd(x, 1, 1, 1), dgpdR(x, 1, 1, 1)) expect_equal(dgpd(x, 1, 1, 0), dgpdR(x, 1, 1, 0)) expect_equal(dgpd(x, 1, 1, -1), dgpdR(x, 1, 1, -1)) expect_equal(dgumbel(x, 1, 1), dgumbelR(x, 1, 1)) expect_equal(dinvgamma(x, 1, 1), dinvgammaR(x, 1, 1)) expect_equal(dinvgamma(x, 1.2, 0.9), dinvgammaR(x, 1.2, 0.9)) expect_equal(dlaplace(x, -1, 5), dlaplaceR(x, -1, 5)) expect_equal(dlaplace(x, 9999, 0.000001), dlaplaceR(x, 9999, 0.000001)) expect_warning(expect_equal(dlgser(x, 0.5), dlgserR(x, 0.5))) expect_warning(expect_equal(dlgser(x, 0.00001), dlgserR(x, 0.00001))) expect_warning(expect_equal(dlgser(x, 0.9999), dlgserR(x, 0.9999))) expect_equal(dlomax(x, 1, 0.5), dlomaxR(x, 1, 0.5)) expect_equal(dpareto(x, 1, 1), dparetoR(x, 1, 1)) expect_equal(dpower(x, 1, 1), dpowerR(x, 1, 1)) expect_equal(drayleigh(x, 1), drayleighR(x, 1)) expect_equal(dsgomp(x, 0.5, 1), dsgompR(x, 0.5, 1)) }) test_that("Compare dinvgamma to actuar implementation", { skip_on_cran() skip_if_not_installed("actuar") x <- c(-1e5, -100, -10, -5.5, -5, -1.01, -1, -0.5, 0.001, 0, 0.001, 0.5, 1, 1.01, 5, 5.5, 10, 100, 1e5) expect_equal(dinvgamma(x, 1.2, 0.9), actuar::dinvgamma(x, 1.2, scale=0.9)) expect_equal(pinvgamma(x, 1.2, 0.9), actuar::pinvgamma(x, 1.2, scale=0.9)) }) test_that("Compare dhuber to hoa implementation", { x <- c(-1e5, -100, -10, -5.5, -5, -1.01, -1, -0.5, 0.001, 0, 0.001, 0.5, 1, 1.01, 5, 5.5, 10, 100, 1e5) n <- length(x) skip_on_cran() skip_if_not_installed("hoa") expect_equal(dhuber(x), hoa::dHuber(x)) expect_equal(phuber(x), hoa::pHuber(x)) }) test_that("Compare triangular to triangle implementation", { x <- c(-1e5, -100, -10, -5.5, -5, -1.01, -1, -0.5, 0.001, 0, 0.001, 0.5, 1, 1.01, 5, 5.5, 10, 100, 1e5) n <- length(x) skip_on_cran() skip_if_not_installed("triangle") expect_equal(dtriang(x, -1, 1), triangle::dtriangle(x, -1, 1)) expect_equal(dtriang(x, 0, 1, 0.8), triangle::dtriangle(x, 0, 1, 0.8)) expect_equal(ptriang(x, -1, 1), triangle::ptriangle(x, -1, 1)) expect_equal(ptriang(x, 0, 1, 0.8), triangle::ptriangle(x, 0, 1, 0.8)) }) test_that("Compare GEV and GPD to evd implementation", { x <- c(-1e5, -100, -10, -5.5, -5, -1.01, -1, -0.5, 0.001, 0, 0.001, 0.5, 1, 1.01, 5, 5.5, 10, 100, 1e5) n <- length(x) skip_on_cran() skip_if_not_installed("evd") expect_equal(dgev(x, 0, 1, 0), evd::dgev(x, 0, 1, 0)) expect_equal(dgev(x, 0, 1, 1), evd::dgev(x, 0, 1, 1)) expect_equal(dgev(x, 0, 1, -1), evd::dgev(x, 0, 1, -1)) expect_equal(pgev(x, 0, 1, 0), evd::pgev(x, 0, 1, 0)) expect_equal(pgev(x, 0, 1, 1), evd::pgev(x, 0, 1, 1)) expect_equal(pgev(x, 0, 1, -1), evd::pgev(x, 0, 1, -1)) expect_equal(dgpd(x, 0, 1, 0), evd::dgpd(x, 0, 1, 0)) expect_equal(dgpd(x, 0, 1, 1), evd::dgpd(x, 0, 1, 1)) expect_equal(dgpd(x, 0, 1, -1), evd::dgpd(x, 0, 1, -1)) expect_equal(pgpd(x, 0, 1, 0), evd::pgpd(x, 0, 1, 0)) expect_equal(pgpd(x, 0, 1, 1), evd::pgpd(x, 0, 1, 1)) expect_equal(pgpd(x, 0, 1, -1), evd::pgpd(x, 0, 1, -1)) }) test_that("Compare to distributions from VGAM package", { x <- c(-1e5, -100, -10, -5.5, -5, -1.01, -1, -0.5, 0.001, 0, 0.001, 0.5, 1, 1.01, 5, 5.5, 10, 100, 1e5) n <- length(x) skip_on_cran() skip_if_not_installed("VGAM") expect_warning(expect_equal(dzib(x, 45, 0.7, 0.2), VGAM::dzibinom(x, 45, 0.7, 0.2))) expect_warning(expect_equal(dzib(x, 45, 0.7, 0.0001), VGAM::dzibinom(x, 45, 0.7, 0.0001))) expect_warning(expect_equal(dzib(x, 45, 0.7, 0.9999), VGAM::dzibinom(x, 45, 0.7, 0.9999))) expect_equal(pzib(x, 45, 0.7, 0.2), VGAM::pzibinom(x, 45, 0.7, 0.2)) expect_equal(pzib(x, 45, 0.7, 0.0001), VGAM::pzibinom(x, 45, 0.7, 0.0001)) expect_equal(pzib(x, 45, 0.7, 0.9999), VGAM::pzibinom(x, 45, 0.7, 0.9999)) expect_warning(expect_equal(dzinb(x, 45, 0.7, 0.2), VGAM::dzinegbin(x, 45, 0.7, NULL, 0.2))) expect_warning(expect_equal(dzinb(x, 45, 0.7, 0.0001), VGAM::dzinegbin(x, 45, 0.7, NULL, 0.0001))) expect_warning(expect_equal(dzinb(x, 45, 0.7, 0.9999), VGAM::dzinegbin(x, 45, 0.7, NULL, 0.9999))) expect_equal(pzinb(x, 45, 0.7, 0.2), VGAM::pzinegbin(x, 45, 0.7, NULL, 0.2)) expect_equal(pzinb(x, 45, 0.7, 0.0001), VGAM::pzinegbin(x, 45, 0.7, NULL, 0.0001)) expect_equal(pzinb(x, 45, 0.7, 0.9999), VGAM::pzinegbin(x, 45, 0.7, NULL, 0.9999)) expect_warning(expect_equal(dzip(x, 7, 0.2), VGAM::dzipois(x, 7, 0.2))) expect_warning(expect_equal(dzip(x, 7, 0.0001), VGAM::dzipois(x, 7, 0.0001))) expect_warning(expect_equal(dzip(x, 7, 0.9999), VGAM::dzipois(x, 7, 0.9999))) expect_equal(pzip(x, 7, 0.2), VGAM::pzipois(x, 7, 0.2)) expect_equal(pzip(x, 7, 0.0001), VGAM::pzipois(x, 7, 0.0001)) expect_equal(pzip(x, 7, 0.9999), VGAM::pzipois(x, 7, 0.9999)) expect_equal(dlaplace(x), VGAM::dlaplace(x)) expect_equal(plaplace(x), VGAM::plaplace(x)) expect_equal(dpareto(x, 1, 1), VGAM::dpareto(x, 1, 1)) expect_equal(ppareto(x, 1, 1), suppressWarnings(VGAM::ppareto(x, 1, 1))) expect_warning(expect_equal(dbbinom(x, 100, 2, 7), VGAM::dbetabinom.ab(x, 100, 2, 7))) expect_equal(pbbinom(x, 100, 2, 7), VGAM::pbetabinom.ab(x, 100, 2, 7)) expect_equal(dfrechet(x, 1, 0, 1), VGAM::dfrechet(x, 0, 1, 1)) expect_equal(pfrechet(x, 1, 0, 1), VGAM::pfrechet(x, 0, 1, 1)) expect_equal(dgumbel(x, 0, 1), VGAM::dgumbel(x, 0, 1)) expect_equal(pgumbel(x, 0, 1), VGAM::pgumbel(x, 0, 1)) expect_equal(dgompertz(x, 1, 1), VGAM::dgompertz(x, 1, 1)) expect_equal(pgompertz(x, 1, 1), VGAM::pgompertz(x, 1, 1)) expect_equal(dkumar(x, 3, 7), VGAM::dkumar(x, 3, 7)) expect_equal(pkumar(x, 3, 7), suppressWarnings(VGAM::pkumar(x, 3, 7))) expect_equal(dslash(x), VGAM::dslash(x)) # expect_equal(pslash(x), VGAM::pslash(x)) expect_equal(dhuber(x), VGAM::dhuber(x, 1.345)) expect_equal(phuber(x), VGAM::phuber(x, 1.345)) expect_warning(expect_equal(dlgser(x, 0.5), VGAM::dlog(x, 0.5))) expect_warning(expect_equal(dlgser(x, 0.0001), VGAM::dlog(x, 0.0001))) expect_warning(expect_equal(dlgser(x, 0.9999), VGAM::dlog(x, 0.9999))) expect_equal(drayleigh(x), VGAM::drayleigh(x)) expect_equal(prayleigh(x), VGAM::prayleigh(x)) expect_warning(expect_equal( extraDistr::dskellam(x, 7, 8), VGAM::dskellam(x, 7, 8) )) }) test_that("Check against the parameter values tested in VGAM", { x <- c(-1e5, -100, -10, -5.5, -5, -1.01, -1, -0.5, 0.001, 0, 0.001, 0.5, 1, 1.01, 5, 5.5, 10, 100, 1e5) n <- length(x) skip_on_cran() skip_if_not_installed("VGAM") expect_warning(expect_equal(dbbinom(x, 10, 0.8, 1.2), VGAM::dbetabinom.ab(x, 10, 0.8, 1.2))) expect_equal(dpareto(x, 1.9, 2.3), dparetoR(x, 1.9, 2.3)) expect_equal(dpareto(x, 2.3, 1.9), VGAM::dpareto(x, 1.9, 2.3)) # reverse order of params! expect_equal(dlst(x, 3, -0.9, 2), dt((x+0.9)/2, df = 3)/2) expect_equal(dlaplace(x, -0.9, 2), VGAM::dlaplace(x, -0.9, 2)) expect_warning(expect_equal(dbern(x, 0.3), dbinom(x, 1, 0.3))) }) test_that("Compare with LaplacesDemon package implementations", { skip_on_cran() skip_if_not_installed("LaplacesDemon") alpha <- runif(5, 0, 3) x <- rdirichlet(5000, alpha) expect_equal(ddirichlet(x, alpha), LaplacesDemon::ddirichlet(x, alpha)) alpha <- c(0.0001, 0.0001, 0.0001, 0.0001, 0.0001) expect_equal(ddirichlet(x, alpha), LaplacesDemon::ddirichlet(x, alpha)) alpha <- c(1000, 1000, 1000, 1000, 1000) expect_equal(ddirichlet(x, alpha), LaplacesDemon::ddirichlet(x, alpha)) alpha <- c(1e-4, 10000, 100, 1e-5, 1000) expect_equal(ddirichlet(x, alpha), LaplacesDemon::ddirichlet(x, alpha)) # x <- c(-1e5, -100, -10, -5.5, -5, -1.01, -1, -0.5, 0.001, 0, # 0.001, 0.5, 1, 1.01, 5, 5.5, 10, 100, 1e5) # # expect_equal(dbern(x, 0.32), LaplacesDemon::dbern(x, 0.32)) # expect_equal(dgpd(x, 0.2, 3.4, 1.4), LaplacesDemon::dgpd(x, 0.2, 3.4, 1.4)) # expect_equal(dhcauchy(x, 2.6), LaplacesDemon::dhalfcauchy(x, 2.6)) # expect_equal(dhnorm(x, 8.3), LaplacesDemon::dhalfnorm(x, 8.3)) # expect_equal(dht(x, sigma=3.4, nu=7), LaplacesDemon::dhalft(x, scale=3.4, nu=7)) # expect_equal(dinvchisq(x, 2.3, 5), LaplacesDemon::dinvchisq(x, 2.3, 5)) # expect_equal(dinvgamma(x, 7.6, 3), LaplacesDemon::dinvgamma(x, 7.6, 3)) # expect_equal(dwald(x, -2, 6), LaplacesDemon::dinvgaussian(x, -2, 6)) # expect_equal(dpareto(x, 5, 6), LaplacesDemon::dpareto(x, 5, 6)) # # expect_equal(dcat(), LaplacesDemon::dcat()) }) test_that("Compare dmnom to dmultinom from base R", { n <- 100 p <- runif(5) p <- p/sum(p) x <- rmnom(5000, n, p) expect_equal(dmnom(x, n, p), apply(x, 1, dmultinom, n, p)) p <- c(1e-4, 10000, 100, 1e-5, 1000) p <- p/sum(p) expect_equal(dmnom(x, n, p), apply(x, 1, dmultinom, n, p)) }) test_that("Bivariate Poisson distribution agrees with code by Karlis and Ntzoufras", { x <- rbvpois(1000, 7, 8, 5) expect_equal( dbvpois(x[,1], x[,2], 7, 8, 5), pbivpois(x[,1], x[,2], 7, 8, 5) ) }) test_that("Skellam distribution agrees with the implementation in skellam package", { skip_on_cran() skip_if_not_installed("skellam") x <- extraDistr::rskellam(5000, 7, 8) expect_equal( extraDistr::dskellam(x, 7, 8), skellam::dskellam(x, 7, 8) ) }) extraDistr/tests/testthat/test-rtnorm-in-bounds.R0000755000176200001440000000206114475546572021747 0ustar liggesusers all_in_bounds <- function(object, lower, upper) { all(object >= lower & object <= upper) } test_that("Check if values generated using rtnorm stay in bounds", { N <- 5000 mu <- 0 sigma <- 1 a <- -1 b <- 1 X <- rtnorm(N, mu, sigma, a, b) expect_true(all_in_bounds(X, a, b)) a <- 0 b <- 1 X <- rtnorm(N, mu, sigma, a, b) expect_true(all_in_bounds(X, a, b)) a <- -1 b <- 0 X <- rtnorm(N, mu, sigma, a, b) expect_true(all_in_bounds(X, a, b)) a <- 4 b <- 5 X <- rtnorm(N, mu, sigma, a, b) expect_true(all_in_bounds(X, a, b)) a <- -5 b <- -4 X <- rtnorm(N, mu, sigma, a, b) expect_true(all_in_bounds(X, a, b)) a <- -Inf b <- 5 X <- rtnorm(N, mu, sigma, a, b) expect_true(all_in_bounds(X, a, b)) a <- -5 b <- Inf X <- rtnorm(N, mu, sigma, a, b) expect_true(all_in_bounds(X, a, b)) a <- -Inf b <- -4 X <- rtnorm(N, mu, sigma, a, b) expect_true(all_in_bounds(X, a, b)) a <- 4 b <- Inf X <- rtnorm(N, mu, sigma, a, b) expect_true(all_in_bounds(X, a, b)) }) extraDistr/tests/testthat/test-probabilities.R0000755000176200001440000001554214475546572021372 0ustar liggesusers test_that("All probabilities/densities >= 0", { x <- c(-Inf, -100, -10, -5, -1, -0.5, 0, 0.5, 1, 5, 10, 100, Inf) expect_true(suppressWarnings(all(dbbinom(x, 1, 1, 1) >= 0))) expect_true(suppressWarnings(all(dbern(x, 0.5) >= 0))) expect_true(suppressWarnings(all(dbetapr(x, 1, 1, 1) >= 0))) expect_true(all(dbhatt(x, sigma = 1) >= 0)) expect_true(suppressWarnings(all(dbnbinom(x, 1, 1, 1) >= 0))) expect_true(all(dbvnorm(x, x, sd1 = 1) >= 0)) expect_true(suppressWarnings(all(dbvpois(x, x, 1, 1, 1) >= 0))) expect_true(suppressWarnings(all(dcat(x, c(0.5, 0.5)) >= 0))) expect_true(all(ddirichlet(c(0.5, 0.5), c(1, 0.5)) >= 0)) expect_true(suppressWarnings(all(ddlaplace(x, 0, scale = 0.5) >= 0))) expect_true(suppressWarnings(all(ddnorm(x, sd = 1) >= 0))) expect_true(suppressWarnings(all(ddgamma(x, 9, 1) >= 0))) expect_true(suppressWarnings(all(ddunif(x, min = 10, max = 100) >= 0))) expect_true(suppressWarnings(all(ddweibull(x, 0.5, 1) >= 0))) expect_true(all(dfatigue(x, 1, 1) >= 0)) expect_true(all(dfrechet(x, lambda = 1) >= 0)) expect_true(all(dgev(x, 1, 1, 1) >= 0)) expect_true(all(dgompertz(x, 1, 1) >= 0)) expect_true(all(dgpd(x, 1, 1, 1) >= 0)) expect_true(suppressWarnings(all(dgpois(x, 1, 1) >= 0))) expect_true(all(dgumbel(x, sigma = 1) >= 0)) expect_true(all(dhcauchy(x, 1) >= 0)) expect_true(all(dhnorm(x, 1) >= 0)) expect_true(all(dht(x, 5, 1) >= 0)) expect_true(all(dhuber(x, 0, 1, 1) >= 0)) expect_true(all(dinvgamma(x, 1, 1) >= 0)) expect_true(all(dinvchisq(x, 1, 1) >= 0)) expect_true(all(dkumar(x, 1, 1) >= 0)) expect_true(all(dlaplace(x, 0, 1) >= 0)) expect_true(suppressWarnings(all(dlgser(x, 0.5) >= 0))) expect_true(all(dlomax(x, 1, 1) >= 0)) expect_true(all(dmixnorm(x, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3)) >= 0)) expect_true(suppressWarnings(all(dmixpois(x, c(1,2,3), c(1/3,1/3,1/3)) >= 0))) expect_true(suppressWarnings(all(dnhyper(x, 60, 35, 15) >= 0))) expect_true(all(ddirmnom(c(1, 1, 1), 2, c(1, 1, 1)) >= 0)) expect_true(all(dmnom(c(1, 1, 1), 2, c(1/3, 1/3, 1/3)) >= 0)) expect_true(all(dmvhyper(c(1, 2, 2), c(2,3,4), 5) >= 0)) expect_true(all(dnsbeta(x, 1, 1, -2, 2) >= 0)) expect_true(all(dlst(x, 2, 0, 1) >= 0)) expect_true(all(dpareto(x, 1, 1) >= 0)) expect_true(all(dprop(x, 10, 0.5) >= 0)) expect_true(all(drayleigh(x, 1) >= 0)) expect_true(suppressWarnings(all(dskellam(x, 1, 1) >= 0))) expect_true(all(dsgomp(x, 0.4, 1) >= 0)) expect_true(all(dslash(x, sigma = 1) >= 0)) expect_true(all(dtnorm(x, 0, 1, 1, 2) >= 0)) expect_true(suppressWarnings(all(dtpois(x, lambda = 25, a = 0) >= 0))) expect_true(suppressWarnings(all(dtbinom(x, 100, 0.67, a = 60, b = 70) >= 0))) expect_true(all(dtriang(x, 1, 2, 1.5) >= 0)) expect_true(all(dwald(x, 1, 1) >= 0)) expect_true(suppressWarnings(all(dzip(x, 1, 0.5) >= 0))) expect_true(suppressWarnings(all(dzib(x, 1, 0.5, 0.5) >= 0))) expect_true(suppressWarnings(all(dzinb(x, 1, 0.5, 0.5) >= 0))) }) test_that("All cumulative probabilities >= 0 and <= 1", { x <- c(-Inf, -100, -10, -5, -1, -0.5, 0, 0.5, 1, 5, 10, 100, Inf) expect_true(all(pbbinom(x, 1, 1, 1) >= 0 & pbbinom(x, 1, 1, 1) <= 1)) expect_true(all(pbern(x, 0.5) >= 0 & pbern(x, 0.5) <= 1)) expect_true(all(pbetapr(x, 1, 1, 1) >= 0 & pbetapr(x, 1, 1, 1) <= 1)) expect_true(all(pbhatt(x, sigma = 1) >= 0 & pbhatt(x, sigma = 1) <= 1)) expect_true(all(pbnbinom(x, 1, 1, 1) >= 0 & pbnbinom(x, 1, 1, 1) <= 1)) # expect_true(all(pbvnorm(x, x, sd1 = 1) >= 0)) # expect_true(all(pbvpois(x, x, 1, 1, 1) >= 0)) expect_true(all(pcat(x, c(0.5, 0.5)) >= 0 & pcat(x, c(0.5, 0.5)) <= 1)) # expect_true(all(pdirichlet(c(0.5, 0.5), c(1, 0.5)) >= 0)) expect_true(all(pdlaplace(x, 0, scale = 0.5) >= 0 & pdlaplace(x, 0, scale = 0.5) <= 1)) expect_true(all(pdnorm(x, sd = 50) >= 0 & pdnorm(x, sd = 50) <= 1)) expect_true(all(pdgamma(x, 9, 1) >= 0 & pdgamma(x, 9, 1) <= 1)) expect_true(all(pdunif(x, min = 10, max = 100) >= 0 & pdunif(x, min = 10, max = 100) <= 1)) expect_true(all(pdweibull(x, 0.5, 1) >= 0 & pdweibull(x, 0.5, 1) <= 1)) expect_true(all(pfatigue(x, 1, 1) >= 0 & pfatigue(x, 1, 1) <= 1)) expect_true(all(pfrechet(x, lambda = 1) >= 0 & pfrechet(x, lambda = 1) <= 1)) expect_true(all(pgev(x, 1, 1, 1) >= 0 & pgev(x, 1, 1, 1) <= 1)) expect_true(all(pgompertz(x, 1, 1) >= 0 & pgompertz(x, 1, 1) <= 1)) expect_true(all(pgpd(x, 1, 1, 1) >= 0 & pgpd(x, 1, 1, 1) <= 1)) expect_true(all(pgpois(x, 1, 1) >= 0 & pgpois(x, 1, 1) <= 1)) expect_true(all(pgumbel(x, sigma = 1) >= 0 & pgumbel(x, sigma = 1) <= 1)) expect_true(all(phcauchy(x, 1) >= 0 & phcauchy(x, 1) <= 1)) expect_true(all(phnorm(x, 1) >= 0 & phnorm(x, 1) <= 1)) expect_true(all(pht(x, 5, 1) >= 0 & pht(x, 5, 1) <= 1)) expect_true(all(phuber(x, 0, 1, 1) >= 0 & phuber(x, 0, 1, 1) <= 1)) expect_true(all(pinvgamma(x, 1, 1) >= 0 & pinvgamma(x, 1, 1) <= 1)) expect_true(all(pinvchisq(x, 1, 1) >= 0 & pinvchisq(x, 1, 1) <= 1)) expect_true(all(pkumar(x, 1, 1) >= 0 & pkumar(x, 1, 1) <= 1)) expect_true(all(plaplace(x, 0, 1) >= 0 & plaplace(x, 0, 1) <= 1)) expect_true(all(plgser(x, 0.5) >= 0 & plgser(x, 0.5) <= 1)) expect_true(all(plomax(x, 1, 1) >= 0 & plomax(x, 1, 1) <= 1)) expect_true(all(pmixnorm(x, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3)) >= 0 & pmixnorm(x, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3)) <= 1)) expect_true(all(pmixpois(x, c(1,2,3), c(1/3,1/3,1/3)) >= 0 & pmixpois(x, c(1,2,3), c(1/3,1/3,1/3)) <= 1)) expect_true(all(pnhyper(x, 60, 35, 15) >= 0 & pnhyper(x, 60, 35, 15) <= 1)) # expect_true(all(pdirmnom(c(1, 1, 1), 2, c(1, 1, 1)) >= 0)) # expect_true(all(pmnom(c(1, 1, 1), 2, c(1/3, 1/3, 1/3)) >= 0)) # expect_true(all(pmvhyper(c(1, 2, 2), c(2,3,4), 5) >= 0)) expect_true(all(pnsbeta(x, 1, 1, -2, 2) >= 0 & pnsbeta(x, 1, 1, -2, 2) <= 1)) expect_true(all(plst(x, 2, 0, 1) >= 0 & plst(x, 2, 0, 1) <= 1)) expect_true(all(ppareto(x, 1, 1) >= 0 & ppareto(x, 1, 1) <= 1)) expect_true(all(pprop(x, 10, 0.5) >= 0 & pprop(x, 10, 0.5) <= 1)) expect_true(all(prayleigh(x, 1) >= 0 & prayleigh(x, 1) <= 1)) # expect_true(all(pskellam(x, 1, 1) >= 0)) expect_true(all(psgomp(x, 0.4, 1) >= 0 & psgomp(x, 0.4, 1) <= 1)) expect_true(all(pslash(x, sigma = 1) >= 0 & pslash(x, sigma = 1) <= 1)) expect_true(all(ptnorm(x, 0, 1, 1, 2) >= 0 & ptnorm(x, 0, 1, 1, 2) <= 1)) expect_true(all(ptpois(x, lambda = 25, a = 0) >= 0 & ptpois(x, lambda = 25, a = 0) <= 1)) expect_true(all(ptbinom(x, 100, 0.67, 60, 70) >= 0 & ptbinom(x, 100, 0.67, 60, 70) <= 1)) expect_true(all(ptbinom(x, 100, 0.67, a = 60, b = 70) >= 0 & ptbinom(x, 100, 0.67, a = 60, b = 70) <= 1)) expect_true(all(ptriang(x, 1, 2, 1.5) >= 0 & ptriang(x, 1, 2, 1.5) <= 1)) expect_true(all(pwald(x, 1, 1) >= 0 & pwald(x, 1, 1) <= 1)) expect_true(all(pzip(x, 1, 0.5) >= 0 & pzip(x, 1, 0.5) <= 1)) expect_true(all(pzib(x, 1, 0.5, 0.5) >= 0 & pzib(x, 1, 0.5, 0.5) <= 1)) expect_true(all(pzinb(x, 1, 0.5, 0.5) >= 0 & pzinb(x, 1, 0.5, 0.5) <= 1)) }) extraDistr/tests/testthat/test-inappropriate-parameters.R0000755000176200001440000007460514475546572023565 0ustar liggesusers test_that("Wrong parameter values in PDF and PMF functions", { expect_warning(expect_true(is.nan(dbbinom(1, -1, 1, 1)))) expect_warning(expect_true(is.nan(dbbinom(1, 1, -1, 1)))) expect_warning(expect_true(is.nan(dbbinom(1, 1, 1, -1)))) expect_warning(expect_true(is.nan(dbern(1, -1)))) expect_warning(expect_true(is.nan(dbern(1, 2)))) expect_warning(expect_true(is.nan(dbetapr(1, -1, 1, 1)))) expect_warning(expect_true(is.nan(dbetapr(1, 1, -1, 1)))) expect_warning(expect_true(is.nan(dbetapr(1, 1, 1, -1)))) expect_warning(expect_true(is.nan(dbhatt(1, sigma = -1)))) expect_warning(expect_true(is.nan(dbhatt(1, a = -1)))) expect_warning(expect_true(is.nan(dbnbinom(1, -1, 1, 1)))) expect_warning(expect_true(is.nan(dbnbinom(1, 1, -1, 1)))) expect_warning(expect_true(is.nan(dbnbinom(1, 1, 1, -1)))) expect_warning(expect_true(is.nan(dbvnorm(1, 1, sd1 = -1)))) expect_warning(expect_true(is.nan(dbvnorm(1, 1, sd2 = -1)))) expect_warning(expect_true(is.nan(dbvnorm(1, 1, cor = -2)))) expect_warning(expect_true(is.nan(dbvnorm(1, 1, cor = 2)))) expect_warning(expect_true(is.nan(dbvpois(1, 1, -1, 1, 1)))) expect_warning(expect_true(is.nan(dbvpois(1, 1, 1, -1, 1)))) expect_warning(expect_true(is.nan(dbvpois(1, 1, 1, 1, -1)))) expect_warning(expect_true(is.nan(dcat(1, c(-1, 0.5))))) expect_warning(expect_true(is.nan(dcat(1, c(0.5, -1))))) expect_warning(expect_true(is.nan(ddirichlet(c(0.5, 0.5), c(-1, 0.5))))) expect_warning(expect_true(is.nan(ddirichlet(c(0.5, 0.5), c(0.5, -1))))) expect_warning(expect_true(is.nan(ddlaplace(1, 0, scale = -1)))) expect_warning(expect_true(is.nan(ddlaplace(1, 0, scale = 2)))) expect_warning(expect_true(is.nan(ddnorm(1, sd = -1)))) expect_warning(expect_true(is.nan(ddgamma(1, -9, 1)))) expect_warning(expect_true(is.nan(ddgamma(1, 9, -1)))) expect_warning(expect_true(is.nan(ddunif(1, min = 10, max = 1)))) expect_warning(expect_true(is.nan(ddunif(1, min = 0, max = Inf)))) expect_warning(expect_true(is.nan(ddunif(1, min = -Inf, max = Inf)))) expect_warning(expect_true(is.nan(ddunif(1, min = Inf, max = -Inf)))) expect_warning(expect_true(is.nan(ddweibull(1, -1, 1)))) expect_warning(expect_true(is.nan(ddweibull(1, 2, 1)))) expect_warning(expect_true(is.nan(ddweibull(1, 0.5, -1)))) expect_warning(expect_true(is.nan(dfatigue(1, -1, 1)))) expect_warning(expect_true(is.nan(dfatigue(1, 1, -1)))) expect_warning(expect_true(is.nan(dfrechet(1, lambda = -1)))) expect_warning(expect_true(is.nan(dfrechet(1, sigma = -1)))) expect_warning(expect_true(is.nan(dgev(1, 1, -1, 1)))) expect_warning(expect_true(is.nan(dgompertz(1, -1, 1)))) expect_warning(expect_true(is.nan(dgompertz(1, 1, -1)))) expect_warning(expect_true(is.nan(dgpd(1, 1, -1, 1)))) expect_warning(expect_true(is.nan(dgpois(1, -1, 1)))) expect_warning(expect_true(is.nan(dgpois(1, 1, -1)))) expect_warning(expect_true(is.nan(dgpois(1, 1, scale = 0)))) expect_warning(expect_true(is.nan(dgumbel(1, sigma = -1)))) expect_warning(expect_true(is.nan(dhcauchy(1, -1)))) expect_warning(expect_true(is.nan(dhnorm(1, -1)))) expect_warning(expect_true(is.nan(dht(1, 5, -1)))) expect_warning(expect_true(is.nan(dhuber(1, 0, -1, 1)))) expect_warning(expect_true(is.nan(dhuber(1, 0, 1, -1)))) expect_warning(expect_true(is.nan(dinvgamma(1, -1, 1)))) expect_warning(expect_true(is.nan(dinvgamma(1, 1, -1)))) expect_warning(expect_true(is.nan(dinvchisq(1, -1, 1)))) expect_warning(expect_true(is.nan(dinvchisq(1, 1, -1)))) expect_warning(expect_true(is.nan(dkumar(0.5, -1, 1)))) expect_warning(expect_true(is.nan(dkumar(0.5, 1, -1)))) expect_warning(expect_true(is.nan(dlaplace(1, 0, -1)))) expect_warning(expect_true(is.nan(dlgser(1, -1)))) expect_warning(expect_true(is.nan(dlgser(1, 2)))) expect_warning(expect_true(is.nan(dlomax(1, -1, 1)))) expect_warning(expect_true(is.nan(dlomax(1, 1, -1)))) expect_warning(expect_true(is.nan(dmixnorm(0, c(1,2,3), c(-1,2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.nan(dmixnorm(0, c(1,2,3), c(1,-2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.nan(dmixnorm(0, c(1,2,3), c(1,2,-3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.nan(dmixnorm(0, c(1,2,3), c(1,2,3), c(-1,1/3,1/3))))) expect_warning(expect_true(is.nan(dmixnorm(0, c(1,2,3), c(1,2,3), c(1/3,-1,1/3))))) expect_warning(expect_true(is.nan(dmixnorm(0, c(1,2,3), c(1,2,3), c(1/3,1/3,-1))))) expect_warning(expect_true(is.nan(dmixpois(0, c(-1,2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.nan(dmixpois(0, c(1,-2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.nan(dmixpois(0, c(1,2,-3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.nan(dmixpois(0, c(1,2,3), c(-1,1/3,1/3))))) expect_warning(expect_true(is.nan(dmixpois(0, c(1,2,3), c(1/3,-1,1/3))))) expect_warning(expect_true(is.nan(dmixpois(0, c(1,2,3), c(1/3,1/3,-1))))) expect_warning(expect_true(is.nan(dnhyper(1, 60.5, 35, 15)))) expect_warning(expect_true(is.nan(dnhyper(1, 60, 35.5, 15)))) expect_warning(expect_true(is.nan(dnhyper(1, 60, 35, 15.5)))) expect_warning(expect_true(is.nan(dnhyper(1, -60, 35, 15)))) expect_warning(expect_true(is.nan(dnhyper(1, 60, -35, 15)))) expect_warning(expect_true(is.nan(dnhyper(1, 60, 35, -15)))) expect_warning(expect_true(is.nan(dnhyper(1, 60, 35, 40)))) expect_warning(expect_true(is.nan(dnhyper(1, 60.5, 35, 15)))) expect_warning(expect_true(is.nan(dnhyper(1, 60.5, 35, 15)))) expect_warning(expect_true(is.nan(dnhyper(1, 60.5, 35, 15)))) expect_warning(expect_true(is.nan(ddirmnom(c(1, 1, 1), 1.5, c(1, 1, 1))))) expect_warning(expect_true(is.nan(ddirmnom(c(1, 1, 1), -3, c(1, 1, 1))))) expect_warning(expect_true(is.nan(ddirmnom(c(1, 1, 1), 3, c(-1, 1, 1))))) expect_warning(expect_true(is.nan(ddirmnom(c(1, 1, 1), 3, c(1, -1, 1))))) expect_warning(expect_true(is.nan(ddirmnom(c(1, 1, 1), 3, c(1, 1, -1))))) expect_warning(expect_true(is.nan(dmnom(c(1, 1, 1), 1.5, c(1/3, 1/3, 1/3))))) expect_warning(expect_true(is.nan(dmnom(c(1, 1, 1), 3, c(-1, 1/3, 1/3))))) expect_warning(expect_true(is.nan(dmnom(c(1, 1, 1), 3, c(1/3, -1, 1/3))))) expect_warning(expect_true(is.nan(dmnom(c(1, 1, 1), 3, c(1/3, 1/3, -1))))) expect_warning(expect_true(is.nan(dmvhyper(c(1, 2, 2), c(2.5,3,4), 5)))) expect_warning(expect_true(is.nan(dmvhyper(c(1, 2, 2), c(2,3.5,4), 5)))) expect_warning(expect_true(is.nan(dmvhyper(c(1, 2, 2), c(2,3,4.5), 5)))) expect_warning(expect_true(is.nan(dmvhyper(c(1, 2, 2), c(2,3,4), 5.5)))) expect_warning(expect_true(is.nan(dmvhyper(c(1, 2, 2), c(-2,3,4), 5)))) expect_warning(expect_true(is.nan(dmvhyper(c(1, 2, 2), c(2,-3,4), 5)))) expect_warning(expect_true(is.nan(dmvhyper(c(1, 2, 2), c(2,3,-4), 5)))) expect_warning(expect_true(is.nan(dmvhyper(c(1, 2, 2), c(2,3,4), -5)))) expect_warning(expect_true(is.nan(dmvhyper(c(1, 2, 2), c(2,3,4), 85)))) expect_warning(expect_true(is.nan(dnsbeta(0.5, -1, 1, -2, 2)))) expect_warning(expect_true(is.nan(dnsbeta(0.5, 1, -1, -2, 2)))) expect_warning(expect_true(is.nan(dnsbeta(0.5, 1, 1, 2, -2)))) expect_warning(expect_true(is.nan(dlst(1, -2, 0, 1)))) expect_warning(expect_true(is.nan(dlst(1, 2, 0, -1)))) expect_warning(expect_true(is.nan(dpareto(0, -1, 1)))) expect_warning(expect_true(is.nan(dpareto(0, 1, -1)))) expect_warning(expect_true(is.nan(dprop(1, -10, 0.5)))) expect_warning(expect_true(is.nan(dprop(1, 10, -1)))) expect_warning(expect_true(is.nan(dprop(1, 10, 2)))) expect_warning(expect_true(is.nan(drayleigh(0, -1)))) expect_warning(expect_true(is.nan(dsgomp(1, -0.4, 1)))) expect_warning(expect_true(is.nan(dsgomp(1, 0.4, -1)))) expect_warning(expect_true(is.nan(dskellam(1, -1, 1)))) expect_warning(expect_true(is.nan(dskellam(1, 1, -1)))) expect_warning(expect_true(is.nan(dslash(1, sigma = -1)))) expect_warning(expect_true(is.nan(dtnorm(1, 0, -1, -2, 2)))) expect_warning(expect_true(is.nan(dtnorm(1, 0, 1, 2, -2)))) expect_warning(expect_true(is.nan(dtnorm(1, 0, 1, 0, 0)))) expect_warning(expect_true(is.nan(dtpois(1, lambda = -5, a = 0)))) expect_warning(expect_true(is.nan(dtpois(1, lambda = -5, a = 6)))) expect_warning(expect_true(is.nan(dtpois(1, lambda = -5, a = 6, b = 5)))) expect_warning(expect_true(is.nan(dtriang(1, 0, 0, 0)))) expect_warning(expect_true(is.nan(dtriang(1, 1, -1, 0)))) expect_warning(expect_true(is.nan(dtriang(1, -1, 1, 2)))) expect_warning(expect_true(is.nan(dtriang(1, -1, 1, -2)))) expect_warning(expect_true(is.nan(dwald(1, 1, -1)))) expect_warning(expect_true(is.nan(dzip(1, -1, 0.5)))) expect_warning(expect_true(is.nan(dzip(1, 1, -1)))) expect_warning(expect_true(is.nan(dzip(1, 1, 2)))) expect_warning(expect_true(is.nan(dzib(1, -1, 0.5, 0.5)))) expect_warning(expect_true(is.nan(dzib(1, 1, -1, 0.5)))) expect_warning(expect_true(is.nan(dzib(1, 1, 0.5, 2)))) expect_warning(expect_true(is.nan(dzib(1, 1, -1, 0.5)))) expect_warning(expect_true(is.nan(dzib(1, 1, 0.5, 2)))) expect_warning(expect_true(is.nan(dzinb(1, -1, 0.5, 0.5)))) expect_warning(expect_true(is.nan(dzinb(1, 1, -1, 0.5)))) expect_warning(expect_true(is.nan(dzinb(1, 1, 0.5, 2)))) expect_warning(expect_true(is.nan(dzinb(1, 1, -1, 0.5)))) expect_warning(expect_true(is.nan(dzinb(1, 1, 0.5, 2)))) }) test_that("Wrong parameter values in CDF functions", { expect_warning(expect_true(is.nan(pbbinom(1, -1, 1, 1)))) expect_warning(expect_true(is.nan(pbbinom(1, 1, -1, 1)))) expect_warning(expect_true(is.nan(pbbinom(1, 1, 1, -1)))) expect_warning(expect_true(is.nan(pbbinom(1, c(-1, 1), c(1, 1), c(1, 1))[1]))) expect_warning(expect_true(is.nan(pbbinom(1, c(1, 1), c(-1, 1), c(1, 1))[1]))) expect_warning(expect_true(is.nan(pbbinom(1, c(1, 1), c(1, 1), c(-1, 1))[1]))) expect_warning(expect_true(is.nan(pbbinom(1, c(1, -1), c(1, 1), c(1, 1))[2]))) expect_warning(expect_true(is.nan(pbbinom(1, c(1, 1), c(1, -1), c(1, 1))[2]))) expect_warning(expect_true(is.nan(pbbinom(1, c(1, 1), c(1, 1), c(1, -1))[2]))) expect_warning(expect_true(is.nan(pbetapr(1, -1, 1, 1)))) expect_warning(expect_true(is.nan(pbetapr(1, 1, -1, 1)))) expect_warning(expect_true(is.nan(pbetapr(1, 1, 1, -1)))) expect_warning(expect_true(is.nan(pbern(1, -1)))) expect_warning(expect_true(is.nan(pbern(1, 2)))) expect_warning(expect_true(is.nan(pbhatt(1, sigma = -1)))) expect_warning(expect_true(is.nan(pbhatt(1, a = -1)))) expect_warning(expect_true(is.nan(pbnbinom(1, -1, 1, 1)))) expect_warning(expect_true(is.nan(pbnbinom(1, 1, -1, 1)))) expect_warning(expect_true(is.nan(pbnbinom(1, 1, 1, -1)))) expect_warning(expect_true(is.nan(pcat(1, c(-1, 0.5))))) expect_warning(expect_true(is.nan(pcat(1, c(0.5, -1))))) expect_warning(expect_true(is.nan(pdlaplace(1, 0, scale = -1)))) expect_warning(expect_true(is.nan(pdlaplace(1, 0, scale = 2)))) expect_warning(expect_true(is.nan(pdnorm(1, sd = -1)))) expect_warning(expect_true(is.nan(pdgamma(1, -9, 1)))) expect_warning(expect_true(is.nan(pdgamma(1, 9, -1)))) expect_warning(expect_true(is.nan(pdunif(1, min = 10, max = 1)))) expect_warning(expect_true(is.nan(pdunif(1, min = 0, max = Inf)))) expect_warning(expect_true(is.nan(pdunif(1, min = -Inf, max = Inf)))) expect_warning(expect_true(is.nan(pdunif(1, min = Inf, max = -Inf)))) expect_warning(expect_true(is.nan(pdweibull(1, -1, 1)))) expect_warning(expect_true(is.nan(pdweibull(1, 2, 1)))) expect_warning(expect_true(is.nan(pdweibull(1, 0.5, -1)))) expect_warning(expect_true(is.nan(pfatigue(1, -1, 1)))) expect_warning(expect_true(is.nan(pfatigue(1, 1, -1)))) expect_warning(expect_true(is.nan(pfrechet(1, lambda = -1)))) expect_warning(expect_true(is.nan(pfrechet(1, sigma = -1)))) expect_warning(expect_true(is.nan(pgev(1, 1, -1, 1)))) expect_warning(expect_true(is.nan(pgompertz(1, -1, 1)))) expect_warning(expect_true(is.nan(pgompertz(1, 1, -1)))) expect_warning(expect_true(is.nan(pgpd(1, 1, -1, 1)))) expect_warning(expect_true(is.nan(pgpois(1, -1, 1)))) expect_warning(expect_true(is.nan(pgpois(1, 1, -1)))) expect_warning(expect_true(is.nan(pgpois(1, 1, scale = 0)))) expect_warning(expect_true(is.nan(pgumbel(1, sigma = -1)))) expect_warning(expect_true(is.nan(phcauchy(1, -1)))) expect_warning(expect_true(is.nan(phnorm(1, -1)))) expect_warning(expect_true(is.nan(pht(1, 5, -1)))) expect_warning(expect_true(is.nan(phuber(1, 0, -1, 1)))) expect_warning(expect_true(is.nan(phuber(1, 0, 1, -1)))) expect_warning(expect_true(is.nan(pinvgamma(1, -1, 1)))) expect_warning(expect_true(is.nan(pinvgamma(1, 1, -1)))) expect_warning(expect_true(is.nan(pinvchisq(1, -1, 1)))) expect_warning(expect_true(is.nan(pinvchisq(1, 1, -1)))) expect_warning(expect_true(is.nan(pkumar(0.5, -1, 1)))) expect_warning(expect_true(is.nan(pkumar(0.5, 1, -1)))) expect_warning(expect_true(is.nan(plaplace(1, 0, -1)))) expect_warning(expect_true(is.nan(plgser(1, -1)))) expect_warning(expect_true(is.nan(plgser(1, 2)))) expect_warning(expect_true(is.nan(plomax(1, -1, 1)))) expect_warning(expect_true(is.nan(plomax(1, 1, -1)))) expect_warning(expect_true(is.nan(pmixnorm(0, c(1,2,3), c(-1,2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.nan(pmixnorm(0, c(1,2,3), c(1,-2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.nan(pmixnorm(0, c(1,2,3), c(1,2,-3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.nan(pmixnorm(0, c(1,2,3), c(1,2,3), c(-1,1/3,1/3))))) expect_warning(expect_true(is.nan(pmixnorm(0, c(1,2,3), c(1,2,3), c(1/3,-1,1/3))))) expect_warning(expect_true(is.nan(pmixnorm(0, c(1,2,3), c(1,2,3), c(1/3,1/3,-1))))) expect_warning(expect_true(is.nan(pmixpois(0, c(-1,2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.nan(pmixpois(0, c(1,-2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.nan(pmixpois(0, c(1,2,-3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.nan(pmixpois(0, c(1,2,3), c(-1,1/3,1/3))))) expect_warning(expect_true(is.nan(pmixpois(0, c(1,2,3), c(1/3,-1,1/3))))) expect_warning(expect_true(is.nan(pmixpois(0, c(1,2,3), c(1/3,1/3,-1))))) expect_warning(expect_true(is.nan(pnhyper(1, 60.5, 35, 15)))) expect_warning(expect_true(is.nan(pnhyper(1, 60, 35.5, 15)))) expect_warning(expect_true(is.nan(pnhyper(1, 60, 35, 15.5)))) expect_warning(expect_true(is.nan(pnhyper(1, -60, 35, 15)))) expect_warning(expect_true(is.nan(pnhyper(1, 60, -35, 15)))) expect_warning(expect_true(is.nan(pnhyper(1, 60, 35, -15)))) expect_warning(expect_true(is.nan(pnhyper(1, 60, 35, 40)))) expect_warning(expect_true(is.nan(pnsbeta(0.5, -1, 1, -2, 2)))) expect_warning(expect_true(is.nan(pnsbeta(0.5, 1, -1, -2, 2)))) expect_warning(expect_true(is.nan(pnsbeta(0.5, 1, 1, 2, -2)))) expect_warning(expect_true(is.nan(plst(1, -2, 0, 1)))) expect_warning(expect_true(is.nan(plst(1, 2, 0, -1)))) expect_warning(expect_true(is.nan(ppareto(0, -1, 1)))) expect_warning(expect_true(is.nan(ppareto(0, 1, -1)))) expect_warning(expect_true(is.nan(pprop(1, -10, 0.5)))) expect_warning(expect_true(is.nan(pprop(1, 10, -1)))) expect_warning(expect_true(is.nan(pprop(1, 10, 2)))) expect_warning(expect_true(is.nan(prayleigh(0, -1)))) expect_warning(expect_true(is.nan(psgomp(1, -0.4, 1)))) expect_warning(expect_true(is.nan(psgomp(1, 0.4, -1)))) expect_warning(expect_true(is.nan(pslash(1, sigma = -1)))) expect_warning(expect_true(is.nan(ptnorm(1, 0, -1, -2, 2)))) expect_warning(expect_true(is.nan(ptnorm(1, 0, 1, 2, -2)))) expect_warning(expect_true(is.nan(ptnorm(1, 0, 1, 0, 0)))) expect_warning(expect_true(is.nan(ptpois(1, lambda = -5, a = 0)))) expect_warning(expect_true(is.nan(ptpois(1, lambda = -5, a = 6)))) expect_warning(expect_true(is.nan(ptpois(1, lambda = -5, a = 6, b = 5)))) expect_warning(expect_true(is.nan(ptriang(1, 0, 0, 0)))) expect_warning(expect_true(is.nan(ptriang(1, 1, -1, 0)))) expect_warning(expect_true(is.nan(ptriang(1, -1, 1, 2)))) expect_warning(expect_true(is.nan(ptriang(1, -1, 1, -2)))) expect_warning(expect_true(is.nan(pwald(1, 1, -1)))) expect_warning(expect_true(is.nan(pzip(1, -1, 0.5)))) expect_warning(expect_true(is.nan(pzip(1, 1, -1)))) expect_warning(expect_true(is.nan(pzip(1, 1, 2)))) expect_warning(expect_true(is.nan(pzib(1, -1, 0.5, 0.5)))) expect_warning(expect_true(is.nan(pzib(1, 1, -1, 0.5)))) expect_warning(expect_true(is.nan(pzib(1, 1, 0.5, 2)))) expect_warning(expect_true(is.nan(pzib(1, 1, -1, 0.5)))) expect_warning(expect_true(is.nan(pzib(1, 1, 0.5, 2)))) expect_warning(expect_true(is.nan(pzinb(1, -1, 0.5, 0.5)))) expect_warning(expect_true(is.nan(pzinb(1, 1, -1, 0.5)))) expect_warning(expect_true(is.nan(pzinb(1, 1, 0.5, 2)))) expect_warning(expect_true(is.nan(pzinb(1, 1, -1, 0.5)))) expect_warning(expect_true(is.nan(pzinb(1, 1, 0.5, 2)))) }) test_that("Wrong parameter values in quantile functions", { expect_warning(expect_true(is.nan(qbetapr(0.5, -1, 1, 1)))) expect_warning(expect_true(is.nan(qbetapr(0.5, 1, -1, 1)))) expect_warning(expect_true(is.nan(qbetapr(0.5, 1, 1, -1)))) expect_warning(expect_true(is.nan(qbern(0.5, -1)))) expect_warning(expect_true(is.nan(qbern(0.5, 2)))) expect_warning(expect_true(is.nan(qcat(0.5, c(-1, 0.5))))) expect_warning(expect_true(is.nan(qcat(0.5, c(0.5, -1))))) expect_warning(expect_true(is.nan(qdunif(0.5, min = 10, max = 1)))) expect_warning(expect_true(is.nan(qdunif(0.5, min = 0, max = Inf)))) expect_warning(expect_true(is.nan(qdunif(0.5, min = -Inf, max = Inf)))) expect_warning(expect_true(is.nan(qdunif(0.5, min = Inf, max = -Inf)))) expect_warning(expect_true(is.nan(qdweibull(0.5, -1, 1)))) expect_warning(expect_true(is.nan(qdweibull(0.5, 2, 1)))) expect_warning(expect_true(is.nan(qdweibull(0.5, 0.5, -1)))) expect_warning(expect_true(is.nan(qfatigue(0.5, -1, 1)))) expect_warning(expect_true(is.nan(qfatigue(0.5, 1, -1)))) expect_warning(expect_true(is.nan(qfrechet(0.5, lambda = -1)))) expect_warning(expect_true(is.nan(qfrechet(0.5, sigma = -1)))) expect_warning(expect_true(is.nan(qgev(0.5, 1, -1, 1)))) expect_warning(expect_true(is.nan(qgompertz(0.5, -1, 1)))) expect_warning(expect_true(is.nan(qgompertz(0.5, 1, -1)))) expect_warning(expect_true(is.nan(qgpd(0.5, 1, -1, 1)))) expect_warning(expect_true(is.nan(qgumbel(0.5, sigma = -1)))) expect_warning(expect_true(is.nan(qhcauchy(0.5, -1)))) expect_warning(expect_true(is.nan(qhnorm(0.5, -1)))) expect_warning(expect_true(is.nan(qht(0.5, 5, -1)))) expect_warning(expect_true(is.nan(qhuber(0.5, 0, -1, 1)))) expect_warning(expect_true(is.nan(qhuber(0.5, 0, 1, -1)))) expect_warning(expect_true(is.nan(qinvgamma(0.5, -1, 1)))) expect_warning(expect_true(is.nan(qinvgamma(0.5, 1, -1)))) expect_warning(expect_true(is.nan(qinvchisq(0.5, -1, 1)))) expect_warning(expect_true(is.nan(qinvchisq(0.5, 1, -1)))) expect_warning(expect_true(is.nan(qkumar(0.5, -1, 1)))) expect_warning(expect_true(is.nan(qkumar(0.5, 1, -1)))) expect_warning(expect_true(is.nan(qlaplace(0.5, 0, -1)))) expect_warning(expect_true(is.nan(qlgser(0.5, -1)))) expect_warning(expect_true(is.nan(qlgser(0.5, 2)))) expect_warning(expect_true(is.nan(qlomax(0.5, -1, 1)))) expect_warning(expect_true(is.nan(qlomax(0.5, 1, -1)))) expect_warning(expect_true(is.nan(qnhyper(0.5, 60.5, 35, 15)))) expect_warning(expect_true(is.nan(qnhyper(0.5, 60, 35.5, 15)))) expect_warning(expect_true(is.nan(qnhyper(0.5, 60, 35, 15.5)))) expect_warning(expect_true(is.nan(qnhyper(0.5, -60, 35, 15)))) expect_warning(expect_true(is.nan(qnhyper(0.5, 60, -35, 15)))) expect_warning(expect_true(is.nan(qnhyper(0.5, 60, 35, -15)))) expect_warning(expect_true(is.nan(qnhyper(0.5, 60, 35, 40)))) expect_warning(expect_true(is.nan(qnsbeta(0.5, -1, 1, -2, 2)))) expect_warning(expect_true(is.nan(qnsbeta(0.5, 1, -1, -2, 2)))) expect_warning(expect_true(is.nan(qnsbeta(0.5, 1, 1, 2, -2)))) expect_warning(expect_true(is.nan(qlst(0.5, -2, 0, 1)))) expect_warning(expect_true(is.nan(qlst(0.5, 2, 0, -1)))) expect_warning(expect_true(is.nan(qpareto(0.5, -1, 1)))) expect_warning(expect_true(is.nan(qpareto(0.5, 1, -1)))) expect_warning(expect_true(is.nan(qprop(0.5, -10, 0.5)))) expect_warning(expect_true(is.nan(qprop(0.5, 10, -1)))) expect_warning(expect_true(is.nan(qprop(0.5, 10, 2)))) expect_warning(expect_true(is.nan(qrayleigh(0, -1)))) expect_warning(expect_true(is.nan(qtnorm(0.5, 0, -1, -2, 2)))) expect_warning(expect_true(is.nan(qtnorm(0.5, 0, 1, 2, -2)))) expect_warning(expect_true(is.nan(qtnorm(0.5, 0, 1, 0, 0)))) expect_warning(expect_true(is.nan(qtpois(0.5, lambda = -5, a = 0)))) expect_warning(expect_true(is.nan(qtpois(0.5, lambda = -5, a = 6)))) expect_warning(expect_true(is.nan(qtpois(0.5, lambda = -5, a = 6, b = 5)))) expect_warning(expect_true(is.nan(qtriang(0.5, 0, 0, 0)))) expect_warning(expect_true(is.nan(qtriang(0.5, 1, -1, 0)))) expect_warning(expect_true(is.nan(qtriang(0.5, -1, 1, 2)))) expect_warning(expect_true(is.nan(qtriang(0.5, -1, 1, -2)))) expect_warning(expect_true(is.nan(qzip(0.5, -1, 0.5)))) expect_warning(expect_true(is.nan(qzip(0.5, 1, -1)))) expect_warning(expect_true(is.nan(qzip(0.5, 1, 2)))) expect_warning(expect_true(is.nan(qzib(0.5, -1, 0.5, 0.5)))) expect_warning(expect_true(is.nan(qzib(0.5, 1, -1, 0.5)))) expect_warning(expect_true(is.nan(qzib(0.5, 1, 0.5, 2)))) expect_warning(expect_true(is.nan(qzib(0.5, 1, -1, 0.5)))) expect_warning(expect_true(is.nan(qzib(0.5, 1, 0.5, 2)))) expect_warning(expect_true(is.nan(qzinb(0.5, -1, 0.5, 0.5)))) expect_warning(expect_true(is.nan(qzinb(0.5, 1, -1, 0.5)))) expect_warning(expect_true(is.nan(qzinb(0.5, 1, 0.5, 2)))) expect_warning(expect_true(is.nan(qzinb(0.5, 1, -1, 0.5)))) expect_warning(expect_true(is.nan(qzinb(0.5, 1, 0.5, 2)))) }) test_that("Wrong parameter values in RNG functions", { expect_warning(expect_true(is.na(rbbinom(1, -1, 1, 1)))) expect_warning(expect_true(is.na(rbbinom(1, 1, -1, 1)))) expect_warning(expect_true(is.na(rbbinom(1, 1, 1, -1)))) expect_warning(expect_true(is.na(rbetapr(1, -1, 1, 1)))) expect_warning(expect_true(is.na(rbetapr(1, 1, -1, 1)))) expect_warning(expect_true(is.na(rbetapr(1, 1, 1, -1)))) expect_warning(expect_true(is.na(rbern(1, -1)))) expect_warning(expect_true(is.na(rbern(1, 2)))) expect_warning(expect_true(is.na(rbhatt(1, sigma = -1)))) expect_warning(expect_true(is.na(rbhatt(1, a = -1)))) expect_warning(expect_true(all(is.na(rbnbinom(1, -1, 1, 1))))) expect_warning(expect_true(all(is.na(rbnbinom(1, 1, -1, 1))))) expect_warning(expect_true(all(is.na(rbnbinom(1, 1, 1, -1))))) expect_warning(expect_true(all(is.na(rbvnorm(1, sd1 = -1))))) expect_warning(expect_true(all(is.na(rbvnorm(1, sd2 = -1))))) expect_warning(expect_true(all(is.na(rbvnorm(1, cor = -2))))) expect_warning(expect_true(all(is.na(rbvnorm(1, cor = 2))))) expect_warning(expect_true(all(is.na(rbvpois(1, -1, 1, 1))))) expect_warning(expect_true(all(is.na(rbvpois(1, 1, -1, 1))))) expect_warning(expect_true(all(is.na(rbvpois(1, 1, 1, -1))))) expect_warning(expect_true(is.na(rcat(1, c(-1, 0.5))))) expect_warning(expect_true(is.na(rcat(1, c(0.5, -1))))) expect_warning(expect_true(is.na(rcat(2, matrix(c(-1, 0.5, 0.5, 0.5), byrow = T, ncol = 2))[1]))) expect_warning(expect_true(is.na(rcat(2, matrix(c(0.5, -1, 0.5, 0.5), byrow = T, ncol = 2))[1]))) expect_warning(expect_true(is.na(rcat(2, matrix(c(0.5, 0.5, -1, 0.5), byrow = T, ncol = 2))[2]))) expect_warning(expect_true(is.na(rcat(2, matrix(c(0.5, 0.5, 0.5, -1), byrow = T, ncol = 2))[2]))) expect_warning(expect_true(all(is.na(rdirichlet(1, c(-1, 0.5)))))) expect_warning(expect_true(all(is.na(rdirichlet(1, c(0.5, -1)))))) expect_warning(expect_true(is.na(rdnorm(1, sd = -1)))) expect_warning(expect_true(is.nan(rdgamma(1, -9, 1)))) expect_warning(expect_true(is.nan(rdgamma(1, 9, -1)))) expect_warning(expect_true(is.na(rdunif(1, min = 10, max = 1)))) expect_warning(expect_true(is.na(rdunif(1, min = 0, max = Inf)))) expect_warning(expect_true(is.na(rdunif(1, min = -Inf, max = Inf)))) expect_warning(expect_true(is.na(rdunif(1, min = Inf, max = -Inf)))) expect_warning(expect_true(is.na(rdweibull(1, -1, 1)))) expect_warning(expect_true(is.na(rdweibull(1, 2, 1)))) expect_warning(expect_true(is.na(rdweibull(1, 0.5, -1)))) expect_warning(expect_true(is.na(rfatigue(1, -1, 1)))) expect_warning(expect_true(is.na(rfatigue(1, 1, -1)))) expect_warning(expect_true(is.na(rfrechet(1, lambda = -1)))) expect_warning(expect_true(is.na(rfrechet(1, sigma = -1)))) expect_warning(expect_true(is.na(rgev(1, 1, -1, 1)))) expect_warning(expect_true(is.na(rgompertz(1, -1, 1)))) expect_warning(expect_true(is.na(rgompertz(1, 1, -1)))) expect_warning(expect_true(is.na(rgpd(1, 1, -1, 1)))) expect_warning(expect_true(is.na(rgpois(1, -1, 1)))) expect_warning(expect_true(is.na(rgpois(1, 1, -1)))) expect_warning(expect_true(is.na(rgpois(1, 1, scale = 0)))) expect_warning(expect_true(is.na(rgumbel(1, sigma = -1)))) expect_warning(expect_true(is.na(rhcauchy(1, -1)))) expect_warning(expect_true(is.na(rhnorm(1, -1)))) expect_warning(expect_true(is.na(rht(1, 5, -1)))) expect_warning(expect_true(is.na(rhuber(1, 0, -1, 1)))) expect_warning(expect_true(is.na(rhuber(1, 0, 1, -1)))) expect_warning(expect_true(is.na(rinvgamma(1, -1, 1)))) expect_warning(expect_true(is.na(rinvgamma(1, 1, -1)))) expect_warning(expect_true(is.na(rinvchisq(1, -1, 1)))) expect_warning(expect_true(is.na(rinvchisq(1, 1, -1)))) expect_warning(expect_true(is.na(rkumar(1, -1, 1)))) expect_warning(expect_true(is.na(rkumar(1, 1, -1)))) expect_warning(expect_true(is.na(rlaplace(1, 0, -1)))) expect_warning(expect_true(is.na(rlgser(1, -1)))) expect_warning(expect_true(is.na(rlgser(1, 2)))) expect_warning(expect_true(is.na(rlomax(1, -1, 1)))) expect_warning(expect_true(is.na(rlomax(1, 1, -1)))) expect_warning(expect_true(is.na(rmixnorm(1, c(1,2,3), c(-1,2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixnorm(1, c(1,2,3), c(1,-2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixnorm(1, c(1,2,3), c(1,2,-3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixnorm(1, c(1,2,3), c(1,2,3), c(-1,1/3,1/3))))) expect_warning(expect_true(is.na(rmixnorm(1, c(1,2,3), c(1,2,3), c(1/3,-1,1/3))))) expect_warning(expect_true(is.na(rmixnorm(1, c(1,2,3), c(1,2,3), c(1/3,1/3,-1))))) expect_warning(expect_true(is.na(rmixpois(1, c(-1,2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixpois(1, c(1,-2,3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixpois(1, c(1,2,-3), c(1/3,1/3,1/3))))) expect_warning(expect_true(is.na(rmixpois(1, c(1,2,3), c(-1,1/3,1/3))))) expect_warning(expect_true(is.na(rmixpois(1, c(1,2,3), c(1/3,-1,1/3))))) expect_warning(expect_true(is.na(rmixpois(1, c(1,2,3), c(1/3,1/3,-1))))) expect_warning(expect_true(is.na(rnhyper(1, 60.5, 35, 15)))) expect_warning(expect_true(is.na(rnhyper(1, 60, 35.5, 15)))) expect_warning(expect_true(is.na(rnhyper(1, 60, 35, 15.5)))) expect_warning(expect_true(is.na(rnhyper(1, -60, 35, 15)))) expect_warning(expect_true(is.na(rnhyper(1, 60, -35, 15)))) expect_warning(expect_true(is.na(rnhyper(1, 60, 35, -15)))) expect_warning(expect_true(is.na(rnhyper(1, 60, 35, 40)))) expect_warning(expect_true(all(is.na(rdirmnom(1, 1.5, c(1, 1, 1)))))) expect_warning(expect_true(all(is.na(rdirmnom(1, -3, c(1, 1, 1)))))) expect_warning(expect_true(all(is.na(rdirmnom(1, 3, c(-1, 1, 1)))))) expect_warning(expect_true(all(is.na(rdirmnom(1, 3, c(1, -1, 1)))))) expect_warning(expect_true(all(is.na(rdirmnom(1, 3, c(1, 1, -1)))))) expect_warning(expect_true(all(is.na(rmnom(1, 3, c(-1, 1/3, 1/3)))))) expect_warning(expect_true(all(is.na(rmnom(1, 3, c(1/3, -1, 1/3)))))) expect_warning(expect_true(all(is.na(rmnom(1, 3, c(1/3, 1/3, -1)))))) expect_warning(expect_true(all(is.na(rmvhyper(1, c(2,3,4), 99))))) expect_warning(expect_true(all(is.na(rmvhyper(1, c(-2,3,4), 99))))) expect_warning(expect_true(all(is.na(rmvhyper(1, c(2,-3,4), 99))))) expect_warning(expect_true(all(is.na(rmvhyper(1, c(2,3,-4), 99))))) expect_warning(expect_true(is.na(rnsbeta(1, -1, 1, -2, 2)))) expect_warning(expect_true(is.na(rnsbeta(1, 1, -1, -2, 2)))) expect_warning(expect_true(is.na(rnsbeta(1, 1, 1, 2, -2)))) expect_warning(expect_true(is.na(rlst(1, -2, 0, 1)))) expect_warning(expect_true(is.na(rlst(1, 2, 0, -1)))) expect_warning(expect_true(is.na(rpareto(1, -1, 1)))) expect_warning(expect_true(is.na(rpareto(1, 1, -1)))) expect_warning(expect_true(is.na(rprop(1, -10, 0.5)))) expect_warning(expect_true(is.na(rprop(1, 10, -1)))) expect_warning(expect_true(is.na(rprop(1, 10, 2)))) expect_warning(expect_true(is.na(rrayleigh(1, -1)))) expect_warning(expect_true(is.na(rsgomp(1, -0.4, 1)))) expect_warning(expect_true(is.na(rsgomp(1, 0.4, -1)))) expect_warning(expect_true(is.na(rskellam(1, -1, 1)))) expect_warning(expect_true(is.na(rskellam(1, 1, -1)))) expect_warning(expect_true(is.na(rslash(1, sigma = -1)))) expect_warning(expect_true(is.na(rtnorm(1, 0, -1, -2, 2)))) expect_warning(expect_true(is.na(rtnorm(1, 0, 1, 2, -2)))) expect_warning(expect_true(is.na(rtnorm(1, 0, 1, 0, 0)))) expect_warning(expect_true(is.na(rtpois(1, lambda = -5, a = 0)))) expect_warning(expect_true(is.na(rtpois(1, lambda = -5, a = 6)))) expect_warning(expect_true(is.na(rtpois(1, lambda = -5, a = 6, b = 5)))) expect_warning(expect_true(is.na(rtriang(1, 0, 0, 0)))) expect_warning(expect_true(is.na(rtriang(1, 1, -1, 0)))) expect_warning(expect_true(is.na(rtriang(1, -1, 1, 2)))) expect_warning(expect_true(is.na(rtriang(1, -1, 1, -2)))) expect_warning(expect_true(is.na(rwald(1, 1, -1)))) expect_warning(expect_true(is.na(rzip(1, -1, 0.5)))) expect_warning(expect_true(is.na(rzip(1, 1, -1)))) expect_warning(expect_true(is.na(rzip(1, 1, 2)))) expect_warning(expect_true(is.na(rzib(1, -1, 0.5, 0.5)))) expect_warning(expect_true(is.na(rzib(1, 1, -1, 0.5)))) expect_warning(expect_true(is.na(rzib(1, 1, 0.5, 2)))) expect_warning(expect_true(is.na(rzib(1, 1, -1, 0.5)))) expect_warning(expect_true(is.na(rzib(1, 1, 0.5, 2)))) expect_warning(expect_true(is.na(rzinb(1, -1, 0.5, 0.5)))) expect_warning(expect_true(is.na(rzinb(1, 1, -1, 0.5)))) expect_warning(expect_true(is.na(rzinb(1, 1, 0.5, 2)))) expect_warning(expect_true(is.na(rzinb(1, 1, -1, 0.5)))) expect_warning(expect_true(is.na(rzinb(1, 1, 0.5, 2)))) })extraDistr/tests/testthat/test-misc.R0000755000176200001440000000256314475546572017474 0ustar liggesusers test_that("other tests", { expect_true(all(rsign(1e5) %in% c(-1, 1))) expect_silent(qcat(seq(0, 1, by = 0.1), c(1, 1, 1), labels = letters[1:3])) expect_warning(qcat(seq(0, 1, by = 0.1), c(1, 1, 1), labels = letters[1:2])) expect_silent(rcat(10, c(1, 1, 1), labels = letters[1:3])) expect_warning(rcat(10, c(1, 1, 1), labels = letters[1:2])) expect_silent(rcatlp(10, log(c(1, 1, 1)/3), labels = letters[1:3])) expect_warning(rcatlp(10, log(c(1, 1, 1)/3), labels = letters[1:2])) expect_error(dbvpois(1:10, a = 1, b = 1, c= 1)) expect_silent(!anyNA(rtlambda(5000, -1))) expect_silent(!anyNA(rtlambda(5000, 0))) expect_silent(!anyNA(rtlambda(5000, 1))) expect_silent(dbvnorm(mtcars[, 1:2])) expect_error(dbvnorm(mtcars)) xx <- seq(-6, 6, by = 0.01) expect_identical(dnorm(xx), dtnorm(xx)) expect_identical(pnorm(xx), ptnorm(xx)) pp <- seq(0, 1, by = 0.01) expect_identical(qnorm(pp), qtnorm(pp)) x <- c(-Inf, -100, -10, -5, -1, -0.5, 0, 0.5, 1, 5, 10, 100, Inf) expect_equal(pmixnorm(x, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3), lower.tail = TRUE), 1 - pmixnorm(x, c(1,2,3), c(1,2,3), c(1/3,1/3,1/3), lower.tail = FALSE)) expect_equal(suppressWarnings(pmixpois(x, c(1,2,3), c(1/3,1/3,1/3), lower.tail = TRUE)), 1 - suppressWarnings(pmixpois(x, c(1,2,3), c(1/3,1/3,1/3), lower.tail = FALSE))) }) extraDistr/tests/testthat.R0000755000176200001440000000021014475546572015547 0ustar liggesuserslibrary(testthat) library(extraDistr) # use fixed random seed for all tests for reproducibility set.seed(42) test_check("extraDistr") extraDistr/src/0000755000176200001440000000000014532046260013174 5ustar liggesusersextraDistr/src/beta-prime-distribution.cpp0000755000176200001440000001264714475546572020500 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using std::log1p; /* * Beta prime distribution * * Values: * x > 0 * * Parameters: * alpha > 0 * beta > 0 * sigma > 0 * */ inline double logpdf_betapr(double x, double alpha, double beta, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(alpha) || ISNAN(beta) || ISNAN(sigma)) return x+alpha+beta+sigma; #endif if (alpha <= 0.0 || beta <= 0.0 || sigma <= 0.0) { throw_warning = true; return NAN; } if (x <= 0.0 || !R_FINITE(x)) return R_NegInf; double z = x / sigma; // pow(z, alpha-1.0) * pow(z+1.0, -alpha-beta) / R::beta(alpha, beta) / sigma; return log(z) * (alpha-1.0) + log1p(z) * (-alpha-beta) - R::lbeta(alpha, beta) - log(sigma); } inline double cdf_betapr(double x, double alpha, double beta, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(alpha) || ISNAN(beta) || ISNAN(sigma)) return x+alpha+beta+sigma; #endif if (alpha <= 0.0 || beta <= 0.0 || sigma <= 0.0) { throw_warning = true; return NAN; } if (x <= 0.0) return 0.0; if (!R_FINITE(x)) return 1.0; double z = x / sigma; return R::pbeta(z/(1.0+z), alpha, beta, true, false); } inline double invcdf_betapr(double p, double alpha, double beta, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(alpha) || ISNAN(beta) || ISNAN(sigma)) return p+alpha+beta+sigma; #endif if (alpha <= 0.0 || beta <= 0.0 || sigma <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } if (p == 0.0) return 0.0; if (p == 1.0) return R_PosInf; double x = R::qbeta(p, alpha, beta, true, false); return x/(1.0-x) * sigma; } inline double rng_betapr(double alpha, double beta, double sigma, bool& throw_warning) { if (ISNAN(alpha) || ISNAN(beta) || ISNAN(sigma) || alpha <= 0.0 || beta <= 0.0 || sigma <= 0.0) { throw_warning = true; return NA_REAL; } double x = R::rbeta(alpha, beta); return x/(1.0-x) * sigma; } // [[Rcpp::export]] NumericVector cpp_dbetapr( const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& sigma, const bool& log_prob = false ) { if (std::min({x.length(), alpha.length(), beta.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), alpha.length(), beta.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_betapr(GETV(x, i), GETV(alpha, i), GETV(beta, i), GETV(sigma, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pbetapr( const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), alpha.length(), beta.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), alpha.length(), beta.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_betapr(GETV(x, i), GETV(alpha, i), GETV(beta, i), GETV(sigma, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qbetapr( const NumericVector& p, const NumericVector& alpha, const NumericVector& beta, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), alpha.length(), beta.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), alpha.length(), beta.length(), sigma.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_betapr(GETV(pp, i), GETV(alpha, i), GETV(beta, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rbetapr( const int& n, const NumericVector& alpha, const NumericVector& beta, const NumericVector& sigma ) { if (std::min({alpha.length(), beta.length(), sigma.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_betapr(GETV(alpha, i), GETV(beta, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/skellam-distribution.cpp0000755000176200001440000000420714475546572020074 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Skellam distribution * * mu1 >= 0 * mu2 >= 0 * */ inline double pmf_skellam(double x, double mu1, double mu2, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu1) || ISNAN(mu2)) return x+mu1+mu2; #endif if (mu1 < 0.0 || mu2 < 0.0) { throw_warning = true; return NAN; } if (!isInteger(x) || !R_FINITE(x)) return 0.0; return exp(-(mu1+mu2)) * pow(mu1/mu2, x/2.0) * R::bessel_i(2.0*sqrt(mu1*mu2), x, 1.0); } inline double rng_skellam(double mu1, double mu2, bool& throw_warning) { if (ISNAN(mu1) || ISNAN(mu2) || mu1 < 0.0 || mu2 < 0.0) { throw_warning = true; return NA_REAL; } return R::rpois(mu1) - R::rpois(mu2); } // [[Rcpp::export]] NumericVector cpp_dskellam( const NumericVector& x, const NumericVector& mu1, const NumericVector& mu2, const bool& log_prob = false ) { if (std::min({x.length(), mu1.length(), mu2.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu1.length(), mu2.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pmf_skellam(GETV(x, i), GETV(mu1, i), GETV(mu2, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_rskellam( const int& n, const NumericVector& mu1, const NumericVector& mu2 ) { if (std::min({mu1.length(), mu2.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_skellam(GETV(mu1, i), GETV(mu2, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/discrete-weibull-distribution.cpp0000755000176200001440000001132714475546572021710 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Discrete Weibull distribution * * Values: * x >= 0 * * Parameters: * 0 < q < 1 * beta * * f(x) = q^x^beta - q^(x+1)^beta * F(x) = 1-q^(x+1)^beta * F^-1(p) = ceiling(pow(log(1-p)/log(q), 1/beta) - 1) * * Nakagawa and Osaki (1975), "The Discrete Weibull Distribution", * IEEE Transactions on Reliability, R-24, pp. 300-301. * */ inline double pdf_dweibull(double x, double q, double beta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(q) || ISNAN(beta)) return x+q+beta; #endif if (q <= 0.0 || q >= 1.0 || beta <= 0.0) { throw_warning = true; return NAN; } if (!isInteger(x) || x < 0.0) return 0.0; return pow(q, pow(x, beta)) - pow(q, pow(x+1.0, beta)); } inline double cdf_dweibull(double x, double q, double beta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(q) || ISNAN(beta)) return x+q+beta; #endif if (q <= 0.0 || q >= 1.0 || beta <= 0.0) { throw_warning = true; return NAN; } if (x < 0.0) return 0.0; // 1.0 - pow(q, pow(x+1.0, beta)) return 1.0 - exp(log(q) * exp(log1p(x) * beta)); } inline double invcdf_dweibull(double p, double q, double beta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(q) || ISNAN(beta)) return p+q+beta; #endif if (q <= 0.0 || q >= 1.0 || beta <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } if (p == 0.0) return 0.0; return ceil(pow(log(1.0 - p)/log(q), 1.0/beta) - 1.0); } inline double rng_dweibull(double q, double beta, bool& throw_warning) { if (ISNAN(q) || ISNAN(beta) || q <= 0.0 || q >= 1.0 || beta <= 0.0) { throw_warning = true; return NA_REAL; } double u = rng_unif(); return ceil(pow(log(u)/log(q), 1.0/beta) - 1.0); } // [[Rcpp::export]] NumericVector cpp_ddweibull( const NumericVector& x, const NumericVector& q, const NumericVector& beta, const bool& log_prob = false ) { if (std::min({x.length(), q.length(), beta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), q.length(), beta.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pdf_dweibull(GETV(x, i), GETV(q, i), GETV(beta, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pdweibull( const NumericVector& x, const NumericVector& q, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), q.length(), beta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), q.length(), beta.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_dweibull(GETV(x, i), GETV(q, i), GETV(beta, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qdweibull( const NumericVector& p, const NumericVector& q, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), q.length(), beta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), q.length(), beta.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) x[i] = invcdf_dweibull(GETV(pp, i), GETV(q, i), GETV(beta, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rdweibull( const int& n, const NumericVector& q, const NumericVector& beta ) { if (std::min({q.length(), beta.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_dweibull(GETV(q, i), GETV(beta, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/half-normal-distribution.cpp0000755000176200001440000000733514475546572020651 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; inline double logpdf_hnorm(double x, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(sigma)) return x+sigma; #endif if (sigma <= 0.0) { throw_warning = true; return NAN; } if (x < 0.0) return R_NegInf; return LOG_2F + R::dnorm(x, 0.0, sigma, true); } inline double cdf_hnorm(double x, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(sigma)) return x+sigma; #endif if (sigma <= 0.0) { throw_warning = true; return NAN; } if (x < 0.0) return 0.0; return 2.0 * R::pnorm(x, 0.0, sigma, true, false) - 1.0; } inline double invcdf_hnorm(double p, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(sigma)) return p+sigma; #endif if (sigma <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } return R::qnorm((p+1.0)/2.0, 0.0, sigma, true, false); } inline double rng_hnorm(double sigma, bool& throw_warning) { if (ISNAN(sigma) || sigma <= 0.0) { throw_warning = true; return NA_REAL; } return abs(R::norm_rand()) * sigma; } // [[Rcpp::export]] NumericVector cpp_dhnorm( const NumericVector& x, const NumericVector& sigma, const bool& log_prob = false ) { if (std::min({x.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_hnorm(GETV(x, i), GETV(sigma, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_phnorm( const NumericVector& x, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_hnorm(GETV(x, i), GETV(sigma, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qhnorm( const NumericVector& p, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), sigma.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_hnorm(GETV(pp, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rhnorm( const int& n, const NumericVector& sigma ) { if (sigma.length() < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_hnorm(GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/laplace-distribution.cpp0000755000176200001440000001147114475546572020046 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Laplace distribution * * Values: * x * * Parameters: * mu * sigma > 0 * * z = (x-mu)/sigma * f(x) = 1/(2*sigma) * exp(-|z|) * F(x) = { 1/2 * exp(z) if x < mu * { 1 - 1/2 * exp(z) otherwise * F^-1(p) = { mu + sigma * log(2*p) if p <= 0.5 * { mu - sigma * log(2*(1-p)) otherwise * */ inline double logpdf_laplace(double x, double mu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma)) return x+mu+sigma; #endif if (sigma <= 0.0) { throw_warning = true; return NAN; } double z = abs(x-mu)/sigma; // exp(-z)/(2.0*sigma); return -z - LOG_2F - log(sigma); } inline double cdf_laplace(double x, double mu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma)) return x+mu+sigma; #endif if (sigma <= 0.0) { throw_warning = true; return NAN; } double z = (x-mu)/sigma; if (x < mu) return exp(z - LOG_2F); // exp(z)/2.0 else return 1.0 - exp(-z - LOG_2F); // 1.0 - exp(-z)/2.0 } inline double invcdf_laplace(double p, double mu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(mu) || ISNAN(sigma)) return p+mu+sigma; #endif if (sigma <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } if (p < 0.5) return mu + sigma * log(2.0*p); else return mu - sigma * log(2.0*(1.0-p)); } inline double rng_laplace(double mu, double sigma, bool& throw_warning) { if (ISNAN(mu) || ISNAN(sigma) || sigma <= 0.0) { throw_warning = true; return NA_REAL; } // this is slower // double u = R::runif(-0.5, 0.5); // return mu + sigma * R::sign(u) * log(1.0 - 2.0*abs(u)); double u = R::exp_rand(); double s = rng_sign(); return u*s * sigma + mu; } // [[Rcpp::export]] NumericVector cpp_dlaplace( const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_laplace(GETV(x, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_plaplace( const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_laplace(GETV(x, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qlaplace( const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), mu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), mu.length(), sigma.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_laplace(GETV(pp, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rlaplace( const int& n, const NumericVector& mu, const NumericVector& sigma ) { if (std::min({mu.length(), sigma.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_laplace(GETV(mu, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/mixture-of-poisson-distributions.cpp0000755000176200001440000001433314475546572022417 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using Rcpp::NumericMatrix; // [[Rcpp::export]] NumericVector cpp_dmixpois( const NumericVector& x, const NumericMatrix& lambda, const NumericMatrix& alpha, const bool& log_prob = false ) { if (std::min({static_cast(x.length()), static_cast(lambda.nrow()), static_cast(lambda.ncol()), static_cast(alpha.nrow()), static_cast(alpha.ncol())}) < 1) { return NumericVector(0); } int Nmax = std::max({ static_cast(x.length()), static_cast(lambda.nrow()), static_cast(alpha.nrow()) }); int k = alpha.ncol(); NumericVector p(Nmax); bool throw_warning = false; if (k != lambda.ncol()) Rcpp::stop("sizes of lambda and alpha do not match"); bool wrong_param; double alpha_tot, nans_sum; for (int i = 0; i < Nmax; i++) { wrong_param = false; alpha_tot = 0.0; nans_sum = 0.0; p[i] = 0.0; for (int j = 0; j < k; j++) { if (GETM(alpha, i, j) < 0.0 || GETM(lambda, i, j) < 0.0) { wrong_param = true; break; } nans_sum += GETM(lambda, i, j); alpha_tot += GETM(alpha, i, j); } #ifdef IEEE_754 if (ISNAN(nans_sum + alpha_tot + GETV(x, i))) { p[i] = nans_sum + alpha_tot + GETV(x, i); continue; } #endif if (wrong_param) { throw_warning = true; p[i] = NAN; continue; } if (GETV(x, i) < 0.0 || !isInteger(GETV(x, i))) { p[i] = R_NegInf; continue; } if (!R_finite(GETV(x, i))) { p[i] = R_NegInf; continue; } double mx = R_NegInf; std::vector tmp(k); for (int j = 0; j < k; j++) { // p[i] += (GETM(alpha, i, j) / alpha_tot) * // R::dpois(GETV(x, i), GETM(lambda, i, j), false); tmp[j] = log(GETM(alpha, i, j)) - log(alpha_tot) + R::dpois(GETV(x, i), GETM(lambda, i, j), true); if (tmp[j] > mx) mx = tmp[j]; } for (int j = 0; j < k; j++) p[i] += exp(tmp[j] - mx); // log-sum-exp trick p[i] = log(p[i]) + mx; } if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pmixpois( const NumericVector& x, const NumericMatrix& lambda, const NumericMatrix& alpha, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({static_cast(x.length()), static_cast(lambda.nrow()), static_cast(lambda.ncol()), static_cast(alpha.nrow()), static_cast(alpha.ncol())}) < 1) { return NumericVector(0); } int Nmax = std::max({ static_cast(x.length()), static_cast(lambda.nrow()), static_cast(alpha.nrow()) }); int k = alpha.ncol(); NumericVector p(Nmax); bool throw_warning = false; if (k != lambda.ncol()) Rcpp::stop("sizes of lambda and alpha do not match"); bool wrong_param; double alpha_tot, nans_sum; for (int i = 0; i < Nmax; i++) { wrong_param = false; alpha_tot = 0.0; nans_sum = 0.0; p[i] = 0.0; for (int j = 0; j < k; j++) { if (GETM(alpha, i, j) < 0.0 || GETM(lambda, i, j) < 0.0) { wrong_param = true; break; } nans_sum += GETM(lambda, i, j); alpha_tot += GETM(alpha, i, j); } #ifdef IEEE_754 if (ISNAN(nans_sum + alpha_tot + GETV(x, i))) { p[i] = nans_sum + alpha_tot + GETV(x, i); continue; } #endif if (wrong_param) { throw_warning = true; p[i] = NAN; continue; } if (GETV(x, i) < 0.0) { p[i] = lower_tail ? R_NegInf : 0.0; // here continue; } if (GETV(x, i) == R_PosInf) { p[i] = !lower_tail ? R_NegInf : 0.0; continue; } double mx = R_NegInf; std::vector tmp(k); for (int j = 0; j < k; j++) { // p[i] += (GETM(alpha, i, j) / alpha_tot) * // R::ppois(GETV(x, i), GETM(lambda, i, j), true, false); tmp[j] = log(GETM(alpha, i, j)) - log(alpha_tot) + R::ppois(GETV(x, i), GETM(lambda, i, j), lower_tail, true); if (tmp[j] > mx) mx = tmp[j]; } for (int j = 0; j < k; j++) p[i] += exp(tmp[j] - mx); // log-sum-exp trick p[i] = log(p[i]) + mx; } // if (!lower_tail) // p = 1.0 - p; if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_rmixpois( const int& n, const NumericMatrix& lambda, const NumericMatrix& alpha ) { if (std::min({static_cast(lambda.nrow()), static_cast(lambda.ncol()), static_cast(alpha.nrow()), static_cast(alpha.ncol())}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } int k = alpha.ncol(); NumericVector x(n); bool throw_warning = false; if (k != lambda.ncol()) Rcpp::stop("sizes of lambda and alpha do not match"); int jj; bool wrong_param; double u, p_tmp, alpha_tot, nans_sum; NumericVector prob(k); for (int i = 0; i < n; i++) { jj = 0; wrong_param = false; u = rng_unif(); p_tmp = 1.0; alpha_tot = 0.0; nans_sum = 0.0; for (int j = 0; j < k; j++) { if (GETM(alpha, i, j) < 0.0 || GETM(lambda, i, j) < 0.0) { wrong_param = true; break; } nans_sum += GETM(lambda, i, j); alpha_tot += GETM(alpha, i, j); } if (ISNAN(nans_sum + alpha_tot) || wrong_param) { throw_warning = true; x[i] = NA_REAL; continue; } for (int j = k-1; j >= 0; j--) { p_tmp -= GETM(alpha, i, j) / alpha_tot; if (u > p_tmp) { jj = j; break; } } x[i] = R::rpois(GETM(lambda, i, jj)); } if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/location-scale-t-distribution.cpp0000755000176200001440000001132414475546572021600 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Non-standard t-distribution * * Values: * x * * Parameters: * nu > 0 * mu * sigma > 0 * */ inline double pdf_lst(double x, double nu, double mu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(nu) || ISNAN(mu) || ISNAN(sigma)) return x+nu+mu+sigma; #endif if (nu <= 0.0 || sigma <= 0.0) { throw_warning = true; return NAN; } double z = (x - mu)/sigma; return R::dt(z, nu, false)/sigma; } inline double cdf_lst(double x, double nu, double mu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(nu) || ISNAN(mu) || ISNAN(sigma)) return x+nu+mu+sigma; #endif if (nu <= 0.0 || sigma <= 0.0) { throw_warning = true; return NAN; } double z = (x - mu)/sigma; return R::pt(z, nu, true, false); } inline double invcdf_lst(double p, double nu, double mu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(nu) || ISNAN(mu) || ISNAN(sigma)) return p+nu+mu+sigma; #endif if (nu <= 0.0 || sigma <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } return R::qt(p, nu, true, false)*sigma + mu; } inline double rng_lst(double nu, double mu, double sigma, bool& throw_warning) { if (ISNAN(nu) || ISNAN(mu) || ISNAN(sigma) || nu <= 0.0 || sigma <= 0.0) { throw_warning = true; return NA_REAL; } return R::rt(nu)*sigma + mu; } // [[Rcpp::export]] NumericVector cpp_dlst( const NumericVector& x, const NumericVector& nu, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob = false ) { if (std::min({x.length(), nu.length(), mu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), nu.length(), mu.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pdf_lst(GETV(x, i), GETV(nu, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_plst( const NumericVector& x, const NumericVector& nu, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), nu.length(), mu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), nu.length(), mu.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_lst(GETV(x, i), GETV(nu, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qlst( const NumericVector& p, const NumericVector& nu, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), nu.length(), mu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), nu.length(), mu.length(), sigma.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) x[i] = invcdf_lst(GETV(pp, i), GETV(nu, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rlst( const int& n, const NumericVector& nu, const NumericVector& mu, const NumericVector& sigma ) { if (std::min({nu.length(), mu.length(), sigma.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_lst(GETV(nu, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/half-cauchy-distribution.cpp0000755000176200001440000000752014475546572020631 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using std::tan; using std::atan; inline double logpdf_hcauchy(double x, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(sigma)) return x+sigma; #endif if (sigma <= 0.0) { throw_warning = true; return NAN; } if (x < 0.0) return R_NegInf; // 2.0/(M_PI*(1.0 + pow(x/sigma, 2.0)))/sigma; return LOG_2F - log(M_PI) - log1p(exp( (log(x)-log(sigma)) * 2.0 )) - log(sigma); } inline double cdf_hcauchy(double x, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(sigma)) return x+sigma; #endif if (sigma <= 0.0) { throw_warning = true; return NAN; } if (x < 0.0) return 0.0; return 2.0/M_PI * atan(x/sigma); } inline double invcdf_hcauchy(double p, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(sigma)) return p+sigma; #endif if (sigma <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } return sigma * tan((M_PI*p)/2.0); } inline double rng_hcauchy(double sigma, bool& throw_warning) { if (ISNAN(sigma) || sigma <= 0.0) { throw_warning = true; return NA_REAL; } return abs(R::rcauchy(0.0, sigma)); } // [[Rcpp::export]] NumericVector cpp_dhcauchy( const NumericVector& x, const NumericVector& sigma, const bool& log_prob = false ) { if (std::min({x.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_hcauchy(GETV(x, i), GETV(sigma, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_phcauchy( const NumericVector& x, const NumericVector& sigma, bool lower_tail = true, bool log_prob = false ) { if (std::min({x.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_hcauchy(GETV(x, i), GETV(sigma, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qhcauchy( const NumericVector& p, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), sigma.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_hcauchy(GETV(pp, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rhcauchy( const int& n, const NumericVector& sigma ) { if (sigma.length() < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_hcauchy(GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/discrete-laplace-distribution.cpp0000755000176200001440000000667514475546572021660 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using std::log1p; inline double logpmf_dlaplace(double x, double p, double mu, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(p) || ISNAN(mu)) return x+p+mu; #endif if (p <= 0.0 || p >= 1.0) { throw_warning = true; return NAN; } if (!isInteger(x)) return R_NegInf; // (1.0-p)/(1.0+p) * pow(p, abs(x-mu)); return log1p(-p) - log1p(p) + log(p) * abs(x-mu); } inline double cdf_dlaplace(double x, double p, double mu, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(p) || ISNAN(mu)) return x+p+mu; #endif if (p <= 0.0 || p >= 1.0) { throw_warning = true; return NAN; } if (x < 0.0) { // pow(p, -floor(x-mu))/(1.0+p); return exp( (log(p) * -floor(x-mu)) - log1p(p) ); } else { // 1.0 - (pow(p, floor(x-mu)+1.0)/(1.0+p)) return 1.0 - exp( log(p) * (floor(x-mu)+1.0) - log1p(p) ); } } inline double rng_dlaplace(double p, double mu, bool& throw_warning) { if (ISNAN(p) || ISNAN(mu) || p <= 0.0 || p >= 1.0) { throw_warning = true; return NA_REAL; } double q, u, v; q = 1.0 - p; u = R::rgeom(q); v = R::rgeom(q); return u-v + mu; } // [[Rcpp::export]] NumericVector cpp_ddlaplace( const NumericVector& x, const NumericVector& location, const NumericVector& scale, const bool& log_prob = false ) { if (std::min({x.length(), location.length(), scale.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), scale.length(), location.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpmf_dlaplace(GETV(x, i), GETV(scale, i), GETV(location, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pdlaplace( const NumericVector& x, const NumericVector& location, const NumericVector& scale, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), location.length(), scale.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), scale.length(), location.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_dlaplace(GETV(x, i), GETV(scale, i), GETV(location, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_rdlaplace( const int& n, const NumericVector& location, const NumericVector& scale ) { if (std::min({location.length(), scale.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_dlaplace(GETV(scale, i), GETV(location, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/gumbel-distribution.cpp0000755000176200001440000001070114475546572017713 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Gumbel distribution * * Values: * x * * Parameters: * mu * sigma > 0 * * z = (x-mu)/sigma * f(x) = 1/sigma * exp(-(z+exp(-z))) * F(x) = exp(-exp(-z)) * F^-1(p) = mu - sigma * log(-log(p)) * */ inline double logpdf_gumbel(double x, double mu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma)) return x+mu+sigma; #endif if (sigma <= 0.0) { throw_warning = true; return NAN; } if (!R_FINITE(x)) return R_NegInf; double z = (x-mu)/sigma; // exp(-(z+exp(-z)))/sigma; return -(z+exp(-z)) - log(sigma); } inline double cdf_gumbel(double x, double mu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma)) return x+mu+sigma; #endif if (sigma <= 0.0) { throw_warning = true; return NAN; } double z = (x-mu)/sigma; return exp(-exp(-z)); } inline double invcdf_gumbel(double p, double mu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(mu) || ISNAN(sigma)) return p+mu+sigma; #endif if (sigma <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } return mu - sigma * log(-log(p)); } inline double rng_gumbel(double mu, double sigma, bool& throw_warning) { if (ISNAN(mu) || ISNAN(sigma) || sigma <= 0.0) { throw_warning = true; return NA_REAL; } double u = R::exp_rand(); // -log(rng_unif()) return mu - sigma * log(u); } // [[Rcpp::export]] NumericVector cpp_dgumbel( const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_gumbel(GETV(x, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pgumbel( const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_gumbel(GETV(x, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qgumbel( const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), mu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), mu.length(), sigma.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_gumbel(GETV(pp, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rgumbel( const int& n, const NumericVector& mu, const NumericVector& sigma ) { if (std::min({mu.length(), sigma.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_gumbel(GETV(mu, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/gamma-poisson-distribution.cpp0000755000176200001440000001156514475546572021223 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Gamma-Poisson distribution * * Values: * x >= 0 * * Parameters: * alpha > 0 * beta > 0 * */ inline double logpmf_gpois(double x, double alpha, double beta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(alpha) || ISNAN(beta)) return x+alpha+beta; #endif if (alpha <= 0.0 || beta <= 0.0) { throw_warning = true; return NAN; } if (!isInteger(x) || x < 0.0 || !R_FINITE(x)) return R_NegInf; // p = beta/(1.0+beta); double p = exp( log(beta) - log1p(beta) ); return R::lgammafn(alpha+x) - lfactorial(x) - R::lgammafn(alpha) + log(p)*x + log(1.0-p)*alpha; } inline std::vector cdf_gpois_table(double x, double alpha, double beta) { if (x < 0.0 || !R_FINITE(x) || alpha < 0.0 || beta < 0.0) Rcpp::stop("inadmissible values"); int ix = to_pos_int(x); std::vector p_tab(ix+1); double p, qa, ga, gax, xf, px, lp; p = beta/(1.0+beta); qa = log(pow(1.0 - p, alpha)); ga = R::lgammafn(alpha); lp = log(p); // x = 0 gax = ga; xf = 0.0; px = 0.0; p_tab[0] = exp(qa); if (ix < 1) return p_tab; // x < 2 gax += log(alpha); px += lp; p_tab[1] = p_tab[0] + exp(gax - ga + px + qa); if (ix < 2) return p_tab; // x >= 2 double dj; for (int j = 2; j <= ix; j++) { if (j % 10000 == 0) Rcpp::checkUserInterrupt(); dj = to_dbl(j); gax += log(dj + alpha - 1.0); xf += log(dj); px += lp; p_tab[j] = p_tab[j-1] + exp(gax - (xf + ga) + px + qa); } return p_tab; } inline double rng_gpois(double alpha, double beta, bool& throw_warning) { if (ISNAN(alpha) || ISNAN(beta) || alpha <= 0.0 || beta <= 0.0) { throw_warning = true; return NA_REAL; } double lambda = R::rgamma(alpha, beta); return R::rpois(lambda); } // [[Rcpp::export]] NumericVector cpp_dgpois( const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& log_prob = false ) { if (std::min({x.length(), alpha.length(), beta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), alpha.length(), beta.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpmf_gpois(GETV(x, i), GETV(alpha, i), GETV(beta, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pgpois( const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), alpha.length(), beta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), alpha.length(), beta.length() }); NumericVector p(Nmax); bool throw_warning = false; std::map, std::vector> memo; double mx = finite_max_int(x); for (int i = 0; i < Nmax; i++) { if (i % 100 == 0) Rcpp::checkUserInterrupt(); #ifdef IEEE_754 if (ISNAN(GETV(x, i)) || ISNAN(GETV(alpha, i)) || ISNAN(GETV(beta, i))) { p[i] = GETV(x, i) + GETV(alpha, i) + GETV(beta, i); continue; } #endif if (GETV(alpha, i) <= 0.0 || GETV(beta, i) <= 0.0) { throw_warning = true; p[i] = NAN; } else if (GETV(x, i) < 0.0) { p[i] = 0.0; } else if (GETV(x, i) == R_PosInf) { p[i] = 1.0; } else if (is_large_int(GETV(x, i))) { p[i] = NA_REAL; Rcpp::warning("NAs introduced by coercion to integer range"); } else { std::vector& tmp = memo[std::make_tuple( static_cast(i % alpha.length()), static_cast(i % beta.length()) )]; if (!tmp.size()) { tmp = cdf_gpois_table(mx, GETV(alpha, i), GETV(beta, i)); } p[i] = tmp[to_pos_int(GETV(x, i))]; } } if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_rgpois( const int& n, const NumericVector& alpha, const NumericVector& beta ) { if (std::min({alpha.length(), beta.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_gpois(GETV(alpha, i), GETV(beta, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/lomax-distribution.cpp0000755000176200001440000001124414475546572017563 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using std::log1p; /* * Lomax distribution * * Values: * x > 0 * * Parameters: * lambda > 0 * kappa > 0 * * f(x) = lambda*kappa / (1+lambda*x)^(kappa+1) * F(x) = 1-(1+lambda*x)^-kappa * F^-1(p) = ((1-p)^(-1/kappa)-1) / lambda * */ inline double logpdf_lomax(double x, double lambda, double kappa, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(lambda) || ISNAN(kappa)) return x+lambda+kappa; #endif if (lambda <= 0.0 || kappa <= 0.0) { throw_warning = true; return NAN; } if (x <= 0.0) return R_NegInf; // lambda*kappa / pow(1.0+lambda*x, kappa+1.0); return log(lambda) + log(kappa) - log1p(lambda*x)*(kappa+1.0); } inline double cdf_lomax(double x, double lambda, double kappa, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(lambda) || ISNAN(kappa)) return x+lambda+kappa; #endif if (lambda <= 0.0 || kappa <= 0.0) { throw_warning = true; return NAN; } if (x <= 0.0) return 0.0; // 1.0 - pow(1.0+lambda*x, -kappa); return 1.0 - exp(log1p(lambda*x) * (-kappa)); } inline double invcdf_lomax(double p, double lambda, double kappa, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(lambda) || ISNAN(kappa)) return p+lambda+kappa; #endif if (lambda <= 0.0 || kappa <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } return (pow(1.0-p, -1.0/kappa)-1.0) / lambda; } inline double rng_lomax(double lambda, double kappa, bool& throw_warning) { if (ISNAN(lambda) || ISNAN(kappa) || lambda <= 0.0 || kappa <= 0.0) { throw_warning = true; return NA_REAL; } double u = rng_unif(); return (pow(u, -1.0/kappa)-1.0) / lambda; } // [[Rcpp::export]] NumericVector cpp_dlomax( const NumericVector& x, const NumericVector& lambda, const NumericVector& kappa, const bool& log_prob = false ) { if (std::min({x.length(), lambda.length(), kappa.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), lambda.length(), kappa.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_lomax(GETV(x, i), GETV(lambda, i), GETV(kappa, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_plomax( const NumericVector& x, const NumericVector& lambda, const NumericVector& kappa, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), lambda.length(), kappa.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), lambda.length(), kappa.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_lomax(GETV(x, i), GETV(lambda, i), GETV(kappa, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qlomax( const NumericVector& p, const NumericVector& lambda, const NumericVector& kappa, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), lambda.length(), kappa.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), lambda.length(), kappa.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) x[i] = invcdf_lomax(GETV(pp, i), GETV(lambda, i), GETV(kappa, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rlomax( const int& n, const NumericVector& lambda, const NumericVector& kappa ) { if (std::min({lambda.length(), kappa.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_lomax(GETV(lambda, i), GETV(kappa, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/bivariate-poisson-distribution.cpp0000755000176200001440000000650514475546572022105 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using Rcpp::NumericMatrix; inline double logpmf_bpois(double x, double y, double a, double b, double c, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(y) || ISNAN(a) || ISNAN(b) || ISNAN(c)) return x+y+a+b+c; #endif if (a < 0.0 || b < 0.0 || c < 0.0) { throw_warning = true; return NAN; } if (!isInteger(x) || x < 0.0 || !R_FINITE(x) || !R_FINITE(y) || !isInteger(y)) { return R_NegInf; } if (y < 0.0) return R_NegInf; // exp(-(a+b+c)) double tmp = -(a+b+c); // tmp *= (pow(a, x) / factorial(x)) * (pow(b, y) / factorial(y)); tmp += (log(a) * x - lfactorial(x)) + (log(b) * y - lfactorial(y)); double minxy = static_cast( (x < y) ? x : y ); // c_ab = c/(a*b) double lc_ab = log(c) - log(a) - log(b); double dk; double mx = R_NegInf; std::vector ls(minxy+1); for (int k = 0; k <= minxy; k++) { dk = static_cast(k); // xy += R::choose(x, k) * R::choose(y, k) * factorial(k) * pow(c_ab, k); ls[k] = R::lchoose(x, dk) + R::lchoose(y, dk) + lfactorial(dk) + lc_ab * dk; if (ls[k] > mx) mx = ls[k]; } double xy = 0.0; for (int k = 0; k <= minxy; k++) xy += exp(ls[k] - mx); // log-sum-exp trick xy = log(xy) + mx; return tmp + xy; } // [[Rcpp::export]] NumericVector cpp_dbpois( const NumericVector& x, const NumericVector& y, const NumericVector& a, const NumericVector& b, const NumericVector& c, const bool& log_prob = false ) { if (std::min({x.length(), y.length(), a.length(), b.length(), c.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), y.length(), a.length(), b.length(), c.length() }); NumericVector p(Nmax); bool throw_warning = false; if (x.length() != y.length()) Rcpp::stop("lengths of x and y differ"); for (int i = 0; i < Nmax; i++) p[i] = logpmf_bpois(GETV(x, i), GETV(y, i), GETV(a, i), GETV(b, i), GETV(c, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericMatrix cpp_rbpois( const int& n, const NumericVector& a, const NumericVector& b, const NumericVector& c ) { if (std::min({a.length(), b.length(), c.length()}) < 1) { Rcpp::warning("NAs produced"); NumericMatrix out(n, 2); std::fill(out.begin(), out.end(), NA_REAL); return out; } NumericMatrix x(n, 2); double u, v, w; bool throw_warning = false; for (int i = 0; i < n; i++) { if (ISNAN(GETV(a, i)) || ISNAN(GETV(b, i)) || ISNAN(GETV(c, i)) || GETV(a, i) < 0.0 || GETV(b, i) < 0.0 || GETV(c, i) < 0.0) { throw_warning = true; x(i, 0) = NA_REAL; x(i, 1) = NA_REAL; } else { u = R::rpois(GETV(a, i)); v = R::rpois(GETV(b, i)); w = R::rpois(GETV(c, i)); x(i, 0) = u+w; x(i, 1) = v+w; } } if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/proportion-distribution.cpp0000755000176200001440000001203614475546572020656 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Re-parametrized beta distribution * * Values: * x * * Parameters: * 0 <= mean <= 1 * size > 0 * prior >= 0 * */ inline double pdf_prop(double x, double size, double mean, double prior, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(size) || ISNAN(mean) || ISNAN(prior)) return x+size+mean+prior; #endif if (size <= 0.0 || mean <= 0.0 || mean >= 1.0 || prior < 0) { throw_warning = true; return NAN; } return R::dbeta(x, size*mean+prior, size*(1.0-mean)+prior, false); } inline double cdf_prop(double x, double size, double mean, double prior, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(size) || ISNAN(mean) || ISNAN(prior)) return x+size+mean+prior; #endif if (size <= 0.0 || mean <= 0.0 || mean >= 1.0 || prior < 0) { throw_warning = true; return NAN; } return R::pbeta(x, size*mean+prior, size*(1.0-mean)+prior, true, false); } inline double invcdf_prop(double p, double size, double mean, double prior, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(size) || ISNAN(mean) || ISNAN(prior)) return p+size+mean+prior; #endif if (size <= 0.0 || mean <= 0.0 || mean >= 1.0 || prior < 0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } return R::qbeta(p, size*mean+prior, size*(1.0-mean)+prior, true, false); } inline double rng_prop(double size, double mean, double prior, bool& throw_warning) { if (ISNAN(size) || ISNAN(mean) || ISNAN(prior) || size <= 0.0 || mean <= 0.0 || mean >= 1.0 || prior < 0) { throw_warning = true; return NA_REAL; } return R::rbeta(size*mean+prior, size*(1.0-mean)+prior); } // [[Rcpp::export]] NumericVector cpp_dprop( const NumericVector& x, const NumericVector& size, const NumericVector& mean, const NumericVector& prior, const bool& log_prob = false ) { if (std::min({x.length(), size.length(), mean.length(), prior.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), size.length(), mean.length(), prior.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pdf_prop(GETV(x, i), GETV(size, i), GETV(mean, i), GETV(prior, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pprop( const NumericVector& x, const NumericVector& size, const NumericVector& mean, const NumericVector& prior, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), size.length(), mean.length(), prior.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), size.length(), mean.length(), prior.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_prop(GETV(x, i), GETV(size, i), GETV(mean, i), GETV(prior, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qprop( const NumericVector& p, const NumericVector& size, const NumericVector& mean, const NumericVector& prior, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), size.length(), mean.length(), prior.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), size.length(), mean.length(), prior.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) x[i] = invcdf_prop(GETV(pp, i), GETV(size, i), GETV(mean, i), GETV(prior, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rprop( const int& n, const NumericVector& size, const NumericVector& mean, const NumericVector& prior ) { if (std::min({size.length(), mean.length(), prior.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_prop(GETV(size, i), GETV(mean, i), GETV(prior, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/non-standart-beta-distribution.cpp0000755000176200001440000001271214475546572021765 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Non-standard beta distribution * * Values: * x * * Parameters: * 0 <= beta <= 1 * alpha > 0 * lower < upper * */ double pdf_nsbeta(double x, double alpha, double beta, double l, double u, bool log_p, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(alpha) || ISNAN(beta) || ISNAN(l) || ISNAN(u)) return x+alpha+beta+l+u; #endif if (l >= u || alpha < 0.0 || beta < 0.0) { Rcpp::warning("NaNs produced"); return NAN; } double r = u-l; double p = R::dbeta((x-l)/r, alpha, beta, log_p); if (log_p) return p-log(r); else return p/r; } double cdf_nsbeta(double x, double alpha, double beta, double l, double u, bool lower_tail, bool log_p, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(alpha) || ISNAN(beta) || ISNAN(l) || ISNAN(u)) return x+alpha+beta+l+u; #endif if (l >= u || alpha < 0.0 || beta < 0.0) { Rcpp::warning("NaNs produced"); return NAN; } return R::pbeta((x-l)/(u-l), alpha, beta, lower_tail, log_p); } double invcdf_nsbeta(double p, double alpha, double beta, double l, double u, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(alpha) || ISNAN(beta) || ISNAN(l) || ISNAN(u)) return p+alpha+beta+l+u; #endif if (l >= u || alpha < 0.0 || beta < 0.0 || !VALID_PROB(p)) { Rcpp::warning("NaNs produced"); return NAN; } return R::qbeta(p, alpha, beta, true, false) * (u-l) + l; } double rng_nsbeta(double alpha, double beta, double l, double u, bool& throw_warning) { if (ISNAN(alpha) || ISNAN(beta) || ISNAN(l) || ISNAN(u) || l >= u || alpha < 0.0 || beta < 0.0) { Rcpp::warning("NAs produced"); return NA_REAL; } return R::rbeta(alpha, beta) * (u-l) + l; } // [[Rcpp::export]] NumericVector cpp_dnsbeta( const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& lower, const NumericVector& upper, const bool& log_prob = false ) { if (std::min({x.length(), alpha.length(), beta.length(), lower.length(), upper.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), alpha.length(), beta.length(), lower.length(), upper.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pdf_nsbeta(GETV(x, i), GETV(alpha, i), GETV(beta, i), GETV(lower, i), GETV(upper, i), log_prob, throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pnsbeta( const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), alpha.length(), beta.length(), lower.length(), upper.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), alpha.length(), beta.length(), lower.length(), upper.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_nsbeta(GETV(x, i), GETV(alpha, i), GETV(beta, i), GETV(lower, i), GETV(upper, i), lower_tail, log_prob, throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qnsbeta( const NumericVector& p, const NumericVector& alpha, const NumericVector& beta, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), alpha.length(), beta.length(), lower.length(), upper.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), alpha.length(), beta.length(), lower.length(), upper.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) x[i] = invcdf_nsbeta(GETV(pp, i), GETV(alpha, i), GETV(beta, i), GETV(lower, i), GETV(upper, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rnsbeta( const int& n, const NumericVector& alpha, const NumericVector& beta, const NumericVector& lower, const NumericVector& upper ) { if (std::min({alpha.length(), beta.length(), lower.length(), upper.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_nsbeta(GETV(alpha, i), GETV(beta, i), GETV(lower, i), GETV(upper, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/beta-binomial-distribution.cpp0000755000176200001440000001371314475546572021151 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Beta-binomial distribution * * Values: * x * * Parameters: * k > 0 * alpha > 0 * beta > 0 * * f(k) = choose(n, k) * (beta(k+alpha, n-k+beta)) / (beta(alpha, beta)) * */ inline double logpmf_bbinom(double k, double n, double alpha, double beta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(k) || ISNAN(n) || ISNAN(alpha) || ISNAN(beta)) return k+n+alpha+beta; #endif if (alpha < 0.0 || beta < 0.0 || n < 0.0 || !isInteger(n, false)) { throw_warning = true; return NAN; } if (!isInteger(k) || k < 0.0 || k > n) return R_NegInf; // R::choose(n, k) * R::beta(k+alpha, n-k+beta) / R::beta(alpha, beta); return R::lchoose(n, k) + R::lbeta(k+alpha, n-k+beta) - R::lbeta(alpha, beta); } inline std::vector cdf_bbinom_table(double k, double n, double alpha, double beta) { if (k < 0.0 || k > n || alpha < 0.0 || beta < 0.0) Rcpp::stop("inadmissible values"); int ik = to_pos_int(k); std::vector p_tab(ik+1); double nck, bab, gx, gy, gxy; bab = R::lbeta(alpha, beta); gxy = R::lgammafn(alpha + beta + n); // k = 0 nck = 0.0; gx = R::lgammafn(alpha); gy = R::lgammafn(beta + n); p_tab[0] = exp(nck + gx + gy - gxy - bab); if (ik < 1) return p_tab; // k < 2 nck += log(n); gx += log(alpha); gy -= log(n + beta - 1.0); p_tab[1] = p_tab[0] + exp(nck + gx + gy - gxy - bab); if (ik < 2) return p_tab; // k >= 1 double dj; for (int j = 2; j <= ik; j++) { if (j % 10000 == 0) Rcpp::checkUserInterrupt(); dj = to_dbl(j); nck += log((n + 1.0 - dj)/dj); gx += log(dj + alpha - 1.0); gy -= log(n + beta - dj); p_tab[j] = p_tab[j-1] + exp(nck + gx + gy - gxy - bab); } return p_tab; } inline double rng_bbinom(double n, double alpha, double beta, bool& throw_warning) { if (ISNAN(n) || ISNAN(alpha) || ISNAN(beta) || alpha < 0.0 || beta < 0.0 || n < 0.0 || !isInteger(n, false)) { throw_warning = true; return NA_REAL; } double prob = R::rbeta(alpha, beta); return R::rbinom(n, prob); } // [[Rcpp::export]] NumericVector cpp_dbbinom( const NumericVector& x, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta, const bool& log_prob = false ) { if (std::min({x.length(), size.length(), alpha.length(), beta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), size.length(), alpha.length(), beta.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpmf_bbinom(GETV(x, i), GETV(size, i), GETV(alpha, i), GETV(beta, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pbbinom( const NumericVector& x, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), size.length(), alpha.length(), beta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), size.length(), alpha.length(), beta.length() }); NumericVector p(Nmax); bool throw_warning = false; std::map, std::vector> memo; // maximum modulo size.length(), bounded in [0, size] int n = x.length(); int k = size.length(); NumericVector mx(k, 0.0); for (int i = 0; i < std::max(n, k); i++) { if (mx[i % k] < GETV(x, i)) { mx[i % k] = std::min(GETV(x, i), GETV(size, i)); } } for (int i = 0; i < Nmax; i++) { if (i % 100 == 0) Rcpp::checkUserInterrupt(); #ifdef IEEE_754 if (ISNAN(GETV(x, i)) || ISNAN(GETV(size, i)) || ISNAN(GETV(alpha, i)) || ISNAN(GETV(beta, i))) { p[i] = GETV(x, i) + GETV(size, i) + GETV(alpha, i) + GETV(beta, i); continue; } #endif if (GETV(alpha, i) <= 0.0 || GETV(beta, i) <= 0.0 || GETV(size, i) < 0.0 || !isInteger(GETV(size, i), false)) { throw_warning = true; p[i] = NAN; } else if (GETV(x, i) < 0.0) { p[i] = 0.0; } else if (GETV(x, i) >= GETV(size, i)) { p[i] = 1.0; } else if (is_large_int(GETV(x, i))) { p[i] = NA_REAL; Rcpp::warning("NAs introduced by coercion to integer range"); } else { std::vector& tmp = memo[std::make_tuple( static_cast(i % size.length()), static_cast(i % alpha.length()), static_cast(i % beta.length()) )]; if (!tmp.size()) { double mxi = std::min(mx[i % size.length()], GETV(size, i)); tmp = cdf_bbinom_table(mx[i % size.length()], GETV(size, i), GETV(alpha, i), GETV(beta, i)); } p[i] = tmp[to_pos_int(GETV(x, i))]; } } if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_rbbinom( const int& n, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta ) { if (std::min({size.length(), alpha.length(), beta.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_bbinom(GETV(size, i), GETV(alpha, i), GETV(beta, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/discrete-normal-distribution.cpp0000755000176200001440000000260414475546572021533 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Discrete normal distribution * * Values: * x * * Parameters * mu * sigma > 0 * */ inline double pmf_dnorm(double x, double mu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma)) return x+mu+sigma; #endif if (sigma <= 0.0) { throw_warning = true; return NAN; } if (!isInteger(x)) return 0.0; return R::pnorm(x+1.0, mu, sigma, true, false) - R::pnorm(x, mu, sigma, true, false); } // [[Rcpp::export]] NumericVector cpp_ddnorm( const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pmf_dnorm(GETV(x, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } extraDistr/src/birnbaum-saunders-distribution.cpp0000755000176200001440000001250014475546572022060 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Birnbaum-Saunders (Fatigue Life) Distribution * * Support: * x > mu * * Parameters: * mu * alpha > 0 * beta > 0 * * */ inline double logpdf_fatigue(double x, double alpha, double beta, double mu, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(alpha) || ISNAN(beta) || ISNAN(mu)) return x+alpha+beta+mu; #endif if (alpha <= 0.0 || beta <= 0.0) { throw_warning = true; return NAN; } if (x <= mu || !R_FINITE(x)) return R_NegInf; double z, zb, bz; z = x-mu; zb = sqrt(z/beta); bz = sqrt(beta/z); // (zb+bz)/(2.0*alpha*z) * phi((zb-bz)/alpha) return log(zb+bz) - LOG_2F - log(alpha) - log(z) + lphi((zb-bz)/alpha); } inline double cdf_fatigue(double x, double alpha, double beta, double mu, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(alpha) || ISNAN(beta) || ISNAN(mu)) return x+alpha+beta+mu; #endif if (alpha <= 0.0 || beta <= 0.0) { throw_warning = true; return NAN; } if (x <= mu) return 0.0; double z, zb, bz; z = x-mu; zb = sqrt(z/beta); bz = sqrt(beta/z); return Phi((zb-bz)/alpha); } inline double invcdf_fatigue(double p, double alpha, double beta, double mu, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(alpha) || ISNAN(beta) || ISNAN(mu)) return p+alpha+beta+mu; #endif if (alpha <= 0.0 || beta <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } if (p == 0.0) return mu; double Zp = InvPhi(p); return pow(alpha/2.0*Zp + sqrt(pow(alpha/2.0*Zp, 2.0) + 1.0), 2.0) * beta + mu; } inline double rng_fatigue(double alpha, double beta, double mu, bool& throw_warning) { if (ISNAN(alpha) || ISNAN(beta) || ISNAN(mu) || alpha <= 0.0 || beta <= 0.0) { throw_warning = true; return NA_REAL; } double z = R::norm_rand(); return pow(alpha/2.0*z + sqrt(pow(alpha/2.0*z, 2.0) + 1.0), 2.0) * beta + mu; } // [[Rcpp::export]] NumericVector cpp_dfatigue( const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& mu, const bool& log_prob = false ) { if (std::min({x.length(), alpha.length(), beta.length(), mu.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), alpha.length(), beta.length(), mu.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_fatigue(GETV(x, i), GETV(alpha, i), GETV(beta, i), GETV(mu, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pfatigue( const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& mu, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), alpha.length(), beta.length(), mu.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), alpha.length(), beta.length(), mu.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_fatigue(GETV(x, i), GETV(alpha, i), GETV(beta, i), GETV(mu, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qfatigue( const NumericVector& p, const NumericVector& alpha, const NumericVector& beta, const NumericVector& mu, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), alpha.length(), beta.length(), mu.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), alpha.length(), beta.length(), mu.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_fatigue(GETV(pp, i), GETV(alpha, i), GETV(beta, i), GETV(mu, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rfatigue( const int& n, const NumericVector& alpha, const NumericVector& beta, const NumericVector& mu ) { if (std::min({alpha.length(), beta.length(), mu.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_fatigue(GETV(alpha, i), GETV(beta, i), GETV(mu, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/categorical-distribution.cpp0000755000176200001440000001502314475546572020717 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using Rcpp::NumericMatrix; /* * Categorical distribution * * Values: * x * * Parameters: * 0 <= p <= 1 * sum(p) = 1 * */ // [[Rcpp::export]] NumericVector cpp_dcat( const NumericVector& x, const NumericMatrix& prob, const bool& log_prob = false ) { if (std::min({x.length(), prob.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ static_cast(x.length()), static_cast(prob.nrow()) }); int k = prob.ncol(); NumericVector p(Nmax); double p_tot; bool throw_warning = false; if (k < 2) Rcpp::stop("number of columns in prob is < 2"); NumericMatrix prob_tab = Rcpp::clone(prob); for (int i = 0; i < prob.nrow(); i++) { p_tot = 0.0; for (int j = 0; j < k; j++) { p_tot += prob_tab(i, j); #ifdef IEEE_754 if (ISNAN(p_tot)) break; #endif if (prob_tab(i, j) < 0.0) { p_tot = NAN; throw_warning = true; break; } } for (int j = 0; j < k; j++) prob_tab(i, j) /= p_tot; } for (int i = 0; i < Nmax; i++) { #ifdef IEEE_754 if (ISNAN(GETV(x, i))) { p[i] = GETV(x, i); continue; } #endif if (!isInteger(GETV(x, i)) || GETV(x, i) < 1.0 || GETV(x, i) > to_dbl(k)) { p[i] = 0.0; continue; } if (is_large_int(GETV(x, i))) { Rcpp::warning("NAs introduced by coercion to integer range"); p[i] = NA_REAL; } p[i] = GETM(prob_tab, i, to_pos_int(GETV(x, i)) - 1); } if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pcat( const NumericVector& x, const NumericMatrix& prob, bool lower_tail = true, bool log_prob = false ) { if (std::min({x.length(), prob.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ static_cast(x.length()), static_cast(prob.nrow()) }); int k = prob.ncol(); NumericVector p(Nmax); double p_tot; bool throw_warning = false; if (k < 2) Rcpp::stop("number of columns in prob is < 2"); NumericMatrix prob_tab = Rcpp::clone(prob); for (int i = 0; i < prob.nrow(); i++) { p_tot = 0.0; for (int j = 0; j < k; j++) { p_tot += prob_tab(i, j); #ifdef IEEE_754 if (ISNAN(p_tot)) break; #endif if (prob_tab(i, j) < 0.0) { p_tot = NAN; throw_warning = true; break; } } prob_tab(i, 0) /= p_tot; for (int j = 1; j < k; j++) { prob_tab(i, j) /= p_tot; prob_tab(i, j) += prob_tab(i, j-1); } } for (int i = 0; i < Nmax; i++) { #ifdef IEEE_754 if (ISNAN(GETV(x, i))) { p[i] = GETV(x, i); continue; } #endif if (GETV(x, i) < 1.0) { p[i] = 0.0; continue; } if (GETV(x, i) >= to_dbl(k)) { p[i] = 1.0; continue; } if (is_large_int(GETV(x, i))) { Rcpp::warning("NAs introduced by coercion to integer range"); p[i] = NA_REAL; } p[i] = GETM(prob_tab, i, to_pos_int(GETV(x, i)) - 1); } if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qcat( const NumericVector& p, const NumericMatrix& prob, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), prob.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ static_cast(p.length()), static_cast(prob.nrow()) }); int k = prob.ncol(); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); int jj; double p_tot; bool throw_warning = false; if (k < 2) Rcpp::stop("number of columns in prob is < 2"); if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; NumericMatrix prob_tab = Rcpp::clone(prob); for (int i = 0; i < prob.nrow(); i++) { p_tot = 0.0; for (int j = 0; j < k; j++) { p_tot += prob_tab(i, j); #ifdef IEEE_754 if (ISNAN(p_tot)) break; #endif if (prob_tab(i, j) < 0.0) { p_tot = NAN; throw_warning = true; break; } } prob_tab(i, 0) /= p_tot; for (int j = 1; j < k; j++) { prob_tab(i, j) /= p_tot; prob_tab(i, j) += prob_tab(i, j-1); } } for (int i = 0; i < Nmax; i++) { #ifdef IEEE_754 if (ISNAN(GETV(p, i))) { x[i] = GETV(p, i); continue; } #endif if (ISNAN(GETM(prob_tab, i, 0))) { x[i] = GETM(prob_tab, i, 0); continue; } if (GETV(p, i) < 0.0 || GETV(p, i) > 1.0) { x[i] = NAN; throw_warning = true; continue; } if (GETV(p, i) == 0.0) { x[i] = 1.0; continue; } if (GETV(p, i) == 1.0) { x[i] = to_dbl(k); continue; } jj = 1; for (int j = 0; j < k; j++) { if (GETM(prob_tab, i, j) >= GETV(p, i)) { jj = j+1; break; } } x[i] = to_dbl(jj); } if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rcat( const int& n, const NumericMatrix& prob ) { if (prob.length() < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } int k = prob.ncol(); NumericVector x(n); int jj; double u, p_tot; bool throw_warning = false; if (k < 2) Rcpp::stop("number of columns in prob is < 2"); NumericMatrix prob_tab = Rcpp::clone(prob); for (int i = 0; i < prob_tab.nrow(); i++) { p_tot = 0.0; for (int j = 0; j < k; j++) { p_tot += prob_tab(i, j); if (ISNAN(p_tot)) break; if (prob_tab(i, j) < 0.0) { p_tot = NAN; throw_warning = true; break; } } prob_tab(i, 0) /= p_tot; for (int j = 1; j < k; j++) { prob_tab(i, j) /= p_tot; prob_tab(i, j) += prob_tab(i, j-1); } } for (int i = 0; i < n; i++) { if (ISNAN(GETM(prob_tab, i , 0))) { x[i] = GETM(prob_tab, i, 0); continue; } u = rng_unif(); jj = 1; for (int j = 0; j < k; j++) { if (GETM(prob_tab, i, j) >= u) { jj = j+1; break; } } x[i] = to_dbl(jj); } if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/shared_inline.h0000755000176200001440000000226714475546572016204 0ustar liggesusers #ifndef EDCPP_INLINEFUNS_H #define EDCPP_INLINEFUNS_H #include "shared.h" #include inline bool tol_equal(double x, double y) { return std::abs(x - y) < MIN_DIFF_EPS; } inline double phi(double x) { return R::dnorm(x, 0.0, 1.0, false); } inline double lphi(double x) { return R::dnorm(x, 0.0, 1.0, true); } inline double Phi(double x) { return R::pnorm(x, 0.0, 1.0, true, false); } inline double InvPhi(double x) { return R::qnorm(x, 0.0, 1.0, true, false); } inline double factorial(double x) { return R::gammafn(x + 1.0); } inline double lfactorial(double x) { return R::lgammafn(x + 1.0); } inline double rng_sign() { double u = rng_unif(); return (u > 0.5) ? 1.0 : -1.0; } inline bool is_large_int(double x) { if (x > std::numeric_limits::max()) return true; return false; } inline double to_dbl(int x) { return static_cast(x); } inline int to_pos_int(double x) { if (x < 0.0 || ISNAN(x)) Rcpp::stop("value cannot be coerced to integer"); if (is_large_int(x)) Rcpp::stop("value out of integer range"); return static_cast(x); } inline double trunc_p(double x) { return x < 0.0 ? 0.0 : (x > 1.0 ? 1.0 : x); } #endif extraDistr/src/multinomial-distribution.cpp0000755000176200001440000001007514475546572020776 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using Rcpp::NumericMatrix; /* * Multinomial distribution * * x[i] number of values of i-th category drawn * n = sum(x) total number of draws * p[i] probability of drawing i-th category value * * f(x) = n!/prod(x[i]!) * prod(p[i]^x[i]) * */ // [[Rcpp::export]] NumericVector cpp_dmnom( const NumericMatrix& x, const NumericVector& size, const NumericMatrix& prob, const bool& log_prob = false ) { if (std::min({static_cast(x.nrow()), static_cast(x.ncol()), static_cast(size.length()), static_cast(prob.nrow()), static_cast(prob.ncol())}) < 1) { return NumericVector(0); } int Nmax = std::max({ static_cast(x.nrow()), static_cast(size.length()), static_cast(prob.nrow()) }); int m = x.ncol(); int k = prob.ncol(); NumericVector p(Nmax); bool throw_warning = false; if (m != k) Rcpp::stop("number of columns in x does not equal number of columns in prob"); double n_fac, prod_xfac, prod_pow_px, sum_x, p_tot; bool wrong_param, wrong_x; for (int i = 0; i < Nmax; i++) { sum_x = 0.0; p_tot = 0.0; wrong_param = false; wrong_x = false; for (int j = 0; j < k; j++) { if (GETM(prob, i, j) < 0.0) wrong_param = true; p_tot += GETM(prob, i, j); sum_x += GETM(x, i, j); } #ifdef IEEE_754 if (ISNAN(p_tot + sum_x + GETV(size, i))) { p[i] = p_tot + sum_x + GETV(size, i); continue; } #endif if (wrong_param || GETV(size, i) < 0.0 || !isInteger(GETV(size, i), false)) { throw_warning = true; p[i] = NAN; continue; } prod_xfac = 0.0; prod_pow_px = 0.0; for (int j = 0; j < k; j++) { if (GETM(x, i, j) < 0.0 || !isInteger(GETM(x, i, j))) { wrong_x = true; } else { prod_xfac += lfactorial(GETM(x, i, j)); prod_pow_px += log(GETM(prob, i, j) / p_tot) * GETM(x, i, j); } } if (wrong_x || sum_x < 0.0 || sum_x != GETV(size, i)) { p[i] = R_NegInf; } else { n_fac = lfactorial(GETV(size, i)); p[i] = n_fac - prod_xfac + prod_pow_px; } } if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericMatrix cpp_rmnom( const int& n, const NumericVector& size, const NumericMatrix& prob ) { if (std::min({static_cast(size.length()), static_cast(prob.nrow()), static_cast(prob.ncol())}) < 1) { Rcpp::warning("NAs produced"); NumericMatrix out(n, prob.ncol()); std::fill(out.begin(), out.end(), NA_REAL); return out; } int k = prob.ncol(); bool wrong_values; double p_tmp, size_left, sum_p, p_tot; NumericMatrix x(n, k); bool throw_warning = false; for (int i = 0; i < n; i++) { size_left = GETV(size, i); sum_p = 1.0; p_tot = 0.0; wrong_values = false; // TODO: // sort prob(i,_) first? for (int j = 0; j < k; j++) { if (GETM(prob, i, j) < 0.0) { wrong_values = true; break; } p_tot += GETM(prob, i, j); } if (wrong_values || ISNAN(p_tot + GETV(size, i)) || GETV(size, i) < 0.0 || !isInteger(GETV(size, i), false)) { throw_warning = true; for (int j = 0; j < k; j++) x(i, j) = NA_REAL; continue; } for (int j = 0; j < k-1; j++) { if ( size_left > 0.0 ) { p_tmp = GETM(prob, i, j)/p_tot; x(i, j) = R::rbinom(size_left, trunc_p(p_tmp/sum_p)); size_left -= x(i, j); sum_p -= p_tmp; } else { break; } } x(i, k-1) = size_left; } if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/truncated-normal-distribution.cpp0000755000176200001440000002011714475546572021721 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Truncated Normal distribution * * Values: * x * * Parameters: * mu * sigma > 0 * a, b * * z = (x-mu)/sigma * * f(x) = phi(z) / (Phi((b-mu)/sigma) - Phi((mu-a)/sigma)) * F(x) = (Phi(z) - Phi((mu-a)/sigma)) / (Phi((b-mu)/sigma) - Phi((a-mu)/sigma)) * F^-1(p) = Phi^-1(Phi((mu-a)/sigma) + p * (Phi((b-mu)/sigma) - Phi((a-mu)/sigma))) * * where phi() is PDF for N(0, 1) and Phi() is CDF for N(0, 1) * */ double pdf_tnorm(double x, double mu, double sigma, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma) || ISNAN(a) || ISNAN(b)) return x+mu+sigma+a+b; #endif if (sigma <= 0.0 || b <= a) { throw_warning = true; return NAN; } if (a == R_NegInf && b == R_PosInf) return R::dnorm(x, mu, sigma, false); double Phi_a, Phi_b; if (x > a && x < b) { Phi_a = Phi((a-mu)/sigma); Phi_b = Phi((b-mu)/sigma); return exp(-((x-mu)*(x-mu)) / (2.0*(sigma*sigma))) / (SQRT_2_PI*sigma * (Phi_b - Phi_a)); } else { return 0.0; } } double cdf_tnorm(double x, double mu, double sigma, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma) || ISNAN(a) || ISNAN(b)) return x+mu+sigma+a+b; #endif if (sigma <= 0.0 || b <= a) { throw_warning = true; return NAN; } if (a == R_NegInf && b == R_PosInf) return R::pnorm(x, mu, sigma, true, false); double Phi_x, Phi_a, Phi_b; if (x > a && x < b) { Phi_x = Phi((x-mu)/sigma); Phi_a = Phi((a-mu)/sigma); Phi_b = Phi((b-mu)/sigma); return (Phi_x - Phi_a) / (Phi_b - Phi_a); } else if (x >= b) { return 1.0; } else { return 0.0; } } double invcdf_tnorm(double p, double mu, double sigma, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(mu) || ISNAN(sigma) || ISNAN(a) || ISNAN(b)) return p+mu+sigma+a+b; #endif if (sigma <= 0.0 || b <= a || !VALID_PROB(p)) { throw_warning = true; return NAN; } if (a == R_NegInf && b == R_PosInf) return R::qnorm(p, mu, sigma, true, false); double Phi_a, Phi_b; Phi_a = Phi((a-mu)/sigma); Phi_b = Phi((b-mu)/sigma); return InvPhi(Phi_a + p * (Phi_b - Phi_a)) * sigma + mu; } double rng_tnorm(double mu, double sigma, double a, double b, bool& throw_warning) { if (ISNAN(mu) || ISNAN(sigma) || ISNAN(a) || ISNAN(b) || sigma <= 0.0 || b <= a) { throw_warning = true; return NA_REAL; } // non-truncated normal if (a == R_NegInf && b == R_PosInf) return R::rnorm(mu, sigma); double r, u, za, zb, aa, za_sq, zb_sq; bool stop = false; za = (a-mu)/sigma; zb = (b-mu)/sigma; za_sq = za * za; zb_sq = zb * zb; if (abs(za) <= 1e-16 && zb == R_PosInf) { r = R::norm_rand(); if (r < 0.0) r = -r; } else if (za == R_PosInf && abs(zb) <= 1e-16) { r = R::norm_rand(); if (r > 0.0) r = -r; } else if ((za < 0.0 && zb == R_PosInf) || (za == R_NegInf && zb > 0.0) || (za != R_PosInf && zb != R_PosInf && za < 0.0 && zb > 0.0 && zb-za > SQRT_2_PI)) { do { r = R::norm_rand(); if (r >= za && r <= zb) stop = true; } while (!stop); } else if (za >= 0.0 && (zb > za + 2.0*sqrt(M_E) / (za + sqrt(za_sq + 4.0)) * exp((za*2.0 - za*sqrt(za_sq + 4.0)) / 4.0))) { aa = (za + sqrt(za_sq + 4.0)) / 2.0; do { r = R::exp_rand() / aa + za; u = rng_unif(); if ((u <= exp(-((r-aa)*(r-aa)) / 2.0)) && (r <= zb)) stop = true; } while (!stop); } else if (zb <= 0.0 && (-za > -zb + 2.0*sqrt(M_E) / (-zb + sqrt(zb_sq + 4.0)) * exp((zb*2.0 + zb*sqrt(zb_sq + 4.0)) / 4.0))) { aa = (-zb + sqrt(zb_sq + 4.0)) / 2.0; do { r = R::exp_rand() / aa - zb; u = rng_unif(); if ((u <= exp(-((r-aa)*(r-aa)) / 2.0)) && (r <= -za)) { r = -r; stop = true; } } while (!stop); } else { if (0.0 < za) { do { r = R::runif(za, zb); u = rng_unif(); stop = (u <= exp((za_sq - r*r)/2.0)); } while (!stop); } else if (zb < 0.0) { do { r = R::runif(za, zb); u = rng_unif(); stop = (u <= exp((zb_sq - r*r)/2.0)); } while (!stop); } else { do { r = R::runif(za, zb); u = rng_unif(); stop = (u <= exp(-(r*r)/2.0)); } while (!stop); } } return mu + sigma * r; } // [[Rcpp::export]] NumericVector cpp_dtnorm( const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& lower, const NumericVector& upper, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), sigma.length(), lower.length(), upper.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), sigma.length(), lower.length(), upper.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pdf_tnorm(GETV(x, i), GETV(mu, i), GETV(sigma, i), GETV(lower, i), GETV(upper, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_ptnorm( const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), sigma.length(), lower.length(), upper.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), sigma.length(), lower.length(), upper.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_tnorm(GETV(x, i), GETV(mu, i), GETV(sigma, i), GETV(lower, i), GETV(upper, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qtnorm( const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), mu.length(), sigma.length(), lower.length(), upper.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), mu.length(), sigma.length(), lower.length(), upper.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) x[i] = invcdf_tnorm(GETV(pp, i), GETV(mu, i), GETV(sigma, i), GETV(lower, i), GETV(upper, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rtnorm( const int& n, const NumericVector& mu, const NumericVector& sigma, const NumericVector& lower, const NumericVector& upper ) { if (std::min({mu.length(), sigma.length(), lower.length(), upper.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_tnorm(GETV(mu, i), GETV(sigma, i), GETV(lower, i), GETV(upper, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/truncated-poisson-distribution.cpp0000755000176200001440000001321614475546572022125 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; inline double logpdf_tpois(double x, double lambda, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(lambda) || ISNAN(a) || ISNAN(b)) return x+lambda+a+b; #endif if (lambda < 0.0 || b < a) { throw_warning = true; return NAN; } if (!isInteger(x) || x < 0.0 || x <= a || x > b || !R_FINITE(x)) return R_NegInf; // if (a == 0.0 && b == R_PosInf) // return pow(lambda, x) / (factorial(x) * (exp(lambda) - 1.0)); double pa, pb; pa = R::ppois(a, lambda, true, false); pb = R::ppois(b, lambda, true, false); return R::dpois(x, lambda, true) - log(pb-pa); } inline double cdf_tpois(double x, double lambda, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(lambda) || ISNAN(a) || ISNAN(b)) return x+lambda+a+b; #endif if (lambda <= 0.0 || b < a) { throw_warning = true; return NAN; } if (x < 0.0 || x <= a) return 0.0; if (x > b || !R_FINITE(x)) return 1.0; // if (a == 0.0 && b == R_PosInf) // return R::ppois(x, lambda, true, false) / (1.0 - exp(-lambda)); double pa, pb; pa = R::ppois(a, lambda, true, false); pb = R::ppois(b, lambda, true, false); return (R::ppois(x, lambda, true, false) - pa) / (pb-pa); } inline double invcdf_tpois(double p, double lambda, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(lambda) || ISNAN(a) || ISNAN(b)) return p+lambda+a+b; #endif if (lambda < 0.0 || b < a || !VALID_PROB(p)) { throw_warning = true; return NAN; } if (p == 0.0) return std::max(a, 0.0); if (p == 1.0) return b; double pa, pb; pa = R::ppois(a, lambda, true, false); pb = R::ppois(b, lambda, true, false); return R::qpois(pa + p*(pb-pa), lambda, true, false); } inline double rng_tpois(double lambda, double a, double b, bool& throw_warning) { if (ISNAN(lambda) || ISNAN(a) || ISNAN(b) || lambda < 0.0 || b < a) { throw_warning = true; return NA_REAL; } double u, pa, pb; pa = R::ppois(a, lambda, true, false); pb = R::ppois(b, lambda, true, false); u = R::runif(pa, pb); return R::qpois(u, lambda, true, false); } // [[Rcpp::export]] NumericVector cpp_dtpois( const NumericVector& x, const NumericVector& lambda, const NumericVector& lower, const NumericVector& upper, const bool& log_prob = false ) { if (std::min({x.length(), lambda.length(), lower.length(), upper.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), lambda.length(), lower.length(), upper.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_tpois(GETV(x, i), GETV(lambda, i), GETV(lower, i), GETV(upper, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_ptpois( const NumericVector& x, const NumericVector& lambda, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), lambda.length(), lower.length(), upper.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), lambda.length(), lower.length(), upper.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_tpois(GETV(x, i), GETV(lambda, i), GETV(lower, i), GETV(upper, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qtpois( const NumericVector& p, const NumericVector& lambda, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), lambda.length(), lower.length(), upper.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), lambda.length(), lower.length(), upper.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) x[i] = invcdf_tpois(GETV(pp, i), GETV(lambda, i), GETV(lower, i), GETV(upper, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rtpois( const int& n, const NumericVector& lambda, const NumericVector& lower, const NumericVector& upper ) { if (std::min({lambda.length(), lower.length(), upper.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_tpois(GETV(lambda, i), GETV(lower, i), GETV(upper, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/rademacher-distribution.cpp0000755000176200001440000000044714475546572020541 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using Rcpp::NumericVector; // [[Rcpp::export]] NumericVector cpp_rsign( const int& n ) { NumericVector x(n); for (int i = 0; i < n; i++) x[i] = rng_sign(); return x; } extraDistr/src/bernoulli-distribution.cpp0000755000176200001440000000775014475546572020445 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Bernoulli distribution * * Values: * x * * Parameters: * 0 <= p <= 1 * */ inline double pdf_bernoulli(double x, double prob, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(prob)) return x+prob; #endif if (!VALID_PROB(prob)) { throw_warning = true; return NAN; } if (x == 1.0) return prob; if (x == 0.0) return 1.0 - prob; char msg[55]; std::snprintf(msg, sizeof(msg), "improper x = %f", x); Rcpp::warning(msg); return 0.0; } inline double cdf_bernoulli(double x, double prob, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(prob)) return x+prob; #endif if (!VALID_PROB(prob)) { throw_warning = true; return NAN; } if (x < 0.0) return 0.0; if (x < 1.0) return 1.0 - prob; return 1.0; } inline double invcdf_bernoulli(double p, double prob, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(prob)) return p+prob; #endif if (!VALID_PROB(prob) || !VALID_PROB(p)) { throw_warning = true; return NAN; } return (p <= (1.0 - prob)) ? 0.0 : 1.0; } inline double rng_bernoulli(double prob, bool& throw_warning) { if (ISNAN(prob) || !VALID_PROB(prob)) { throw_warning = true; return NA_REAL; } double u = rng_unif(); return (u > prob) ? 0.0 : 1.0; } // [[Rcpp::export]] NumericVector cpp_dbern( const NumericVector& x, const NumericVector& prob, const bool& log_prob = false ) { if (std::min({x.length(), prob.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), prob.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pdf_bernoulli(GETV(x, i), GETV(prob, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pbern( const NumericVector& x, const NumericVector& prob, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), prob.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), prob.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_bernoulli(GETV(x, i), GETV(prob, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qbern( const NumericVector& p, const NumericVector& prob, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), prob.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), prob.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_bernoulli(GETV(pp, i), GETV(prob, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rbern( const int& n, const NumericVector& prob ) { if (prob.length() < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_bernoulli(GETV(prob, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/huber-distribution.cpp0000755000176200001440000001335014475546572017550 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; inline double logpdf_huber(double x, double mu, double sigma, double c, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma) || ISNAN(c)) return x+mu+sigma+c; #endif if (sigma <= 0.0 || c <= 0.0) { throw_warning = true; return NAN; } double z, A, rho; z = abs((x - mu)/sigma); // A = 2.0*SQRT_2_PI * (Phi(c) + phi(c)/c - 0.5); A = LOG_2F + log(SQRT_2_PI) + log(Phi(c) + phi(c)/c - 0.5); if (z <= c) { rho = (z*z)/2.0; } else { rho = c*z - (c*c)/2.0; } // exp(-rho)/A/sigma; return -rho - A - log(sigma); } inline double cdf_huber(double x, double mu, double sigma, double c, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma) || ISNAN(c)) return x+mu+sigma+c; #endif if (sigma <= 0.0 || c <= 0.0) { throw_warning = true; return NAN; } double A, z, az, p; A = 2.0*(phi(c)/c - Phi(-c) + 0.5); z = (x - mu)/sigma; az = -abs(z); if (az <= -c) p = exp((c*c)/2.0)/c * exp(c*az) / SQRT_2_PI/A; else p = (phi(c)/c + Phi(az) - Phi(-c))/A; if (z <= 0.0) return p; else return 1.0 - p; } inline double invcdf_huber(double p, double mu, double sigma, double c, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(mu) || ISNAN(sigma) || ISNAN(c)) return p+mu+sigma+c; #endif if (sigma <= 0.0 || c <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } double x, pm, A; A = 2.0 * SQRT_2_PI * (Phi(c) + phi(c)/c - 0.5); pm = std::min(p, 1.0 - p); if (pm <= SQRT_2_PI * phi(c)/(c*A)) x = log(c*pm*A)/c - c/2.0; else x = InvPhi(abs(1.0 - Phi(c) + pm*A/SQRT_2_PI - phi(c)/c)); if (p < 0.5) return mu + x*sigma; else return mu - x*sigma; } inline double rng_huber(double mu, double sigma, double c, bool& throw_warning) { if (ISNAN(mu) || ISNAN(sigma) || ISNAN(c) || sigma <= 0.0 || c <= 0.0) { throw_warning = true; return NA_REAL; } double x, pm, A, u; u = rng_unif(); A = 2.0 * SQRT_2_PI * (Phi(c) + phi(c)/c - 0.5); pm = std::min(u, 1.0 - u); if (pm <= SQRT_2_PI * phi(c)/(c*A)) x = log(c*pm*A)/c - c/2.0; else x = InvPhi(abs(1.0 - Phi(c) + pm*A/SQRT_2_PI - phi(c)/c)); if (u < 0.5) return mu + x*sigma; else return mu - x*sigma; } // [[Rcpp::export]] NumericVector cpp_dhuber( const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& epsilon, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), sigma.length(), epsilon.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), sigma.length(), epsilon.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_huber(GETV(x, i), GETV(mu, i), GETV(sigma, i), GETV(epsilon, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_phuber( const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& epsilon, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), sigma.length(), epsilon.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), sigma.length(), epsilon.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_huber(GETV(x, i), GETV(mu, i), GETV(sigma, i), GETV(epsilon, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qhuber( const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const NumericVector& epsilon, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), mu.length(), sigma.length(), epsilon.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), mu.length(), sigma.length(), epsilon.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_huber(GETV(pp, i), GETV(mu, i), GETV(sigma, i), GETV(epsilon, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rhuber( const int& n, const NumericVector& mu, const NumericVector& sigma, const NumericVector& epsilon ) { if (std::min({mu.length(), sigma.length(), epsilon.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_huber(GETV(mu, i), GETV(sigma, i), GETV(epsilon, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/pareto-distribution.cpp0000755000176200001440000001034214475546572017733 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Pareto distribution * * Values: * x * * Parameters: * a, b > 0 * * f(x) = (a*b^a) / x^{a+1} * F(x) = 1 - (b/x)^a * F^-1(p) = b/(1-p)^{1-a} * */ inline double logpdf_pareto(double x, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(a) || ISNAN(b)) return x+a+b; #endif if (a <= 0.0 || b <= 0.0) { throw_warning = true; return NAN; } if (x < b) return R_NegInf; // a * pow(b, a) / pow(x, a+1.0); return log(a) + log(b)*a - log(x)*(a+1.0); } inline double cdf_pareto(double x, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(a) || ISNAN(b)) return x+a+b; #endif if (a <= 0.0 || b <= 0.0) { throw_warning = true; return NAN; } if (x < b) return 0.0; return 1.0 - pow(b/x, a); } inline double invcdf_pareto(double p, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(a) || ISNAN(b)) return p+a+b; #endif if (a <= 0.0 || b <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } return b / pow(1.0-p, 1.0/a); } inline double rng_pareto(double a, double b, bool& throw_warning) { if (ISNAN(a) || ISNAN(b) || a <= 0.0 || b <= 0.0) { throw_warning = true; return NA_REAL; } double u = rng_unif(); return b / pow(u, 1.0/a); } // [[Rcpp::export]] NumericVector cpp_dpareto( const NumericVector& x, const NumericVector& a, const NumericVector& b, const bool& log_prob = false ) { if (std::min({x.length(), a.length(), b.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), a.length(), b.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_pareto(GETV(x, i), GETV(a, i), GETV(b, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_ppareto( const NumericVector& x, const NumericVector& a, const NumericVector& b, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), a.length(), b.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), a.length(), b.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_pareto(GETV(x, i), GETV(a, i), GETV(b, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qpareto( const NumericVector& p, const NumericVector& a, const NumericVector& b, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), a.length(), b.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), a.length(), b.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) x[i] = invcdf_pareto(GETV(pp, i), GETV(a, i), GETV(b, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rpareto( const int& n, const NumericVector& a, const NumericVector& b ) { if (std::min({a.length(), b.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_pareto(GETV(a, i), GETV(b, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/frechet-distribution.cpp0000755000176200001440000001251614475546572020066 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Frechet distribution * * Values: * x > mu * * Parameters: * lambda > 0 * mu * sigma > 0 * * z = (x-mu)/sigma * f(x) = lambda/sigma * z^{-1-lambda} * exp(-z^-lambda) * F(x) = exp(-z^-lambda) * F^-1(p) = mu + sigma * -log(p)^{-1/lambda} * */ inline double logpdf_frechet(double x, double lambda, double mu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(lambda) || ISNAN(mu) || ISNAN(sigma)) return x+lambda+mu+sigma; #endif if (lambda <= 0.0 || sigma <= 0.0) { throw_warning = true; return NAN; } if (x <= mu) return R_NegInf; double z = (x-mu)/sigma; // lambda/sigma * pow(z, -1.0-lambda) * exp(-pow(z, -lambda)); return log(lambda) - log(sigma) + log(z) * (-1.0-lambda) - exp(log(z) * -lambda); } inline double cdf_frechet(double x, double lambda, double mu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(lambda) || ISNAN(mu) || ISNAN(sigma)) return x+lambda+mu+sigma; #endif if (lambda <= 0.0 || sigma <= 0.0) { throw_warning = true; return NAN; } if (x <= mu) return 0.0; double z = (x-mu)/sigma; return exp(-pow(z, -lambda)); } inline double invcdf_frechet(double p, double lambda, double mu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(lambda) || ISNAN(mu) || ISNAN(sigma)) return p+lambda+mu+sigma; #endif if (lambda <= 0.0 || sigma <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } if (p == 1.0) return R_PosInf; return mu + sigma * pow(-log(p), -1.0/lambda); } inline double rng_frechet(double lambda, double mu, double sigma, bool& throw_warning) { if (ISNAN(lambda) || ISNAN(mu) || ISNAN(sigma) || lambda <= 0.0 || sigma <= 0.0) { throw_warning = true; return NA_REAL; } double u = rng_unif(); return mu + sigma * pow(-log(u), -1.0/lambda); } // [[Rcpp::export]] NumericVector cpp_dfrechet( const NumericVector& x, const NumericVector& lambda, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob = false ) { if (std::min({x.length(), lambda.length(), mu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), lambda.length(), mu.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_frechet(GETV(x, i), GETV(lambda, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pfrechet( const NumericVector& x, const NumericVector& lambda, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), lambda.length(), mu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), lambda.length(), mu.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_frechet(GETV(x, i), GETV(lambda, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qfrechet( const NumericVector& p, const NumericVector& lambda, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), lambda.length(), mu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), lambda.length(), mu.length(), sigma.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_frechet(GETV(pp, i), GETV(lambda, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rfrechet( const int& n, const NumericVector& lambda, const NumericVector& mu, const NumericVector& sigma ) { if (std::min({lambda.length(), mu.length(), sigma.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_frechet(GETV(lambda, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/inverse-gamma-distribution.cpp0000755000176200001440000000550014475546572021174 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Inverse-Gamma distribution * * Values: * x * * Parameters: * alpha > 0 * beta > 0 * * f(k) = (x^(-alpha-1) * exp(-1/(beta*x))) / (Gamma(alpha)*beta^alpha) * F(x) = gamma(alpha, 1/(beta*x)) / Gamma(alpha) * * V. Witkovsky (2001) Computing the distribution of a linear * combination of inverted gamma variables, Kybernetika 37(1), 79-90 * */ inline double logpdf_invgamma(double x, double alpha, double beta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(alpha) || ISNAN(beta)) return x+alpha+beta; #endif if (alpha <= 0.0 || beta <= 0.0) { throw_warning = true; return NAN; } if (x <= 0.0) return R_NegInf; return log(beta) * -alpha - R::lgammafn(alpha) + log(x) * (-alpha-1.0) - 1.0/(beta*x); } inline double cdf_invgamma(double x, double alpha, double beta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(alpha) || ISNAN(beta)) return x+alpha+beta; #endif if (alpha <= 0.0 || beta <= 0.0) { throw_warning = true; return NAN; } if (x <= 0.0) return 0.0; return R::pgamma(1.0/x, alpha, 1.0/beta, false, false); } // [[Rcpp::export]] NumericVector cpp_dinvgamma( const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& log_prob = false ) { if (std::min({x.length(), alpha.length(), beta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), alpha.length(), beta.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_invgamma(GETV(x, i), GETV(alpha, i), GETV(beta, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pinvgamma( const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), alpha.length(), beta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), alpha.length(), beta.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_invgamma(GETV(x, i), GETV(alpha, i), GETV(beta, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } extraDistr/src/wald-distribution.cpp0000755000176200001440000000703414475546572017374 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Wald distribution * * Parameters: * mu > 0 * lambda > 0 * * Values: * x > 0 * * */ inline double pdf_wald(double x, double mu, double lambda, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(lambda)) return x+mu+lambda; #endif if (mu <= 0.0 || lambda <= 0.0) { throw_warning = true; return NAN; } if (x <= 0.0 || !R_FINITE(x)) return 0.0; return sqrt(lambda/(2.0*M_PI*(x*x*x))) * exp( (-lambda*(x-mu)*(x-mu))/(2.0*(mu*mu)*x) ); } inline double cdf_wald(double x, double mu, double lambda, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(lambda)) return x+mu+lambda; #endif if (mu <= 0.0 || lambda <= 0.0) { throw_warning = true; return NAN; } if (x <= 0.0) return 0.0; if (x == R_PosInf) return 1.0; return Phi(sqrt(lambda/x)*(x/mu-1.0)) + exp((2.0*lambda)/mu) * Phi(-sqrt(lambda/x)*(x/mu+1.0)); } inline double rng_wald(double mu, double lambda, bool& throw_warning) { if (ISNAN(mu) || ISNAN(lambda) || mu <= 0.0 || lambda <= 0.0) { throw_warning = true; return NA_REAL; } double u, x, y, z; u = rng_unif(); z = R::norm_rand(); y = z*z; x = mu + (mu*mu*y)/(2.0*lambda) - mu/(2.0*lambda) * sqrt(4.0*mu*lambda*y+(mu*mu)*(y*y)); if (u <= mu/(mu+x)) return x; else return (mu*mu)/x; } // [[Rcpp::export]] NumericVector cpp_dwald( const NumericVector& x, const NumericVector& mu, const NumericVector& lambda, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), lambda.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), lambda.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pdf_wald(GETV(x, i), GETV(mu, i), GETV(lambda, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pwald( const NumericVector& x, const NumericVector& mu, const NumericVector& lambda, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), lambda.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), lambda.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_wald(GETV(x, i), GETV(mu, i), GETV(lambda, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_rwald( const int& n, const NumericVector& mu, const NumericVector& lambda ) { if (std::min({mu.length(), lambda.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_wald(GETV(mu, i), GETV(lambda, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/discrete-gamma-distribution.cpp0000755000176200001440000000267214475546572021332 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Discrete normal distribution * * Values: * x * * Parameters * mu * sigma > 0 * */ inline double pmf_dgamma(double x, double shape, double scale, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(shape) || ISNAN(scale)) return x+shape+scale; #endif if (shape <= 0.0 || scale <= 0) { throw_warning = true; return NAN; } if (x < 0.0 || !isInteger(x)) return 0.0; return R::pgamma(x+1.0, shape, scale, true, false) - R::pgamma(x, shape, scale, true, false); } // [[Rcpp::export]] NumericVector cpp_ddgamma( const NumericVector& x, const NumericVector& shape, const NumericVector& scale, const bool& log_prob = false ) { if (std::min({x.length(), shape.length(), scale.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), shape.length(), scale.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pmf_dgamma(GETV(x, i), GETV(shape, i), GETV(scale, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } extraDistr/src/gev-distribution.cpp0000755000176200001440000001376314475546572017234 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using std::log1p; /* * Generalized extreme value distribution * * Values: * x * * Parameters: * mu * sigma > 0 * xi * * z = (x-mu)/sigma * where 1+xi*z > 0 * * f(x) = { 1/sigma * (1+xi*z)^{-1/xi-1} * exp(-(1+xi*z)^{-1/xi}) if xi != 0 * { 1/sigma * exp(-z) * exp(-exp(-z)) otherwise * F(x) = { exp(-(1+xi*z)^{1/xi}) if xi != 0 * { exp(-exp(-z)) otherwise * F^-1(p) = { mu - sigma/xi * (1 - (-log(1-p))^xi) if xi != 0 * { mu - sigma * log(-log(1-p)) otherwise * */ inline double logpdf_gev(double x, double mu, double sigma, double xi, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma) || ISNAN(xi)) return x+mu+sigma+xi; #endif if (sigma <= 0.0) { Rcpp::warning("NaNs produced"); return NAN; } double z = (x-mu)/sigma; if (1.0+xi*z > 0.0) { if (xi != 0.0) { // 1.0/sigma * pow(1.0+xi*z, -1.0-(1.0/xi)) * exp(-pow(1.0+xi*z, -1.0/xi)); return -log(sigma) + log1p(xi*z) * (-1.0-(1.0/xi)) - exp(log1p(xi*z) * (-1.0/xi) ); } else { // 1.0/sigma * exp(-z) * exp(-exp(-z)); return -log(sigma) - z - exp(-z); } } else { return R_NegInf; } } inline double cdf_gev(double x, double mu, double sigma, double xi, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma) || ISNAN(xi)) return x+mu+sigma+xi; #endif if (sigma <= 0.0) { Rcpp::warning("NaNs produced"); return NAN; } double z = (x-mu)/sigma; if (1.0+xi*z > 0.0) { if (xi != 0.0) { // exp(-pow(1.0+xi*z, -1.0/xi)); return exp(-exp(log1p(xi*z) * (-1.0/xi))); } else { return exp(-exp(-z)); } } else { if (z > 0 && z >= -1/xi) return 1.0; else return 0.0; } } inline double invcdf_gev(double p, double mu, double sigma, double xi, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(mu) || ISNAN(sigma) || ISNAN(xi)) return p+mu+sigma+xi; #endif if (sigma <= 0.0 || !VALID_PROB(p)) { Rcpp::warning("NaNs produced"); return NAN; } if (p == 1.0) return R_PosInf; if (xi != 0.0) return mu - sigma/xi * (1.0 - pow(-log(p), -xi)); else return mu - sigma * log(-log(p)); } inline double rng_gev(double mu, double sigma, double xi, bool& throw_warning) { if (ISNAN(mu) || ISNAN(sigma) || ISNAN(xi) || sigma <= 0.0) { Rcpp::warning("NAs produced"); return NA_REAL; } double u = R::exp_rand(); // -log(rng_unif()) if (xi != 0.0) return mu + sigma/xi * (pow(u, -xi) - 1.0); else return mu - sigma * log(u); } // [[Rcpp::export]] NumericVector cpp_dgev( const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), sigma.length(), xi.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), sigma.length(), xi.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_gev(GETV(x, i), GETV(mu, i), GETV(sigma, i), GETV(xi, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pgev( const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi, bool lower_tail = true, bool log_prob = false ) { if (std::min({x.length(), mu.length(), sigma.length(), xi.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), sigma.length(), xi.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_gev(GETV(x, i), GETV(mu, i), GETV(sigma, i), GETV(xi, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qgev( const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi, bool lower_tail = true, bool log_prob = false ) { if (std::min({p.length(), mu.length(), sigma.length(), xi.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), mu.length(), sigma.length(), xi.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_gev(GETV(pp, i), GETV(mu, i), GETV(sigma, i), GETV(xi, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rgev( const int& n, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi ) { if (std::min({mu.length(), sigma.length(), xi.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_gev(GETV(mu, i), GETV(sigma, i), GETV(xi, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/dirichlet-multinomial-distribution.cpp0000755000176200001440000001067514475546572022751 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using Rcpp::NumericMatrix; /* * Dirichlet-multinomial (multivariate Polya) distribution * * Values: * x > 0 * * Parameters: * n > 0 * alpha > 0 (R^k where k >= 2) * * where: * sum(x) == n * */ // [[Rcpp::export]] NumericVector cpp_ddirmnom( const NumericMatrix& x, const NumericVector& size, const NumericMatrix& alpha, const bool& log_prob = false ) { if (std::min({static_cast(x.nrow()), static_cast(x.ncol()), static_cast(size.length()), static_cast(alpha.nrow()), static_cast(alpha.ncol())}) < 1) { return NumericVector(0); } int Nmax = std::max({ static_cast(x.nrow()), static_cast(size.length()), static_cast(alpha.nrow()) }); int m = x.ncol(); int k = alpha.ncol(); k = std::min(m, k); NumericVector p(Nmax); bool throw_warning = false; if (k < 2) Rcpp::stop("number of columns in alpha should be >= 2"); if (m != k) Rcpp::stop("number of columns in x does not equal number of columns in alpha"); double prod_tmp, sum_alpha, sum_x; bool wrong_x, wrong_param; for (int i = 0; i < Nmax; i++) { prod_tmp = 0.0; sum_alpha = 0.0; sum_x = 0.0; wrong_x = false; wrong_param = false; for (int j = 0; j < k; j++) { if (GETM(alpha, i, j) <= 0.0) wrong_param = true; if (GETM(x, i, j) < 0.0 || !isInteger(GETM(x, i, j))) wrong_x = true; sum_x += GETM(x, i, j); sum_alpha += GETM(alpha, i, j); } #ifdef IEEE_754 if (ISNAN(sum_x + sum_alpha + GETV(size, i))) { p[i] = sum_x + sum_alpha + GETV(size, i); continue; } #endif if (wrong_param || GETV(size, i) < 0.0 || !isInteger(GETV(size, i), false)) { throw_warning = true; p[i] = NAN; continue; } if (sum_x < 0.0 || sum_x != GETV(size, i) || wrong_x) { p[i] = R_NegInf; } else { for (int j = 0; j < k; j++) { prod_tmp += R::lgammafn(GETM(x, i, j) + GETM(alpha, i, j)) - (lfactorial(GETM(x, i, j)) + R::lgammafn(GETM(alpha, i, j))); } p[i] = (lfactorial(GETV(size, i)) + R::lgammafn(sum_alpha)) - R::lgammafn(GETV(size, i) + sum_alpha) + prod_tmp; } } if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericMatrix cpp_rdirmnom( const int& n, const NumericVector& size, const NumericMatrix& alpha ) { if (std::min({static_cast(size.length()), static_cast(alpha.nrow()), static_cast(alpha.ncol())}) < 1) { Rcpp::warning("NAs produced"); NumericMatrix out(n, alpha.ncol()); std::fill(out.begin(), out.end(), NA_REAL); return out; } int k = alpha.ncol(); NumericMatrix x(n, k); bool throw_warning = false; if (k < 2) Rcpp::stop("Number of columns in alpha should be >= 2"); double size_left, row_sum, sum_p, p_tmp, sum_alpha; bool wrong_values; for (int i = 0; i < n; i++) { size_left = GETV(size, i); row_sum = 0.0; wrong_values = false; NumericVector pi(k); sum_alpha = 0.0; for (int j = 0; j < k; j++) { sum_alpha += GETM(alpha, i, j); if (GETM(alpha, i, j) <= 0.0) { wrong_values = true; break; } pi[j] = R::rgamma(GETM(alpha, i, j), 1.0); row_sum += pi[j]; } if (wrong_values || ISNAN(sum_alpha + GETV(size, i)) || GETV(size, i) < 0.0 || !isInteger(GETV(size, i), false)) { throw_warning = true; for (int j = 0; j < k; j++) x(i, j) = NA_REAL; continue; } if (GETV(size, i) == 0.0) { for (int j = 0; j < k; j++) x(i, j) = 0.0; continue; } sum_p = 1.0; for (int j = 0; j < k-1; j++) { if ( size_left > 0.0 ) { p_tmp = pi[j] / row_sum; x(i, j) = R::rbinom(size_left, trunc_p(p_tmp/sum_p)); size_left -= x(i, j); sum_p -= p_tmp; } else { break; } } x(i, k-1) = size_left; } if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/tuckey-lambda-distribution.cpp0000755000176200001440000000461514475546572021171 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* Joiner, B.L., & Rosenblatt, J.R. (1971). Some properties of the range in samples from Tukey's symmetric lambda distributions. Journal of the American Statistical Association, 66(334), 394-399. Hastings Jr, C., Mosteller, F., Tukey, J.W., & Winsor, C.P. (1947). Low moments for small samples: a comparative study of order statistics. The Annals of Mathematical Statistics, 413-426. */ inline double invcdf_tlambda(double p, double lambda, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(lambda)) return p+lambda; #endif if (!VALID_PROB(p)) { throw_warning = true; return NAN; } if (lambda == 0.0) return log(p) - log(1.0 - p); return (pow(p, lambda) - pow(1.0 - p, lambda))/lambda; } inline double rng_tlambda(double lambda, bool& throw_warning) { if (ISNAN(lambda)) { throw_warning = true; return NA_REAL; } double u = rng_unif(); if (lambda == 0.0) return log(u) - log(1.0 - u); return (pow(u, lambda) - pow(1.0 - u, lambda))/lambda; } // [[Rcpp::export]] NumericVector cpp_qtlambda( const NumericVector& p, const NumericVector& lambda, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), lambda.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), lambda.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_tlambda(GETV(pp, i), GETV(lambda, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rtlambda( const int& n, const NumericVector& lambda ) { if (lambda.length() < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_tlambda(GETV(lambda, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/bhattacharjee-distribution.cpp0000755000176200001440000001040614475546572021227 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Bhattacharjee distribution * * Parameters: * mu * sigma >= 0 * a >= 0 * * Bhattacharjee, G.P., Pandit, S.N.N., and Mohan, R. (1963). * Dimensional chains involving rectangular and normal error-distributions. * Technometrics, 5, 404-406. * */ inline double G(double x) { return x * Phi(x) + phi(x); } inline double pdf_bhattacharjee(double x, double mu, double sigma, double a, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma) || ISNAN(a)) return x+mu+sigma+a; #endif if (sigma < 0.0 || a < 0.0) { throw_warning = true; return NAN; } if (sigma == 0.0) return R::dunif(x, mu-a, mu+a, false); if (a == 0.0) return R::dnorm(x, mu, sigma, false); double z = x-mu; return (Phi((z+a)/sigma) - Phi((z-a)/sigma)) / (2.0*a); } inline double cdf_bhattacharjee(double x, double mu, double sigma, double a, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma) || ISNAN(a)) return x+mu+sigma+a; #endif if (sigma < 0.0 || a < 0.0) { throw_warning = true; return NAN; } if (x == R_NegInf) return 0.0; if (x == R_PosInf) return 1.0; if (sigma == 0.0) return R::punif(x, mu-a, mu+a, true, false); if (a == 0.0) return R::pnorm(x, mu, sigma, true, false); double z = x-mu; return sigma/(2.0*a) * (G((z+a)/sigma) - G((z-a)/sigma)); } inline double rng_bhattacharjee(double mu, double sigma, double a, bool& throw_warning) { if (ISNAN(mu) || ISNAN(sigma) || ISNAN(a) || sigma < 0.0 || a < 0.0) { throw_warning = true; return NA_REAL; } if (sigma == 0.0) return R::runif(mu-a, mu+a); if (a == 0.0) return R::rnorm(mu, sigma); return R::runif(-a, a) + R::norm_rand() * sigma + mu; } // [[Rcpp::export]] NumericVector cpp_dbhatt( const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& a, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), sigma.length(), a.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), sigma.length(), a.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pdf_bhattacharjee(GETV(x, i), GETV(mu, i), GETV(sigma, i), GETV(a, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pbhatt( const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& a, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), sigma.length(), a.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), sigma.length(), a.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_bhattacharjee(GETV(x, i), GETV(mu, i), GETV(sigma, i), GETV(a, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_rbhatt( const int& n, const NumericVector& mu, const NumericVector& sigma, const NumericVector& a ) { if (std::min({mu.length(), sigma.length(), a.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_bhattacharjee(GETV(mu, i), GETV(sigma, i), GETV(a, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/zero-inflated-negative-binomial-distribution.cpp0000755000176200001440000001217714475546572024604 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using std::log1p; inline double pdf_zinb(double x, double r, double p, double pi, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(r) || ISNAN(p) || ISNAN(pi)) return x+r+p+pi; #endif if (!VALID_PROB(p) || r < 0.0 || !VALID_PROB(pi)) { throw_warning = true; return NAN; } if (x < 0.0 || !isInteger(x) || !R_FINITE(x)) return 0.0; if (x == 0.0) { // pi + (1.0-pi) * pow(p, r); return pi + exp(log1p(-pi) + log(p) * r); } else { // (1.0-pi) * R::dnbinom(x, r, p, false); return exp(log1p(-pi) + R::dnbinom(x, r, p, true)); } } inline double cdf_zinb(double x, double r, double p, double pi, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(r) || ISNAN(p) || ISNAN(pi)) return x+r+p+pi; #endif if (!VALID_PROB(p) || r < 0.0 || !VALID_PROB(pi)) { throw_warning = true; return NAN; } if (x < 0.0) return 0.0; if (!R_FINITE(x)) return 1.0; // pi + (1.0-pi) * R::pnbinom(x, r, p, true, false); return pi + exp(log1p(-pi) + R::pnbinom(x, r, p, true, true)); } inline double invcdf_zinb(double pp, double r, double p, double pi, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(pp) || ISNAN(r) || ISNAN(p) || ISNAN(pi)) return pp+r+p+pi; #endif if (!VALID_PROB(p) || r < 0.0 || !VALID_PROB(pi) || !VALID_PROB(pp)) { throw_warning = true; return NAN; } if (pp < pi) return 0.0; else return R::qnbinom((pp - pi) / (1.0-pi), r, p, true, false); } inline double rng_zinb(double r, double p, double pi, bool& throw_warning) { if (ISNAN(r) || ISNAN(p) || ISNAN(pi) || !VALID_PROB(p) || r < 0.0 || !VALID_PROB(pi)) { throw_warning = true; return NA_REAL; } double u = rng_unif(); if (u < pi) return 0.0; else return R::rnbinom(r, p); } // [[Rcpp::export]] NumericVector cpp_dzinb( const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& log_prob = false ) { if (std::min({x.length(), size.length(), prob.length(), pi.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), size.length(), prob.length(), pi.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pdf_zinb(GETV(x, i), GETV(size, i), GETV(prob, i), GETV(pi, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pzinb( const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), size.length(), prob.length(), pi.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), size.length(), prob.length(), pi.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_zinb(GETV(x, i), GETV(size, i), GETV(prob, i), GETV(pi, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qzinb( const NumericVector& p, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), size.length(), prob.length(), pi.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), size.length(), prob.length(), pi.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) x[i] = invcdf_zinb(GETV(pp, i), GETV(size, i), GETV(prob, i), GETV(pi, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rzinb( const int& n, const NumericVector& size, const NumericVector& prob, const NumericVector& pi ) { if (std::min({size.length(), prob.length(), pi.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_zinb(GETV(size, i), GETV(prob, i), GETV(pi, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/slash-distribution.cpp0000755000176200001440000000640614475546572017561 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Location-scale slash distribution * * Parameters: * mu * sigma > 0 * * */ inline double pdf_slash(double x, double mu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma)) return x+mu+sigma; #endif if (sigma <= 0.0) { throw_warning = true; return NAN; } double z = (x - mu)/sigma; if (z == 0.0) return 0.19947114020071635; // 1.0/(2.0 * SQRT_2_PI); return ((PHI_0 - phi(z))/(z*z))/sigma; } inline double cdf_slash(double x, double mu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma)) return x+mu+sigma; #endif if (sigma <= 0.0) { throw_warning = true; return NAN; } double z = (x - mu)/sigma; if (z == 0.0) return 0.5; return Phi(z) - (PHI_0 - phi(z))/z; } inline double rng_slash(double mu, double sigma, bool& throw_warning) { if (ISNAN(mu) || ISNAN(sigma) || sigma <= 0.0) { throw_warning = true; return NA_REAL; } double z = R::norm_rand(); double u = rng_unif(); return z/u*sigma + mu; } // [[Rcpp::export]] NumericVector cpp_dslash( const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pdf_slash(GETV(x, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pslash( const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), mu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), mu.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_slash(GETV(x, i), GETV(mu, i), GETV(sigma, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_rslash( const int& n, const NumericVector& mu, const NumericVector& sigma ) { if (std::min({mu.length(), sigma.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_slash(GETV(mu, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/multivariate-hypergeometric-distribution.cpp0000755000176200001440000001036314475546572024176 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using Rcpp::NumericMatrix; /* * Multivariate hypergeometric distribution * * n[i] number of marbels from i-th category * N = sum(n) total number of marbels * x[i] number of marbles of i-th category drawn * k = sum(x) number of marbles to be drawn * * where k <= N and x[i] <= n[i] * * f(x) = prod(choose(n, x)) / choose(N, k) * */ // [[Rcpp::export]] NumericVector cpp_dmvhyper( const NumericMatrix& x, const NumericMatrix& n, const NumericVector& k, const bool& log_prob = false ) { if (std::min({static_cast(x.nrow()), static_cast(x.ncol()), static_cast(n.nrow()), static_cast(n.ncol()), static_cast(k.length())}) < 1) { return NumericVector(0); } int Nmax = std::max({ static_cast(x.nrow()), static_cast(n.nrow()), static_cast(k.length()) }); int m = x.ncol(); NumericVector p(Nmax); bool throw_warning = false; if (m != n.ncol()) Rcpp::stop("number of columns in x does not equal number of columns in n"); bool wrong_n, wrong_x; double lNck, sum_x, lncx_prod, n_tot; for (int i = 0; i < Nmax; i++) { wrong_x = false; wrong_n = false; sum_x = 0.0; lncx_prod = 0.0; n_tot = 0.0; for (int j = 0; j < m; j++) { if (!isInteger(GETM(n, i, j), false) || GETM(n, i, j) < 0.0) wrong_n = true; sum_x += GETM(x, i, j); n_tot += GETM(n, i, j); } #ifdef IEEE_754 if (ISNAN(sum_x + n_tot + GETV(k, i))) { p[i] = sum_x + n_tot + GETV(k, i); continue; } #endif if (wrong_n || GETV(k, i) < 0.0 || GETV(k, i) > n_tot || !isInteger(GETV(k, i), false)) { throw_warning = true; p[i] = NAN; continue; } for (int j = 0; j < m; j++) { if (GETM(x, i, j) > GETM(n, i, j) || GETM(x, i, j) < 0.0 || !isInteger(GETM(x, i, j))) { wrong_x = true; } else { lncx_prod += R::lchoose(GETM(n, i, j), GETM(x, i, j)); } } if (wrong_x || sum_x != GETV(k, i)) { p[i] = R_NegInf; } else { lNck = R::lchoose(n_tot, GETV(k, i)); p[i] = lncx_prod - lNck; } } if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericMatrix cpp_rmvhyper( const int& nn, const NumericMatrix& n, const NumericVector& k ) { if (std::min({static_cast(n.nrow()), static_cast(n.ncol()), static_cast(k.length())}) < 1) { Rcpp::warning("NAs produced"); NumericMatrix out(nn, n.ncol()); std::fill(out.begin(), out.end(), NA_REAL); return out; } int m = n.ncol(); NumericMatrix x(nn, m); std::vector n_otr(m); bool wrong_values; double k_left; bool throw_warning = false; for (int i = 0; i < nn; i++) { wrong_values = false; n_otr[0] = 0.0; for (int j = 1; j < m; j++) { if (!isInteger(GETM(n, i, j), false) || GETM(n, i, j) < 0.0 || ISNAN(GETM(n, i, j))) { wrong_values = true; break; } n_otr[0] += GETM(n, i, j); } if (wrong_values || ISNAN(GETV(k, i)) || ISNAN(GETM(n, i, 0)) || !isInteger(GETM(n, i, 0), false) || GETM(n, i, 0) < 0 || (n_otr[0] + GETM(n, i, 0)) < GETV(k, i) || !isInteger(GETV(k, i), false) || GETV(k, i) < 0.0) { throw_warning = true; for (int j = 0; j < m; j++) x(i, j) = NA_REAL; continue; } for (int j = 1; j < m; j++) n_otr[j] = n_otr[j-1] - GETM(n, i, j); k_left = GETV(k, i); x(i, 0) = R::rhyper(GETM(n, i, 0), n_otr[0], k_left); k_left -= x(i, 0); if (m > 2) { for (int j = 1; j < m-1; j++) { x(i, j) = R::rhyper(GETM(n, i, j), n_otr[j], k_left); k_left -= x(i, j); } } x(i, m-1) = k_left; } if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/gompertz-distribution.cpp0000755000176200001440000001107514475546572020314 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Gompertz distribution * * Values: * x >= 0 * * Parameters: * a > 0 * b > 0 * * f(x) = a*exp(b*x - a/b * (exp(bx)-1)) * F(x) = 1-exp(-a/b * (exp(bx)-1)) * F^-1(p) = 1/b * log(1 - b/a * log(1-p)) * * References: * * Lenart, A. (2012). The Gompertz distribution and Maximum Likelihood Estimation * of its parameters - a revision. MPIDR WORKING PAPER WP 2012-008. * */ inline double logpdf_gompertz(double x, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(a) || ISNAN(b)) return x+a+b; #endif if (a <= 0.0 || b <= 0.0) { throw_warning = true; return NAN; } if (x < 0.0 || !R_FINITE(x)) return R_NegInf; // a * exp(b*x - a/b * (exp(b*x) - 1.0)); return log(a) + (b*x - a/b * (exp(b*x) - 1.0)); } inline double cdf_gompertz(double x, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(a) || ISNAN(b)) return x+a+b; #endif if (a <= 0.0 || b <= 0.0) { throw_warning = true; return NAN; } if (x < 0.0) return 0.0; if (!R_FINITE(x)) return 1.0; return 1.0 - exp(-a/b * (exp(b*x) - 1.0)); } inline double invcdf_gompertz(double p, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(a) || ISNAN(b)) return p+a+b; #endif if (a <= 0.0 || b <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } return log(1.0 - b/a * log(1.0-p)) / b; } inline double rng_gompertz(double a, double b, bool& throw_warning) { if (ISNAN(a) || ISNAN(b) || a <= 0.0 || b <= 0.0) { throw_warning = true; return NA_REAL; } double u = rng_unif(); return log(1.0 - b/a * log(u)) / b; } // [[Rcpp::export]] NumericVector cpp_dgompertz( const NumericVector& x, const NumericVector& a, const NumericVector& b, bool log_prob = false ) { if (std::min({x.length(), a.length(), b.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), a.length(), b.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_gompertz(GETV(x, i), GETV(a, i), GETV(b, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pgompertz( const NumericVector& x, const NumericVector& a, const NumericVector& b, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), a.length(), b.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), a.length(), b.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_gompertz(GETV(x, i), GETV(a, i), GETV(b, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qgompertz( const NumericVector& p, const NumericVector& a, const NumericVector& b, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), a.length(), b.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), a.length(), b.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_gompertz(GETV(pp, i), GETV(a, i), GETV(b, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rgompertz( const int& n, const NumericVector& a, const NumericVector& b ) { if (std::min({a.length(), b.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_gompertz(GETV(a, i), GETV(b, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/truncated-binomial-distribution.cpp0000755000176200001440000001417514475546572022232 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; inline double logpdf_tbinom(double x, double size, double prob, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(size) || ISNAN(prob) || ISNAN(a) || ISNAN(b)) return x+size+prob+a+b; #endif if (size < 0.0 || !VALID_PROB(prob) || b < a || !isInteger(size, false)) { throw_warning = true; return NAN; } if (!isInteger(x) || x < 0.0 || x <= a || x > b || x > size) return R_NegInf; double pa, pb; pa = R::pbinom(a, size, prob, true, false); pb = R::pbinom(b, size, prob, true, false); return R::dbinom(x, size, prob, true) - log(pb-pa); } inline double cdf_tbinom(double x, double size, double prob, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(size) || ISNAN(prob) || ISNAN(a) || ISNAN(b)) return x+size+prob+a+b; #endif if (size < 0.0 || !VALID_PROB(prob) || b < a || !isInteger(size, false)) { throw_warning = true; return NAN; } if (x < 0.0 || x <= a) return 0.0; if (x > b || x >= size) return 1.0; double pa, pb; pa = R::pbinom(a, size, prob, true, false); pb = R::pbinom(b, size, prob, true, false); return (R::pbinom(x, size, prob, true, false) - pa) / (pb-pa); } inline double invcdf_tbinom(double p, double size, double prob, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(size) || ISNAN(prob) || ISNAN(a) || ISNAN(b)) return p+size+prob+a+b; #endif if (size < 0.0 || !VALID_PROB(prob) || b < a || !isInteger(size, false) || !VALID_PROB(p)) { throw_warning = true; return NAN; } if (p == 0.0) return std::max(a, 0.0); if (p == 1.0) return std::min(size, b); double pa, pb; pa = R::pbinom(a, size, prob, true, false); pb = R::pbinom(b, size, prob, true, false); return R::qbinom(pa + p*(pb-pa), size, prob, true, false); } inline double rng_tbinom(double size, double prob, double a, double b, bool& throw_warning) { if (ISNAN(size) || ISNAN(prob) || ISNAN(a) || ISNAN(b) || size < 0.0 || !VALID_PROB(prob) || b < a || !isInteger(size, false)) { throw_warning = true; return NA_REAL; } double u, pa, pb; pa = R::pbinom(a, size, prob, true, false); pb = R::pbinom(b, size, prob, true, false); u = R::runif(pa, pb); return R::qbinom(u, size, prob, true, false); } // [[Rcpp::export]] NumericVector cpp_dtbinom( const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& lower, const NumericVector& upper, const bool& log_prob = false ) { if (std::min({x.length(), size.length(), prob.length(), lower.length(), upper.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), size.length(), prob.length(), lower.length(), upper.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_tbinom(GETV(x, i), GETV(size, i), GETV(prob, i), GETV(lower, i), GETV(upper, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_ptbinom( const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), size.length(), prob.length(), lower.length(), upper.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), size.length(), prob.length(), lower.length(), upper.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_tbinom(GETV(x, i), GETV(size, i), GETV(prob, i), GETV(lower, i), GETV(upper, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qtbinom( const NumericVector& p, const NumericVector& size, const NumericVector& prob, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), size.length(), prob.length(), lower.length(), upper.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), size.length(), prob.length(), lower.length(), upper.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) x[i] = invcdf_tbinom(GETV(pp, i), GETV(size, i), GETV(prob, i), GETV(lower, i), GETV(upper, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rtbinom( const int& n, const NumericVector& size, const NumericVector& prob, const NumericVector& lower, const NumericVector& upper ) { if (std::min({size.length(), prob.length(), lower.length(), upper.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_tbinom(GETV(size, i), GETV(prob, i), GETV(lower, i), GETV(upper, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/shifted-gompertz-distribution.cpp0000755000176200001440000001031314475546572021732 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Gompertz distribution * * Values: * x >= 0 * * Parameters: * b > 0 * eta > 0 * * f(x) = b*exp(-b*x) * exp(-eta*exp(-b*x)) * (1 + eta*(1 - exp(-b*x))) * F(x) = (1-exp(-b*x)) * exp(-eta*exp(-b*x)) * * References: * * Bemmaor, A.C. (1994). * Modeling the Diffusion of New Durable Goods: Word-of-Mouth Effect Versus Consumer Heterogeneity. * [In:] G. Laurent, G.L. Lilien & B. Pras. Research Traditions in Marketing. * Boston: Kluwer Academic Publishers. pp. 201-223. * * Jimenez, T.F., Jodra, P. (2009). * A Note on the Moments and Computer Generation of the Shifted Gompertz Distribution. * Communications in Statistics - Theory and Methods, 38(1), 78-89. * * Jimenez T.F. (2014). * Estimation of the Parameters of the Shifted Gompertz Distribution, * Using Least Squares, Maximum Likelihood and Moments Methods. * Journal of Computational and Applied Mathematics, 255(1), 867-877. * */ inline double logpdf_sgomp(double x, double b, double eta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(b) || ISNAN(eta)) return x+b+eta; #endif if (b <= 0.0 || eta <= 0.0) { throw_warning = true; return NAN; } if (x < 0.0 || !R_FINITE(x)) return R_NegInf; double ebx = exp(-b*x); // b*ebx * exp(-eta*ebx) * (1+eta*(1-ebx)); return log(b) + log(ebx) - eta*ebx + log1p(eta*(1-ebx)); } inline double cdf_sgomp(double x, double b, double eta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(b) || ISNAN(eta)) return x+b+eta; #endif if (b <= 0.0 || eta <= 0.0) { throw_warning = true; return NAN; } if (x < 0.0) return 0.0; if (x == R_PosInf) return 1.0; double ebx = exp(-b*x); // (1-ebx) * exp(-eta*ebx) return exp(log1p(-ebx) - eta*ebx); } inline double rng_sgomp(double b, double eta, bool& throw_warning) { if (ISNAN(b) || ISNAN(eta) || b <= 0.0 || eta <= 0.0) { throw_warning = true; return NA_REAL; } double u, v, rg, re; u = R::exp_rand(); // -log(rng_unif()) v = R::exp_rand(); // -log(rng_unif()) rg = -log(u/eta) / b; re = v / b; return (rg>re) ? rg : re; } // [[Rcpp::export]] NumericVector cpp_dsgomp( const NumericVector& x, const NumericVector& b, const NumericVector& eta, bool log_prob = false ) { if (std::min({x.length(), b.length(), eta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), b.length(), eta.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_sgomp(GETV(x, i), GETV(b, i), GETV(eta, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_psgomp( const NumericVector& x, const NumericVector& b, const NumericVector& eta, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), b.length(), eta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), b.length(), eta.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_sgomp(GETV(x, i), GETV(b, i), GETV(eta, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_rsgomp( const int& n, const NumericVector& b, const NumericVector& eta ) { if (std::min({b.length(), eta.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_sgomp(GETV(b, i), GETV(eta, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/beta-negative-binomial-distribution.cpp0000755000176200001440000001412414475546572022746 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Beta-negative binomial distribution * * Values: * x * * Parameters: * r > 0 * alpha > 0 * beta > 0 * * f(k) = gamma(r+k)/(k! gamma(r)) * beta(alpha+r, beta+k)/beta(alpha, beta) * */ inline double logpmf_bnbinom(double k, double r, double alpha, double beta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(k) || ISNAN(r) || ISNAN(alpha) || ISNAN(beta)) return k+r+alpha+beta; #endif if (alpha <= 0.0 || beta <= 0.0 || r < 0.0) { throw_warning = true; return NAN; } if (!isInteger(k) || k < 0.0 || !R_FINITE(k)) return R_NegInf; // (R::gammafn(r+k) / (R::gammafn(k+1.0) * R::gammafn(r))) * // R::beta(alpha+r, beta+k) / R::beta(alpha, beta); return (R::lgammafn(r+k) - R::lgammafn(k+1.0) - R::lgammafn(r)) + R::lbeta(alpha+r, beta+k) - R::lbeta(alpha, beta); } inline std::vector cdf_bnbinom_table(double k, double r, double alpha, double beta) { if (k < 0.0 || !R_FINITE(k) || r < 0.0 || alpha < 0.0 || beta < 0.0) Rcpp::stop("inadmissible values"); int ik = to_pos_int(k); std::vector p_tab(ik+1); double grx, xf, gr, gar, gbx, gabrx, bab; bab = R::lbeta(alpha, beta); gr = R::lgammafn(r); gar = R::lgammafn(alpha + r); xf = 0.0; // k < 1 grx = gr; gbx = R::lgammafn(beta); gabrx = R::lgammafn(alpha + beta + r); p_tab[0] = exp(grx - gr + gar + gbx - gabrx - bab); if (ik < 1) return p_tab; // k < 2 grx += log(r); gbx += log(beta); gabrx += log(alpha + beta + r); p_tab[1] = p_tab[0] + exp(grx - gr + gar + gbx - gabrx - bab); if (ik < 2) return p_tab; // k >= 2 double dj; for (int j = 2; j <= ik; j++) { if (j % 10000 == 0) Rcpp::checkUserInterrupt(); dj = to_dbl(j); grx += log(r + dj - 1.0); gbx += log(beta + dj - 1.0); gabrx += log(alpha + beta + r + dj - 1.0); xf += log(dj); p_tab[j] = p_tab[j-1] + exp(grx - (xf + gr) + gar + gbx - gabrx - bab); } return p_tab; } inline double rng_bnbinom(double r, double alpha, double beta, bool& throw_warning) { if (ISNAN(r) || ISNAN(alpha) || ISNAN(beta) || alpha <= 0.0 || beta <= 0.0 || r < 0.0) { throw_warning = true; return NA_REAL; } double prob = R::rbeta(alpha, beta); return R::rnbinom(r, prob); } // [[Rcpp::export]] NumericVector cpp_dbnbinom( const NumericVector& x, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta, const bool& log_prob = false ) { if (std::min({x.length(), size.length(), alpha.length(), beta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), size.length(), alpha.length(), beta.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpmf_bnbinom(GETV(x, i), GETV(size, i), GETV(alpha, i), GETV(beta, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pbnbinom( const NumericVector& x, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), size.length(), alpha.length(), beta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), size.length(), alpha.length(), beta.length() }); NumericVector p(Nmax); bool throw_warning = false; std::map, std::vector> memo; // maximum modulo size.length(), > 0 int n = x.length(); int k = size.length(); NumericVector mx(k, 0.0); for (int i = 0; i < std::max(n, k); i++) { double xi = GETV(x, i); if (mx[i % k] < xi && R_FINITE(xi)) { mx[i % k] = xi; } } for (int i = 0; i < Nmax; i++) { if (i % 100 == 0) Rcpp::checkUserInterrupt(); #ifdef IEEE_754 if (ISNAN(GETV(x, i)) || ISNAN(GETV(size, i)) || ISNAN(GETV(alpha, i)) || ISNAN(GETV(beta, i))) { p[i] = GETV(x, i) + GETV(size, i) + GETV(alpha, i) + GETV(beta, i); continue; } #endif if (GETV(alpha, i) <= 0.0 || GETV(beta, i) <= 0.0 || GETV(size, i) < 0.0) { throw_warning = true; p[i] = NAN; } else if (GETV(x, i) < 0.0) { p[i] = 0.0; } else if (!R_FINITE(GETV(x, i))) { p[i] = 1.0; } else if (is_large_int(GETV(x, i))) { p[i] = NA_REAL; Rcpp::warning("NAs introduced by coercion to integer range"); } else { std::vector& tmp = memo[std::make_tuple( static_cast(i % size.length()), static_cast(i % alpha.length()), static_cast(i % beta.length()) )]; if (!tmp.size()) { //double mxi = std::min(mx[i % size.length()], GETV(size, i)); tmp = cdf_bnbinom_table(mx[i % size.length()], GETV(size, i), GETV(alpha, i), GETV(beta, i)); } p[i] = tmp[to_pos_int(GETV(x, i))]; } } if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_rbnbinom( const int& n, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta ) { if (std::min({size.length(), alpha.length(), beta.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_bnbinom(GETV(size, i), GETV(alpha, i), GETV(beta, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/triangular-distribution.cpp0000755000176200001440000001326114475546572020614 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Triangular distribution * * Values: * x * * Parameters: * a * b > a * a <= c <= b * * f(x) = { (2*(x-a)) / ((b-a)*(c-a)) x < c * { 2/(b-a) x = c * { (2*(b-x)) / ((b-a)*(b-c)) x > c * F(x) = { (x-a)^2 / ((b-a)*(c-a)) * { 1 - ((b-x)^2 / ((b-a)*(b-c))) * F^-1(p) = { a + sqrt(p*(b-a)*(c-a)) p < (c-a)/(b-a) * { b - sqrt((1-p)*(b-a)*(b-c)); */ inline double logpdf_triangular(double x, double a, double b, double c, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(a) || ISNAN(b) || ISNAN(c)) return x+a+b+c; #endif if (a > c || c > b || a == b) { throw_warning = true; return NAN; } if (x < a || x > b) { return R_NegInf; } else if (x < c) { // 2.0*(x-a) / ((b-a)*(c-a)); return LOG_2F + log(x-a) - log(b-a) - log(c-a); } else if (x > c) { // 2.0*(b-x) / ((b-a)*(b-c)); return LOG_2F + log(b-x) - log(b-a) - log(b-c); } else { // 2.0/(b-a); return LOG_2F - log(b-a); } } inline double cdf_triangular(double x, double a, double b, double c, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(a) || ISNAN(b) || ISNAN(c)) return x+a+b+c; #endif if (a > c || c > b || a == b) { throw_warning = true; return NAN; } if (x < a) { return 0.0; } else if (x >= b) { return 1.0; } else if (x <= c) { // ((x-a)*(x-a)) / ((b-a)*(c-a)); return exp( log(x-a) * 2.0 - log(b-a) - log(c-a) ); } else { // 1.0 - (((b-x)*(b-x)) / ((b-a)*(b-c))); return 1.0 - exp( log(b-x) * 2.0 - log(b-a) - log(b-c) ); } } inline double invcdf_triangular(double p, double a, double b, double c, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(a) || ISNAN(b) || ISNAN(c)) return p+a+b+c; #endif if (a > c || c > b || a == b || !VALID_PROB(p)) { throw_warning = true; return NAN; } double fc = (c-a)/(b-a); if (p < fc) return a + sqrt(p*(b-a)*(c-a)); return b - sqrt((1.0-p)*(b-a)*(b-c)); } inline double rng_triangular(double a, double b, double c, bool& throw_warning) { if (ISNAN(a) || ISNAN(b) || ISNAN(c) || a > c || c > b || a == b) { throw_warning = true; return NA_REAL; } double u, v, r, cc; r = b - a; cc = (c-a)/r; u = rng_unif(); v = rng_unif(); return ((1.0-cc) * std::min(u, v) + cc * std::max(u, v)) * r + a; } // [[Rcpp::export]] NumericVector cpp_dtriang( const NumericVector& x, const NumericVector& a, const NumericVector& b, const NumericVector& c, const bool& log_prob = false ) { if (std::min({x.length(), a.length(), b.length(), c.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), a.length(), b.length(), c.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_triangular(GETV(x, i), GETV(a, i), GETV(b, i), GETV(c, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_ptriang( const NumericVector& x, const NumericVector& a, const NumericVector& b, const NumericVector& c, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), a.length(), b.length(), c.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), a.length(), b.length(), c.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_triangular(GETV(x, i), GETV(a, i), GETV(b, i), GETV(c, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qtriang( const NumericVector& p, const NumericVector& a, const NumericVector& b, const NumericVector& c, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), a.length(), b.length(), c.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), a.length(), b.length(), c.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) x[i] = invcdf_triangular(GETV(pp, i), GETV(a, i), GETV(b, i), GETV(c, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rtriang( const int& n, const NumericVector& a, const NumericVector& b, const NumericVector& c ) { if (std::min({a.length(), b.length(), c.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_triangular(GETV(a, i), GETV(b, i), GETV(c, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/half-t-distribution.cpp0000755000176200001440000001046214475546572017617 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * * x >= 0 * * Parameters: * nu > 0 * sigma > 0 * * with nu = 1 returns half-Cauchy * with nu = Inf returns half-normal * */ inline double logpdf_ht(double x, double nu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(nu) || ISNAN(sigma)) return x+nu+sigma; #endif if (sigma <= 0.0 || nu <= 0.0) { throw_warning = true; return NAN; } if (x < 0.0) return R_NegInf; return LOG_2F + R::dt(x/sigma, nu, true) - log(sigma); } inline double cdf_ht(double x, double nu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(nu) || ISNAN(sigma)) return x+nu+sigma; #endif if (sigma <= 0.0 || nu <= 0.0) { throw_warning = true; return NAN; } if (x < 0.0) return 0.0; return 2.0 * R::pt(x/sigma, nu, true, false) - 1.0; } inline double invcdf_ht(double p, double nu, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(nu) || ISNAN(sigma)) return p+nu+sigma; #endif if (sigma <= 0.0 || nu <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } return R::qt((p+1.0)/2.0, nu, true, false) * sigma; } inline double rng_ht(double nu, double sigma, bool& throw_warning) { if (ISNAN(nu) || ISNAN(sigma) || sigma <= 0.0 || nu <= 0.0) { throw_warning = true; return NA_REAL; } return abs(R::rt(nu) * sigma); } // [[Rcpp::export]] NumericVector cpp_dht( const NumericVector& x, const NumericVector& nu, const NumericVector& sigma, const bool& log_prob = false ) { if (std::min({x.length(), nu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), nu.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_ht(GETV(x, i), GETV(nu, i), GETV(sigma, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pht( const NumericVector& x, const NumericVector& nu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), nu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), nu.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_ht(GETV(x, i), GETV(nu, i), GETV(sigma, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qht( const NumericVector& p, const NumericVector& nu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), nu.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), nu.length(), sigma.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_ht(GETV(pp, i), GETV(nu, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rht( const int& n, const NumericVector& nu, const NumericVector& sigma ) { if (std::min({nu.length(), sigma.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_ht(GETV(nu, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/dirichlet-distribution.cpp0000755000176200001440000000670114475546572020414 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using Rcpp::NumericMatrix; /* * Dirichlet distribution * * Values: * x * * Parameters: * alpha > 0 (R^k where k >= 2) * * f(x) = Gamma(sum(alpha)) / prod(Gamma(alpha)) * prod_k x[k]^{k-1} * */ // [[Rcpp::export]] NumericVector cpp_ddirichlet( const NumericMatrix& x, const NumericMatrix& alpha, const bool& log_prob = false ) { if (std::min({x.nrow(), x.ncol(), alpha.nrow(), alpha.ncol()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.nrow(), alpha.nrow() }); int m = x.ncol(); int k = alpha.ncol(); k = std::min(m, k); NumericVector p(Nmax); bool throw_warning = false; if (k < 2) Rcpp::stop("number of columns in alpha should be >= 2"); if (m != k) Rcpp::stop("number of columns in x does not equal number of columns in alpha"); double prod_gamma, sum_alpha, p_tmp, beta_const, sum_x; bool wrong_alpha, wrong_x; for (int i = 0; i < Nmax; i++) { wrong_alpha = false; wrong_x = false; sum_alpha = 0.0; sum_x = 0.0; for (int j = 0; j < m; j++) { sum_alpha += GETM(alpha, i, j); sum_x += GETM(x, i, j); if (GETM(alpha, i, j) <= 0.0) wrong_alpha = true; if (GETM(x, i, j) < 0.0 || GETM(x, i, j) > 1.0) wrong_x = true; } #ifdef IEEE_754 if (ISNAN(sum_x + sum_alpha)) { p[i] = sum_x + sum_alpha; continue; } #endif if (wrong_alpha) { throw_warning = true; p[i] = NAN; } else if (wrong_x) { p[i] = R_NegInf; } else { prod_gamma = 0.0; p_tmp = 0.0; for (int j = 0; j < m; j++) { prod_gamma += R::lgammafn(GETM(alpha, i, j)); p_tmp += log(GETM(x, i, j)) * (GETM(alpha, i, j) - 1.0); if (GETM(alpha, i, j) == 1.0 && GETM(x, i, j) == 0.0) p_tmp = R_NegInf; } beta_const = prod_gamma - R::lgammafn(sum_alpha); p[i] = p_tmp - beta_const; } } if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericMatrix cpp_rdirichlet( const int& n, const NumericMatrix& alpha ) { if (std::min({alpha.nrow(), alpha.ncol()}) < 1) { Rcpp::warning("NAs produced"); NumericMatrix out(n, alpha.ncol()); std::fill(out.begin(), out.end(), NA_REAL); return out; } int k = alpha.ncol(); NumericMatrix x(n, k); bool throw_warning = false; if (k < 2) Rcpp::stop("number of columns in alpha should be >= 2"); double row_sum, sum_alpha; bool wrong_values; for (int i = 0; i < n; i++) { sum_alpha = 0.0; row_sum = 0.0; wrong_values = false; for (int j = 0; j < k; j++) { sum_alpha += GETM(alpha, i, j); if (GETM(alpha, i, j) <= 0.0) { wrong_values = true; break; } x(i, j) = R::rgamma(GETM(alpha, i, j), 1.0); row_sum += x(i, j); } if (ISNAN(sum_alpha) || wrong_values) { throw_warning = true; for (int j = 0; j < k; j++) x(i, j) = NA_REAL; } else { for (int j = 0; j < k; j++) x(i, j) /= row_sum; } } if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/gpd-distribution.cpp0000755000176200001440000001431114523122745017175 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using Rcpp::NumericVector; using std::abs; using std::ceil; using std::exp; using std::floor; using std::log; using std::pow; using std::sqrt; using std::log1p; /* * Generalized Pareto distribution * * Values: * x * * Parameters: * mu * sigma > 0 * xi * * z = (x-mu)/sigma * where 1+xi*z > 0 * * f(x) = { (1+xi*z)^{-(xi+1)/xi}/sigma if xi != 0 * { exp(-z)/sigma otherwise * F(x) = { 1-(1+xi*z)^{-1/xi} if xi != 0 * { 1-exp(-z) otherwise * F^-1(p) = { mu + sigma * ((1-p)^{-xi}-1)/xi if xi != 0 * { mu - sigma * log(1-p) otherwise * */ inline double logpdf_gpd(double x, double mu, double sigma, double xi, bool &throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma) || ISNAN(xi)) return x + mu + sigma + xi; #endif if (sigma <= 0.0) { throw_warning = true; return NAN; } double z = (x - mu) / sigma; if (xi != 0.0) { if (z > 0 && 1.0 + xi * z > 0.0) { // pow(1.0+xi*z, -(xi+1.0)/xi)/sigma; return log1p(xi * z) * (-(xi + 1.0) / xi) - log(sigma); } else { return R_NegInf; } } else { if (z > 0 && 1.0 + xi * z > 0.0) { // exp(-z)/sigma; return -z - log(sigma); } else { return R_NegInf; } } } inline double cdf_gpd(double x, double mu, double sigma, double xi, bool &throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(mu) || ISNAN(sigma) || ISNAN(xi)) return x + mu + sigma + xi; #endif if (sigma <= 0.0) { throw_warning = true; return NAN; } double z = (x - mu) / sigma; if (xi != 0.0) { if (z > 0 && 1.0 + xi * z > 0.0) { // 1.0 - pow(1.0+xi*z, -1.0/xi); return 1.0 - exp(log1p(xi * z) * (-1.0 / xi)); } else { if (z > 0 && z >= -1 / xi) return 1.0; else return 0.0; } } else { if (z > 0 && 1.0 + xi * z > 0.0) { return 1.0 - exp(-z); } else { if (z > 0 && z >= -1 / xi) return 1.0; else return 0.0; } } } inline double invcdf_gpd(double p, double mu, double sigma, double xi, bool &throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(mu) || ISNAN(sigma) || ISNAN(xi)) return p + mu + sigma + xi; #endif if (sigma <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } if (xi != 0.0) return mu + sigma * (pow(1.0 - p, -xi) - 1.0) / xi; else return mu - sigma * log(1.0 - p); } inline double rng_gpd(double mu, double sigma, double xi, bool &throw_warning) { if (ISNAN(mu) || ISNAN(sigma) || ISNAN(xi) || sigma <= 0.0) { throw_warning = true; return NA_REAL; } if (xi != 0.0) { double u = rng_unif(); return mu + sigma * (pow(u, -xi) - 1.0) / xi; } else { double v = R::exp_rand(); // -log(rng_unif()) return mu + sigma * v; } } // [[Rcpp::export]] NumericVector cpp_dgpd( const NumericVector &x, const NumericVector &mu, const NumericVector &sigma, const NumericVector &xi, const bool &log_prob = false) { if (std::min({x.length(), mu.length(), sigma.length(), xi.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({x.length(), mu.length(), sigma.length(), xi.length()}); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_gpd(GETV(x, i), GETV(mu, i), GETV(sigma, i), GETV(xi, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pgpd( const NumericVector &x, const NumericVector &mu, const NumericVector &sigma, const NumericVector &xi, const bool &lower_tail = true, const bool &log_prob = false) { if (std::min({x.length(), mu.length(), sigma.length(), xi.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({x.length(), mu.length(), sigma.length(), xi.length()}); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_gpd(GETV(x, i), GETV(mu, i), GETV(sigma, i), GETV(xi, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qgpd( const NumericVector &p, const NumericVector &mu, const NumericVector &sigma, const NumericVector &xi, const bool &lower_tail = true, const bool &log_prob = false) { if (std::min({p.length(), mu.length(), sigma.length(), xi.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({p.length(), mu.length(), sigma.length(), xi.length()}); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_gpd(GETV(pp, i), GETV(mu, i), GETV(sigma, i), GETV(xi, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rgpd( const int &n, const NumericVector &mu, const NumericVector &sigma, const NumericVector &xi) { if (std::min({mu.length(), sigma.length(), xi.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_gpd(GETV(mu, i), GETV(sigma, i), GETV(xi, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/negative-hypergeometric-distribution.cpp0000755000176200001440000002031414475546572023267 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; std::vector nhyper_table( double n, double m, double r, bool cumulative = false ) { if (n < 0.0 || m < 0.0 || r < 0.0 || r > m) Rcpp::stop("inadmissible values"); double j, N, start_eps; int ni = to_pos_int(n); N = m+n; std::vector t(ni), h(ni), p(ni+1); start_eps = 1e-200; h[0] = start_eps * r*n/(N-r); t[0] = start_eps + h[0]; for (int i = 1; i <= ni-1; i++) { j = to_dbl(i) + r; h[i] = h[i-1] * j*(n+r-j)/(N-j)/(j+1.0-r); t[i] = t[i-1] + h[i]; } p[0] = start_eps / t[ni-1]; if (cumulative) { for (int i = 1; i < ni; i++) p[i] = t[i-1] / t[ni-1]; p[ni] = 1.0; } else { for (int i = 1; i <= ni; i++) p[i] = h[i-1] / t[ni-1]; } return p; } // [[Rcpp::export]] NumericVector cpp_dnhyper( const NumericVector& x, const NumericVector& n, const NumericVector& m, const NumericVector& r, const bool& log_prob = false ) { if (std::min({x.length(), n.length(), m.length(), r.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), n.length(), m.length(), r.length() }); NumericVector p(Nmax); bool throw_warning = false; std::map, std::vector> memo; for (int i = 0; i < Nmax; i++) { if (i % 100 == 0) Rcpp::checkUserInterrupt(); #ifdef IEEE_754 if (ISNAN(GETV(x, i)) || ISNAN(GETV(n, i)) || ISNAN(GETV(m, i)) || ISNAN(GETV(r, i))) { p[i] = GETV(x, i) + GETV(n, i) + GETV(m, i) + GETV(r, i); continue; } #endif if (GETV(r, i) > GETV(m, i) || GETV(n, i) < 0.0 || GETV(m, i) < 0.0 || GETV(r, i) < 0.0 || !isInteger(GETV(n, i), false) || !isInteger(GETV(m, i), false) || !isInteger(GETV(r, i), false)) { throw_warning = true; p[i] = NAN; } else if (!isInteger(GETV(x, i)) || GETV(x, i) < GETV(r, i) || GETV(x, i) > (GETV(n, i) + GETV(r, i))) { p[i] = 0.0; } else if (is_large_int(GETV(x, i))) { p[i] = NA_REAL; Rcpp::warning("NAs introduced by coercion to integer range"); } else { std::vector& tmp = memo[std::make_tuple( static_cast(i % n.length()), static_cast(i % m.length()), static_cast(i % r.length()) )]; if (!tmp.size()) { tmp = nhyper_table(GETV(n, i), GETV(m, i), GETV(r, i), false); } p[i] = tmp[to_pos_int( GETV(x, i) - GETV(r, i) )]; } } if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pnhyper( const NumericVector& x, const NumericVector& n, const NumericVector& m, const NumericVector& r, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), n.length(), m.length(), r.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), n.length(), m.length(), r.length() }); NumericVector p(Nmax); bool throw_warning = false; std::map, std::vector> memo; for (int i = 0; i < Nmax; i++) { if (i % 100 == 0) Rcpp::checkUserInterrupt(); #ifdef IEEE_754 if (ISNAN(GETV(x, i)) || ISNAN(GETV(n, i)) || ISNAN(GETV(m, i)) || ISNAN(GETV(r, i))) { p[i] = GETV(x, i) + GETV(n, i) + GETV(m, i) + GETV(r, i); continue; } #endif if (GETV(r, i) > GETV(m, i) || GETV(n, i) < 0.0 || GETV(m, i) < 0.0 || GETV(r, i) < 0.0 || !isInteger(GETV(n, i), false) || !isInteger(GETV(m, i), false) || !isInteger(GETV(r, i), false)) { throw_warning = true; p[i] = NAN; } else if (GETV(x, i) < GETV(r, i)) { p[i] = 0.0; } else if (GETV(x, i) >= (GETV(n, i) + GETV(r, i))) { p[i] = 1.0; } else if (is_large_int(GETV(x, i))) { p[i] = NA_REAL; Rcpp::warning("NAs introduced by coercion to integer range"); } else { std::vector& tmp = memo[std::make_tuple( static_cast(i % n.length()), static_cast(i % m.length()), static_cast(i % r.length()) )]; if (!tmp.size()) { tmp = nhyper_table(GETV(n, i), GETV(m, i), GETV(r, i), true); } p[i] = tmp[to_pos_int( GETV(x, i) - GETV(r, i) )]; } } if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qnhyper( const NumericVector& p, const NumericVector& n, const NumericVector& m, const NumericVector& r, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), n.length(), m.length(), r.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), n.length(), m.length(), r.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; std::map, std::vector> memo; for (int i = 0; i < Nmax; i++) { if (i % 100 == 0) Rcpp::checkUserInterrupt(); #ifdef IEEE_754 if (ISNAN(GETV(pp, i)) || ISNAN(GETV(n, i)) || ISNAN(GETV(m, i)) || ISNAN(GETV(r, i))) { x[i] = GETV(pp, i) + GETV(n, i) + GETV(m, i) + GETV(r, i); continue; } #endif if (!VALID_PROB(GETV(pp, i)) || GETV(r, i) > GETV(m, i) || GETV(n, i) < 0.0 || GETV(m, i) < 0.0 || GETV(r, i) < 0.0 || !isInteger(GETV(n, i), false) || !isInteger(GETV(m, i), false) || !isInteger(GETV(r, i), false)) { throw_warning = true; x[i] = NAN; } else { std::vector& tmp = memo[std::make_tuple( static_cast(i % n.length()), static_cast(i % m.length()), static_cast(i % r.length()) )]; if (!tmp.size()) { tmp = nhyper_table(GETV(n, i), GETV(m, i), GETV(r, i), true); } for (int j = 0; j <= to_pos_int( GETV(n, i) ); j++) { if (tmp[j] >= GETV(pp, i)) { x[i] = to_dbl(j) + GETV(r, i); break; } } } } if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rnhyper( const int& nn, const NumericVector& n, const NumericVector& m, const NumericVector& r ) { if (std::min({n.length(), m.length(), r.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(nn, NA_REAL); } double u; NumericVector x(nn); bool throw_warning = false; std::map, std::vector> memo; for (int i = 0; i < nn; i++) { if (i % 100 == 0) Rcpp::checkUserInterrupt(); if (ISNAN(GETV(n, i)) || ISNAN(GETV(m, i)) || ISNAN(GETV(r, i)) || GETV(r, i) > GETV(m, i) || GETV(n, i) < 0.0 || GETV(m, i) < 0.0 || GETV(r, i) < 0.0 || !isInteger(GETV(n, i), false) || !isInteger(GETV(m, i), false) || !isInteger(GETV(r, i), false)) { throw_warning = true; x[i] = NA_REAL; } else { std::vector& tmp = memo[std::make_tuple( static_cast(i % n.length()), static_cast(i % m.length()), static_cast(i % r.length()) )]; if (!tmp.size()) { tmp = nhyper_table(GETV(n, i), GETV(m, i), GETV(r, i), true); } u = rng_unif(); for (int j = 0; j <= to_pos_int( GETV(n, i) ); j++) { if (tmp[j] >= u) { x[i] = to_dbl(j) + GETV(r, i); break; } } } } if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/discrete-uniform-distribution.cpp0000755000176200001440000001133014475546572021716 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Discrete uniform distribution * * Values: * a <= x <= b * * f(x) = 1/(b-a+1) * F(x) = (floor(x)-a+1)/b-a+1 * */ inline double pmf_dunif(double x, double min, double max, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(min) || ISNAN(max)) return x+min+max; #endif if (min > max || !R_FINITE(min) || !R_FINITE(max) || !isInteger(min, false) || !isInteger(max, false)) { throw_warning = true; return NAN; } if (x < min || x > max || !isInteger(x)) return 0.0; return 1.0/(max-min+1.0); } inline double cdf_dunif(double x, double min, double max, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(min) || ISNAN(max)) return x+min+max; #endif if (min > max || !R_FINITE(min) || !R_FINITE(max) || !isInteger(min, false) || !isInteger(max, false)) { throw_warning = true; return NAN; } if (x < min) return 0.0; else if (x >= max) return 1.0; return (floor(x)-min+1.0)/(max-min+1.0); } inline double invcdf_dunif(double p, double min, double max, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(min) || ISNAN(max)) return p+min+max; #endif if (min > max || !R_FINITE(min) || !R_FINITE(max) || !isInteger(min, false) || !isInteger(max, false) || !VALID_PROB(p)) { throw_warning = true; return NAN; } if (p == 0 || min == max) return min; return ceil( p*(max-min+1.0)+min-1.0 ); } inline double rng_dunif(double min, double max, bool& throw_warning) { if (ISNAN(min) || ISNAN(max) || min > max || !R_FINITE(min) || !R_FINITE(max) || !isInteger(min, false) || !isInteger(max, false)) { throw_warning = true; return NA_REAL; } if (min == max) return min; return ceil(R::runif(min - 1.0, max)); } // [[Rcpp::export]] NumericVector cpp_ddunif( const NumericVector& x, const NumericVector& min, const NumericVector& max, const bool& log_prob = false ) { if (std::min({x.length(), min.length(), max.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), min.length(), max.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pmf_dunif(GETV(x, i), GETV(min, i), GETV(max, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pdunif( const NumericVector& x, const NumericVector& min, const NumericVector& max, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), min.length(), max.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), min.length(), max.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_dunif(GETV(x, i), GETV(min, i), GETV(max, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qdunif( const NumericVector& p, const NumericVector& min, const NumericVector& max, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), min.length(), max.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), min.length(), max.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_dunif(GETV(pp, i), GETV(min, i), GETV(max, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rdunif( const int& n, const NumericVector& min, const NumericVector& max ) { if (std::min({min.length(), max.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_dunif(GETV(min, i), GETV(max, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/zero-inflated-binomial-distribution.cpp0000755000176200001440000001252514475546572023001 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using std::log1p; /* * Zero-inflated Poisson distribution * * Parameters: * lambda > 0 * 0 <= pi <= 1 * * Values: * x >= 0 * */ inline double pdf_zib(double x, double n, double p, double pi, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(n) || ISNAN(p) || ISNAN(pi)) return x+n+p+pi; #endif if (!VALID_PROB(p) || n < 0.0 || !VALID_PROB(pi) || !isInteger(n, false)) { throw_warning = true; return NAN; } if (x < 0.0 || !isInteger(x) || !R_FINITE(x)) return 0.0; if (x == 0.0) { // pi + (1.0-pi) * pow(1.0-p, n); return pi + exp( log1p(-pi) + log1p(-p) * n ); } else { // (1.0-pi) * R::dbinom(x, n, p, false); return exp( log1p(-pi) + R::dbinom(x, n, p, true) ); } } inline double cdf_zib(double x, double n, double p, double pi, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(n) || ISNAN(p) || ISNAN(pi)) return x+n+p+pi; #endif if (!VALID_PROB(p) || n < 0.0 || !VALID_PROB(pi) || !isInteger(n, false)) { throw_warning = true; return NAN; } if (x < 0.0) return 0.0; if (!R_FINITE(x)) return 1.0; // pi + (1.0-pi) * R::pbinom(x, n, p, true, false); return pi + exp( log1p(-pi) + R::pbinom(x, n, p, true, true) ); } inline double invcdf_zib(double pp, double n, double p, double pi, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(pp) || ISNAN(n) || ISNAN(p) || ISNAN(pi)) return pp+n+p+pi; #endif if (!VALID_PROB(p) || n < 0.0 || !VALID_PROB(pi) || !isInteger(n, false) || !VALID_PROB(pp)) { throw_warning = true; return NAN; } if (pp < pi) return 0.0; else return R::qbinom((pp - pi) / (1.0-pi), n, p, true, false); } inline double rng_zib(double n, double p, double pi, bool& throw_warning) { if (ISNAN(n) || ISNAN(p) || ISNAN(pi) || !VALID_PROB(p) || n < 0.0 || !VALID_PROB(pi) || !isInteger(n, false)) { throw_warning = true; return NA_REAL; } double u = rng_unif(); if (u < pi) return 0.0; else return R::rbinom(n, p); } // [[Rcpp::export]] NumericVector cpp_dzib( const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& log_prob = false ) { if (std::min({x.length(), size.length(), prob.length(), pi.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), size.length(), prob.length(), pi.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pdf_zib(GETV(x, i), GETV(size, i), GETV(prob, i), GETV(pi, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pzib( const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), size.length(), prob.length(), pi.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), size.length(), prob.length(), pi.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_zib(GETV(x, i), GETV(size, i), GETV(prob, i), GETV(pi, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qzib( const NumericVector& p, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), size.length(), prob.length(), pi.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), size.length(), prob.length(), pi.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) x[i] = invcdf_zib(GETV(pp, i), GETV(size, i), GETV(prob, i), GETV(pi, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rzib( const int& n, const NumericVector& size, const NumericVector& prob, const NumericVector& pi ) { if (std::min({size.length(), prob.length(), pi.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_zib(GETV(size, i), GETV(prob, i), GETV(pi, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/power-distribution.cpp0000755000176200001440000001116414475546572017600 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Power distribution * * Values: * 0 < x < alpha * * Parameters: * alpha > 0 * beta > 0 * * f(x) = (beta*x^(beta-1)) / (alpha^beta) * F(x) = x^beta / alpha^beta * F^-1(p) = alpha * p^(1/beta) * */ inline double logpdf_power(double x, double alpha, double beta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(alpha) || ISNAN(beta)) return x+alpha+beta; #endif if (alpha <= 0.0 || beta <= 0.0) { throw_warning = true; return NAN; } if (x <= 0.0 || x >= alpha) return R_NegInf; // beta * pow(x, beta-1.0) / pow(alpha, beta); return log(beta) + log(x)*(beta-1.0) - log(alpha)*beta; } inline double cdf_power(double x, double alpha, double beta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(alpha) || ISNAN(beta)) return x+alpha+beta; #endif if (alpha <= 0.0 || beta <= 0.0) { throw_warning = true; return NAN; } if (x <= 0.0) return 0.0; if (x >= alpha) return 1.0; // pow(x, beta) / pow(alpha, beta); return exp( log(x)*beta - log(alpha)*beta ); } inline double invcdf_power(double p, double alpha, double beta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(alpha) || ISNAN(beta)) return p+alpha+beta; #endif if (alpha <= 0.0 || beta <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } return alpha * pow(p, 1.0/beta); } inline double rng_power(double alpha, double beta, bool& throw_warning) { if (ISNAN(alpha) || ISNAN(beta) || alpha <= 0.0 || beta <= 0.0) { throw_warning = true; return NA_REAL; } double u = rng_unif(); return alpha * pow(u, 1.0/beta); } // [[Rcpp::export]] NumericVector cpp_dpower( const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& log_prob = false ) { if (std::min({x.length(), alpha.length(), beta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), alpha.length(), beta.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_power(GETV(x, i), GETV(alpha, i), GETV(beta, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_ppower( const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), alpha.length(), beta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), alpha.length(), beta.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_power(GETV(x, i), GETV(alpha, i), GETV(beta, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qpower( const NumericVector& p, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), alpha.length(), beta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), alpha.length(), beta.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) x[i] = invcdf_power(GETV(pp, i), GETV(alpha, i), GETV(beta, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rpower( const int& n, const NumericVector& alpha, const NumericVector& beta ) { if (std::min({alpha.length(), beta.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_power(GETV(alpha, i), GETV(beta, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/zero-inflated-poisson-distribution.cpp0000755000176200001440000001136114475546572022676 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using std::log1p; /* * Zero-inflated Poisson distribution * * Parameters: * lambda > 0 * 0 <= pi <= 1 * * Values: * x >= 0 * */ inline double pdf_zip(double x, double lambda, double pi, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(lambda) || ISNAN(pi)) return x+lambda+pi; #endif if (lambda <= 0.0 || !VALID_PROB(pi)) { throw_warning = true; return NAN; } if (x < 0.0 || !isInteger(x) || !R_FINITE(x)) return 0.0; if (x == 0.0) { // pi + (1.0-pi) * exp(-lambda); return pi + exp( log1p(-pi) - lambda ); } else { // (1.0-pi) * R::dpois(x, lambda, false); return exp( log1p(-pi) + R::dpois(x, lambda, true) ); } } inline double cdf_zip(double x, double lambda, double pi, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(lambda) || ISNAN(pi)) return x+lambda+pi; #endif if (lambda <= 0.0 || !VALID_PROB(pi)) { throw_warning = true; return NAN; } if (x < 0.0) return 0.0; if (!R_FINITE(x)) return 1.0; // pi + (1.0-pi) * R::ppois(x, lambda, true, false); return pi + exp(log1p(-pi) + R::ppois(x, lambda, true, true)); } inline double invcdf_zip(double p, double lambda, double pi, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(lambda) || ISNAN(pi)) return p+lambda+pi; #endif if (lambda <= 0.0 || !VALID_PROB(pi) || !VALID_PROB(p)) { throw_warning = true; return NAN; } if (p < pi) return 0.0; else return R::qpois((p - pi) / (1.0-pi), lambda, true, false); } inline double rng_zip(double lambda, double pi, bool& throw_warning) { if (ISNAN(lambda) || ISNAN(pi) || lambda <= 0.0 || !VALID_PROB(pi)) { throw_warning = true; return NA_REAL; } double u = rng_unif(); if (u < pi) return 0.0; else return R::rpois(lambda); } // [[Rcpp::export]] NumericVector cpp_dzip( const NumericVector& x, const NumericVector& lambda, const NumericVector& pi, const bool& log_prob = false ) { if (std::min({x.length(), lambda.length(), pi.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), lambda.length(), pi.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pdf_zip(GETV(x, i), GETV(lambda, i), GETV(pi, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pzip( const NumericVector& x, const NumericVector& lambda, const NumericVector& pi, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), lambda.length(), pi.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), lambda.length(), pi.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_zip(GETV(x, i), GETV(lambda, i), GETV(pi, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qzip( const NumericVector& p, const NumericVector& lambda, const NumericVector& pi, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), lambda.length(), pi.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), lambda.length(), pi.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) x[i] = invcdf_zip(GETV(pp, i), GETV(lambda, i), GETV(pi, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rzip( const int& n, const NumericVector& lambda, const NumericVector& pi ) { if (std::min({lambda.length(), pi.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_zip(GETV(lambda, i), GETV(pi, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } extraDistr/src/kumaraswamy-distribution.cpp0000755000176200001440000001061514475546572021005 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using std::log1p; /* * Kumaraswamy distribution * * Values: * x in [0, 1] * * Parameters: * a > 0 * b > 0 * * f(x) = a*b*x^{a-1}*(1-x^a)^{b-1} * F(x) = 1-(1-x^a)^b * F^-1(p) = 1-(1-p^{1/b})^{1/a} * */ inline double pdf_kumar(double x, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(a) || ISNAN(b)) return x+a+b; #endif if (a <= 0.0 || b <= 0.0) { throw_warning = true; return NAN; } if (x < 0.0 || x > 1.0) return 0.0; // is the support [0,1] or (0,1) ? // log(a) + log(b) + log(x)*(a-1.0) + log1p(-pow(x, a))*(b-1.0); return a*b * pow(x, a-1.0) * pow(1.0-pow(x, a), b-1.0); } inline double cdf_kumar(double x, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(a) || ISNAN(b)) return x+a+b; #endif if (a <= 0.0 || b <= 0.0) { throw_warning = true; return NAN; } if (x < 0.0) return 0.0; if (x >= 1.0) return 1.0; return 1.0 - pow(1.0 - pow(x, a), b); } inline double invcdf_kumar(double p, double a, double b, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(a) || ISNAN(b)) return p+a+b; #endif if (a <= 0.0 || b <= 0.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } return pow(1.0 - pow(1.0 - p, 1.0/b), 1.0/a); } inline double rng_kumar(double a, double b, bool& throw_warning) { if (ISNAN(a) || ISNAN(b) || a <= 0.0 || b <= 0.0) { throw_warning = true; return NA_REAL; } double u = rng_unif(); return pow(1.0 - pow(u, 1.0/b), 1.0/a); } // [[Rcpp::export]] NumericVector cpp_dkumar( const NumericVector& x, const NumericVector& a, const NumericVector& b, const bool& log_prob = false ) { if (std::min({x.length(), a.length(), b.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), a.length(), b.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = pdf_kumar(GETV(x, i), GETV(a, i), GETV(b, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pkumar( const NumericVector& x, const NumericVector& a, const NumericVector& b, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), a.length(), b.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), a.length(), b.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_kumar(GETV(x, i), GETV(a, i), GETV(b, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qkumar( const NumericVector& p, const NumericVector& a, const NumericVector& b, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), a.length(), b.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), a.length(), b.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_kumar(GETV(pp, i), GETV(a, i), GETV(b, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rkumar( const int& n, const NumericVector& a, const NumericVector& b ) { if (std::min({a.length(), b.length()}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_kumar(GETV(a, i), GETV(b, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/shared.h0000755000176200001440000000224614475546572014643 0ustar liggesusers #ifndef EDCPP_SHARED_H #define EDCPP_SHARED_H #define STRICT_R_HEADERS #include // Constants static const double SQRT_2_PI = 2.506628274631000241612; // sqrt(2*pi) static const double PHI_0 = 0.3989422804014327028632; // dnorm(0) static const double LOG_2F = 0.6931471805599452862268; // log(2) static const double MIN_DIFF_EPS = 1e-8; // MACROS #define GETV(x, i) x[i % x.length()] // wrapped indexing of vector #define GETM(x, i, j) x(i % x.nrow(), j) // wrapped indexing of matrix #define VALID_PROB(p) ((p >= 0.0) && (p <= 1.0)) // functions bool isInteger(double x, bool warn = true); double finite_max_int(const Rcpp::NumericVector& x); double rng_unif(); // standard uniform // inline functions inline bool tol_equal(double x, double y); inline double phi(double x); inline double lphi(double x); inline double Phi(double x); inline double InvPhi(double x); inline double factorial(double x); inline double lfactorial(double x); inline double rng_sign(); inline bool is_large_int(double x); inline double to_dbl(int x); inline int to_pos_int(double x); inline double trunc_p(double x); #include "shared_inline.h" #endif extraDistr/src/shared.cpp0000755000176200001440000000147114475546572015175 0ustar liggesusers#include #include "shared.h" bool isInteger(double x, bool warn) { if (ISNAN(x)) return false; if (((x < 0.0) ? std::ceil(x) : std::floor(x)) != x) { if (warn) { char msg[55]; std::snprintf(msg, sizeof(msg), "non-integer: %f", x); Rcpp::warning(msg); } return false; } return true; } double finite_max_int(const Rcpp::NumericVector& x) { double max_x = 0.0; int n = x.length(); int i = 0; do { if (x[i] > 0.0 && !is_large_int(x[i])) { max_x = x[i]; break; } i++; } while (i < n); while (i < n) { if (x[i] > max_x && !is_large_int(x[i])) { max_x = x[i]; } i++; } return max_x; } double rng_unif() { double u; // same as in base R do { u = R::unif_rand(); } while (u <= 0.0 || u >= 1.0); return u; } extraDistr/src/mixture-of-normal-distributions.cpp0000755000176200001440000001520014475546572022207 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using Rcpp::NumericMatrix; // [[Rcpp::export]] NumericVector cpp_dmixnorm( const NumericVector& x, const NumericMatrix& mu, const NumericMatrix& sigma, const NumericMatrix& alpha, const bool& log_prob = false ) { if (std::min({static_cast(x.length()), static_cast(mu.nrow()), static_cast(mu.ncol()), static_cast(sigma.nrow()), static_cast(sigma.ncol()), static_cast(alpha.nrow()), static_cast(alpha.ncol())}) < 1) { return NumericVector(0); } int Nmax = std::max({ static_cast(x.length()), static_cast(mu.nrow()), static_cast(sigma.nrow()), static_cast(alpha.nrow()) }); int k = alpha.ncol(); NumericVector p(Nmax); bool throw_warning = false; if (k != mu.ncol() || k != sigma.ncol()) Rcpp::stop("sizes of mu, sigma, and alpha do not match"); bool wrong_param; double alpha_tot, nans_sum; for (int i = 0; i < Nmax; i++) { wrong_param = false; alpha_tot = 0.0; nans_sum = 0.0; p[i] = 0.0; for (int j = 0; j < k; j++) { if (GETM(alpha, i, j) < 0.0 || GETM(sigma, i, j) <= 0.0) wrong_param = true; nans_sum += GETM(mu, i, j) + GETM(sigma, i, j); alpha_tot += GETM(alpha, i, j); } #ifdef IEEE_754 if (ISNAN(nans_sum + alpha_tot + GETV(x, i))) { p[i] = nans_sum + alpha_tot + GETV(x, i); continue; } #endif if (wrong_param) { throw_warning = true; p[i] = NAN; continue; } if (!R_finite(GETV(x, i))) { p[i] = R_NegInf; continue; } double mx = R_NegInf; std::vector tmp(k); for (int j = 0; j < k; j++) { // p[i] += (GETM(alpha, i, j) / alpha_tot) * // R::dnorm(GETV(x, i), GETM(mu, i, j), GETM(sigma, i, j), false); tmp[j] = log(GETM(alpha, i, j)) - log(alpha_tot) + R::dnorm(GETV(x, i), GETM(mu, i, j), GETM(sigma, i, j), true); if (tmp[j] > mx) mx = tmp[j]; } for (int j = 0; j < k; j++) p[i] += exp(tmp[j] - mx); // log-sum-exp trick p[i] = log(p[i]) + mx; } if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_pmixnorm( const NumericVector& x, const NumericMatrix& mu, const NumericMatrix& sigma, const NumericMatrix& alpha, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({static_cast(x.length()), static_cast(mu.nrow()), static_cast(mu.ncol()), static_cast(sigma.nrow()), static_cast(sigma.ncol()), static_cast(alpha.nrow()), static_cast(alpha.ncol())}) < 1) { return NumericVector(0); } int Nmax = std::max({ static_cast(x.length()), static_cast(mu.nrow()), static_cast(sigma.nrow()), static_cast(alpha.nrow()) }); int k = alpha.ncol(); NumericVector p(Nmax); bool throw_warning = false; if (k != mu.ncol() || k != sigma.ncol()) Rcpp::stop("sizes of mu, sigma, and alpha do not match"); bool wrong_param; double alpha_tot, nans_sum; for (int i = 0; i < Nmax; i++) { wrong_param = false; alpha_tot = 0.0; nans_sum = 0.0; p[i] = 0.0; for (int j = 0; j < k; j++) { if (GETM(alpha, i, j) < 0.0 || GETM(sigma, i, j) < 0.0) { wrong_param = true; break; } nans_sum += GETM(mu, i, j) + GETM(sigma, i, j); alpha_tot += GETM(alpha, i, j); } #ifdef IEEE_754 if (ISNAN(nans_sum + alpha_tot + GETV(x, i))) { p[i] = nans_sum + alpha_tot + GETV(x, i); continue; } #endif if (wrong_param) { throw_warning = true; p[i] = NAN; continue; } if (GETV(x, i) == R_NegInf) { p[i] = lower_tail ? R_NegInf : 0.0; continue; } if (GETV(x, i) == R_PosInf) { p[i] = !lower_tail ? R_NegInf : 0.0; continue; } double mx = R_NegInf; std::vector tmp(k); for (int j = 0; j < k; j++) { // p[i] += (GETM(alpha, i, j) / alpha_tot) * // R::pnorm(GETV(x, i), GETM(mu, i, j), GETM(sigma, i, j), true, false); tmp[j] = log(GETM(alpha, i, j)) - log(alpha_tot) + R::pnorm(GETV(x, i), GETM(mu, i, j), GETM(sigma, i, j), lower_tail, true); if (tmp[j] > mx) mx = tmp[j]; } for (int j = 0; j < k; j++) p[i] += exp(tmp[j] - mx); // log-sum-exp trick p[i] = log(p[i]) + mx; } if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_rmixnorm( const int& n, const NumericMatrix& mu, const NumericMatrix& sigma, const NumericMatrix& alpha ) { if (std::min({static_cast(mu.nrow()), static_cast(mu.ncol()), static_cast(sigma.nrow()), static_cast(sigma.ncol()), static_cast(alpha.nrow()), static_cast(alpha.ncol())}) < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } int k = alpha.ncol(); NumericVector x(n); bool throw_warning = false; if (k != mu.ncol() || k != sigma.ncol()) Rcpp::stop("sizes of mu, sigma, and alpha do not match"); int jj; bool wrong_param; double alpha_tot, nans_sum, u, p_tmp; NumericVector prob(k); for (int i = 0; i < n; i++) { jj = 0; wrong_param = false; u = rng_unif(); p_tmp = 1.0; alpha_tot = 0.0; nans_sum = 0.0; for (int j = 0; j < k; j++) { if (GETM(alpha, i, j) < 0.0 || GETM(sigma, i, j) < 0.0) { wrong_param = true; break; } nans_sum += GETM(mu, i, j) + GETM(sigma, i, j); alpha_tot += GETM(alpha, i, j); } if (ISNAN(nans_sum + alpha_tot) || wrong_param) { throw_warning = true; x[i] = NA_REAL; continue; } for (int j = k-1; j >= 0; j--) { p_tmp -= GETM(alpha, i, j) / alpha_tot; if (u > p_tmp) { jj = j; break; } } x[i] = R::rnorm(GETM(mu, i, jj), GETM(sigma, i, jj)); } if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/bivariate-normal-distribution.cpp0000755000176200001440000000751214475546572021702 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using Rcpp::NumericMatrix; /* * Bivariate Normal distribution * * Values: * x, y * * Parameters: * mu1, mu2 * sigma1, sigma2 > 0 * * z1 = (x1 - mu1)/sigma1 * z2 = (x2 - mu2)/sigma2 * * f(x) = 1/(2*pi*sqrt(1-rho^2)*sigma1*sigma2) * * exp(-(1/(2*(1-rho^2)*(z1^2 - 2*rho*z1*z2 + z2^2)))) * */ inline double pdf_bnorm(double x, double y, double mu1, double mu2, double sigma1, double sigma2, double rho, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(y) || ISNAN(mu1) || ISNAN(mu2) || ISNAN(sigma1) || ISNAN(sigma2) || ISNAN(rho)) return x+y+mu1+mu2+sigma1+sigma2+rho; #endif if (sigma1 <= 0.0 || sigma2 <= 0.0 || rho <= -1.0 || rho >= 1.0) { throw_warning = true; return NAN; } if (!R_FINITE(x) || !R_FINITE(y)) return 0.0; double z1 = (x - mu1)/sigma1; double z2 = (y - mu2)/sigma2; double c1 = 1.0/(2.0*M_PI*sqrt(1.0 - (rho*rho))*sigma1*sigma2); double c2 = -1.0/(2.0*(1.0 - (rho*rho))); return c1 * exp(c2 * ((z1*z1) - 2.0*rho*z1*z2 + (z2*z2))); } // [[Rcpp::export]] NumericVector cpp_dbnorm( const NumericVector& x, const NumericVector& y, const NumericVector& mu1, const NumericVector& mu2, const NumericVector& sigma1, const NumericVector& sigma2, const NumericVector& rho, const bool& log_prob = false ) { if (std::min({x.length(), y.length(), mu1.length(), mu2.length(), sigma1.length(), sigma2.length(), rho.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), y.length(), mu1.length(), mu2.length(), sigma1.length(), sigma2.length(), rho.length() }); NumericVector p(Nmax); bool throw_warning = false; if (x.length() != y.length()) Rcpp::stop("lengths of x and y differ"); for (int i = 0; i < Nmax; i++) p[i] = pdf_bnorm(GETV(x, i), GETV(y, i), GETV(mu1, i), GETV(mu2, i), GETV(sigma1, i), GETV(sigma2, i), GETV(rho, i), throw_warning); if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericMatrix cpp_rbnorm( const int& n, const NumericVector& mu1, const NumericVector& mu2, const NumericVector& sigma1, const NumericVector& sigma2, const NumericVector& rho ) { if (std::min({mu1.length(), mu2.length(), sigma1.length(), sigma2.length(), rho.length()}) < 1) { Rcpp::warning("NAs produced"); NumericMatrix out(n, 2); std::fill(out.begin(), out.end(), NA_REAL); return out; } NumericMatrix x(n, 2); double u, v, corr; bool throw_warning = false; for (int i = 0; i < n; i++) { if (ISNAN(GETV(mu1, i)) || ISNAN(GETV(mu2, i)) || ISNAN(GETV(sigma1, i)) || ISNAN(GETV(sigma2, i)) || ISNAN(GETV(rho, i)) || GETV(sigma1, i) <= 0.0 || GETV(sigma2, i) <= 0.0 || GETV(rho, i) < -1.0 || GETV(rho, i) > 1.0) { throw_warning = true; x(i, 0) = NA_REAL; x(i, 1) = NA_REAL; } else if (!tol_equal(GETV(rho, i), 0.0)) { u = R::norm_rand(); v = R::norm_rand(); corr = (GETV(rho, i)*u + sqrt(1.0 - pow(GETV(rho, i), 2.0))*v); x(i, 0) = GETV(mu1, i) + GETV(sigma1, i) * u; x(i, 1) = GETV(mu2, i) + GETV(sigma2, i) * corr; } else { x(i, 0) = R::rnorm(GETV(mu1, i), GETV(sigma1, i)); x(i, 1) = R::rnorm(GETV(mu2, i), GETV(sigma2, i)); } } if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/categorical-distribution-lp.cpp0000755000176200001440000000336114475546572021332 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::log; using Rcpp::NumericVector; using Rcpp::NumericMatrix; /* * * * Random generation from categorical distribution using Gumbel-max trick * * Random generation from categorical distribution given log-probabilities. * * Given vector of log-probabilities gamma[1], ..., gamma[k], where each * gamma[i] = log(prob[i]) + constant, then it is possible to taking * * x = argmax[i]( gamma[i] + g[i] ) * * where g[1], ..., g[k] is a sample from standard Gumbel distribution. * * * References: * * Maddison, C. J., Tarlow, D., & Minka, T. (2014). A* sampling. * [In:] Advances in Neural Information Processing Systems (pp. 3086-3094). * * */ // [[Rcpp::export]] NumericVector cpp_rcatlp( const int& n, const NumericMatrix& log_prob ) { if (log_prob.length() < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); int k = log_prob.ncol(); double u, glp, max_val; int jj; bool throw_warning = false; bool wrong_prob = false; for (int i = 0; i < n; i++) { max_val = -INFINITY; jj = 0; for (int j = 0; j < k; j++) { wrong_prob = false; if (ISNAN(GETM(log_prob, i, j))) { throw_warning = wrong_prob = true; break; } u = R::exp_rand(); // -log(rng_unif()) glp = -log(u) + GETM(log_prob, i, j); if (glp > max_val) { max_val = glp; jj = j; } } if (wrong_prob) { x[i] = NA_REAL; } else { x[i] = static_cast(jj); } } if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/rayleigh-distribution.cpp0000755000176200001440000001032514475546572020246 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; /* * Rayleigh distribution * * Values: * x >= 0 * * Parameters: * sigma > 0 * * f(x) = x/sigma^2 * exp(-(x^2 / 2*sigma^2)) * F(x) = 1 - exp(-x^2 / 2*sigma^2) * F^-1(p) = sigma * sqrt(-2 * log(1-p)) * */ inline double logpdf_rayleigh(double x, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(sigma)) return x+sigma; #endif if (sigma <= 0.0) { throw_warning = true; return NAN; } if (x <= 0.0 || !R_FINITE(x)) return R_NegInf; // x/(sigma*sigma) * exp(-(x*x) / (2.0*(sigma*sigma))); double lsigsq = 2.0 * log(sigma); double lxsq = 2.0 * log(x); return log(x) - lsigsq - exp( lxsq - LOG_2F - lsigsq ); } inline double cdf_rayleigh(double x, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(sigma)) return x+sigma; #endif if (sigma <= 0.0) { throw_warning = true; return NAN; } if (x < 0) return 0.0; if (!R_FINITE(x)) return 1.0; return 1.0 - exp(-(x*x) / (2.0*(sigma*sigma))); } inline double invcdf_rayleigh(double p, double sigma, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(sigma)) return p+sigma; #endif if (!VALID_PROB(p) || sigma <= 0.0) { throw_warning = true; return NAN; } return sqrt(-2.0*(sigma*sigma) * log(1.0-p)); } inline double rng_rayleigh(double sigma, bool& throw_warning) { if (ISNAN(sigma) || sigma <= 0.0) { throw_warning = true; return NA_REAL; } double u = rng_unif(); return sqrt(-2.0*(sigma*sigma) * log(u)); } // [[Rcpp::export]] NumericVector cpp_drayleigh( const NumericVector& x, const NumericVector& sigma, const bool& log_prob = false ) { if (std::min({x.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_rayleigh(GETV(x, i), GETV(sigma, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_prayleigh( const NumericVector& x, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), sigma.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_rayleigh(GETV(x, i), GETV(sigma, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qrayleigh( const NumericVector& p, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), sigma.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), sigma.length() }); NumericVector q(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) q[i] = invcdf_rayleigh(GETV(pp, i), GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return q; } // [[Rcpp::export]] NumericVector cpp_rrayleigh( const int& n, const NumericVector& sigma ) { if (sigma.length() < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_rayleigh(GETV(sigma, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/src/RcppExports.cpp0000644000176200001440000133253614532037664016216 0ustar liggesusers// Generated by using Rcpp::compileAttributes() -> do not edit by hand // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 #include "../inst/include/extraDistr.h" #include #include #include using namespace Rcpp; #ifdef RCPP_USE_GLOBAL_ROSTREAM Rcpp::Rostream& Rcpp::Rcout = Rcpp::Rcpp_cout_get(); Rcpp::Rostream& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get(); #endif // cpp_dbern NumericVector cpp_dbern(const NumericVector& x, const NumericVector& prob, const bool& log_prob); static SEXP _extraDistr_cpp_dbern_try(SEXP xSEXP, SEXP probSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dbern(x, prob, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dbern(SEXP xSEXP, SEXP probSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dbern_try(xSEXP, probSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pbern NumericVector cpp_pbern(const NumericVector& x, const NumericVector& prob, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pbern_try(SEXP xSEXP, SEXP probSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pbern(x, prob, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pbern(SEXP xSEXP, SEXP probSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pbern_try(xSEXP, probSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qbern NumericVector cpp_qbern(const NumericVector& p, const NumericVector& prob, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qbern_try(SEXP pSEXP, SEXP probSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qbern(p, prob, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qbern(SEXP pSEXP, SEXP probSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qbern_try(pSEXP, probSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rbern NumericVector cpp_rbern(const int& n, const NumericVector& prob); static SEXP _extraDistr_cpp_rbern_try(SEXP nSEXP, SEXP probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rbern(n, prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rbern(SEXP nSEXP, SEXP probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rbern_try(nSEXP, probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dbbinom NumericVector cpp_dbbinom(const NumericVector& x, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta, const bool& log_prob); static SEXP _extraDistr_cpp_dbbinom_try(SEXP xSEXP, SEXP sizeSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dbbinom(x, size, alpha, beta, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dbbinom(SEXP xSEXP, SEXP sizeSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dbbinom_try(xSEXP, sizeSEXP, alphaSEXP, betaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pbbinom NumericVector cpp_pbbinom(const NumericVector& x, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pbbinom_try(SEXP xSEXP, SEXP sizeSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pbbinom(x, size, alpha, beta, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pbbinom(SEXP xSEXP, SEXP sizeSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pbbinom_try(xSEXP, sizeSEXP, alphaSEXP, betaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rbbinom NumericVector cpp_rbbinom(const int& n, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta); static SEXP _extraDistr_cpp_rbbinom_try(SEXP nSEXP, SEXP sizeSEXP, SEXP alphaSEXP, SEXP betaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rbbinom(n, size, alpha, beta)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rbbinom(SEXP nSEXP, SEXP sizeSEXP, SEXP alphaSEXP, SEXP betaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rbbinom_try(nSEXP, sizeSEXP, alphaSEXP, betaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dbnbinom NumericVector cpp_dbnbinom(const NumericVector& x, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta, const bool& log_prob); static SEXP _extraDistr_cpp_dbnbinom_try(SEXP xSEXP, SEXP sizeSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dbnbinom(x, size, alpha, beta, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dbnbinom(SEXP xSEXP, SEXP sizeSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dbnbinom_try(xSEXP, sizeSEXP, alphaSEXP, betaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pbnbinom NumericVector cpp_pbnbinom(const NumericVector& x, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pbnbinom_try(SEXP xSEXP, SEXP sizeSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pbnbinom(x, size, alpha, beta, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pbnbinom(SEXP xSEXP, SEXP sizeSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pbnbinom_try(xSEXP, sizeSEXP, alphaSEXP, betaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rbnbinom NumericVector cpp_rbnbinom(const int& n, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta); static SEXP _extraDistr_cpp_rbnbinom_try(SEXP nSEXP, SEXP sizeSEXP, SEXP alphaSEXP, SEXP betaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rbnbinom(n, size, alpha, beta)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rbnbinom(SEXP nSEXP, SEXP sizeSEXP, SEXP alphaSEXP, SEXP betaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rbnbinom_try(nSEXP, sizeSEXP, alphaSEXP, betaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dbetapr NumericVector cpp_dbetapr(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& sigma, const bool& log_prob); static SEXP _extraDistr_cpp_dbetapr_try(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dbetapr(x, alpha, beta, sigma, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dbetapr(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dbetapr_try(xSEXP, alphaSEXP, betaSEXP, sigmaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pbetapr NumericVector cpp_pbetapr(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pbetapr_try(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pbetapr(x, alpha, beta, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pbetapr(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pbetapr_try(xSEXP, alphaSEXP, betaSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qbetapr NumericVector cpp_qbetapr(const NumericVector& p, const NumericVector& alpha, const NumericVector& beta, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qbetapr_try(SEXP pSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qbetapr(p, alpha, beta, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qbetapr(SEXP pSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qbetapr_try(pSEXP, alphaSEXP, betaSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rbetapr NumericVector cpp_rbetapr(const int& n, const NumericVector& alpha, const NumericVector& beta, const NumericVector& sigma); static SEXP _extraDistr_cpp_rbetapr_try(SEXP nSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP sigmaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rbetapr(n, alpha, beta, sigma)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rbetapr(SEXP nSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP sigmaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rbetapr_try(nSEXP, alphaSEXP, betaSEXP, sigmaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dbhatt NumericVector cpp_dbhatt(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& a, const bool& log_prob); static SEXP _extraDistr_cpp_dbhatt_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP aSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dbhatt(x, mu, sigma, a, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dbhatt(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP aSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dbhatt_try(xSEXP, muSEXP, sigmaSEXP, aSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pbhatt NumericVector cpp_pbhatt(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& a, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pbhatt_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP aSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pbhatt(x, mu, sigma, a, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pbhatt(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP aSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pbhatt_try(xSEXP, muSEXP, sigmaSEXP, aSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rbhatt NumericVector cpp_rbhatt(const int& n, const NumericVector& mu, const NumericVector& sigma, const NumericVector& a); static SEXP _extraDistr_cpp_rbhatt_try(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP aSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rbhatt(n, mu, sigma, a)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rbhatt(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP aSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rbhatt_try(nSEXP, muSEXP, sigmaSEXP, aSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dfatigue NumericVector cpp_dfatigue(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& mu, const bool& log_prob); static SEXP _extraDistr_cpp_dfatigue_try(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP muSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dfatigue(x, alpha, beta, mu, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dfatigue(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP muSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dfatigue_try(xSEXP, alphaSEXP, betaSEXP, muSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pfatigue NumericVector cpp_pfatigue(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& mu, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pfatigue_try(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP muSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pfatigue(x, alpha, beta, mu, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pfatigue(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP muSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pfatigue_try(xSEXP, alphaSEXP, betaSEXP, muSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qfatigue NumericVector cpp_qfatigue(const NumericVector& p, const NumericVector& alpha, const NumericVector& beta, const NumericVector& mu, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qfatigue_try(SEXP pSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP muSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qfatigue(p, alpha, beta, mu, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qfatigue(SEXP pSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP muSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qfatigue_try(pSEXP, alphaSEXP, betaSEXP, muSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rfatigue NumericVector cpp_rfatigue(const int& n, const NumericVector& alpha, const NumericVector& beta, const NumericVector& mu); static SEXP _extraDistr_cpp_rfatigue_try(SEXP nSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP muSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rfatigue(n, alpha, beta, mu)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rfatigue(SEXP nSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP muSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rfatigue_try(nSEXP, alphaSEXP, betaSEXP, muSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dbnorm NumericVector cpp_dbnorm(const NumericVector& x, const NumericVector& y, const NumericVector& mu1, const NumericVector& mu2, const NumericVector& sigma1, const NumericVector& sigma2, const NumericVector& rho, const bool& log_prob); static SEXP _extraDistr_cpp_dbnorm_try(SEXP xSEXP, SEXP ySEXP, SEXP mu1SEXP, SEXP mu2SEXP, SEXP sigma1SEXP, SEXP sigma2SEXP, SEXP rhoSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type y(ySEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu1(mu1SEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu2(mu2SEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma1(sigma1SEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma2(sigma2SEXP); Rcpp::traits::input_parameter< const NumericVector& >::type rho(rhoSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dbnorm(x, y, mu1, mu2, sigma1, sigma2, rho, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dbnorm(SEXP xSEXP, SEXP ySEXP, SEXP mu1SEXP, SEXP mu2SEXP, SEXP sigma1SEXP, SEXP sigma2SEXP, SEXP rhoSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dbnorm_try(xSEXP, ySEXP, mu1SEXP, mu2SEXP, sigma1SEXP, sigma2SEXP, rhoSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rbnorm NumericMatrix cpp_rbnorm(const int& n, const NumericVector& mu1, const NumericVector& mu2, const NumericVector& sigma1, const NumericVector& sigma2, const NumericVector& rho); static SEXP _extraDistr_cpp_rbnorm_try(SEXP nSEXP, SEXP mu1SEXP, SEXP mu2SEXP, SEXP sigma1SEXP, SEXP sigma2SEXP, SEXP rhoSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu1(mu1SEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu2(mu2SEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma1(sigma1SEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma2(sigma2SEXP); Rcpp::traits::input_parameter< const NumericVector& >::type rho(rhoSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rbnorm(n, mu1, mu2, sigma1, sigma2, rho)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rbnorm(SEXP nSEXP, SEXP mu1SEXP, SEXP mu2SEXP, SEXP sigma1SEXP, SEXP sigma2SEXP, SEXP rhoSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rbnorm_try(nSEXP, mu1SEXP, mu2SEXP, sigma1SEXP, sigma2SEXP, rhoSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dbpois NumericVector cpp_dbpois(const NumericVector& x, const NumericVector& y, const NumericVector& a, const NumericVector& b, const NumericVector& c, const bool& log_prob); static SEXP _extraDistr_cpp_dbpois_try(SEXP xSEXP, SEXP ySEXP, SEXP aSEXP, SEXP bSEXP, SEXP cSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type y(ySEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type c(cSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dbpois(x, y, a, b, c, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dbpois(SEXP xSEXP, SEXP ySEXP, SEXP aSEXP, SEXP bSEXP, SEXP cSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dbpois_try(xSEXP, ySEXP, aSEXP, bSEXP, cSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rbpois NumericMatrix cpp_rbpois(const int& n, const NumericVector& a, const NumericVector& b, const NumericVector& c); static SEXP _extraDistr_cpp_rbpois_try(SEXP nSEXP, SEXP aSEXP, SEXP bSEXP, SEXP cSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type c(cSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rbpois(n, a, b, c)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rbpois(SEXP nSEXP, SEXP aSEXP, SEXP bSEXP, SEXP cSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rbpois_try(nSEXP, aSEXP, bSEXP, cSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rcatlp NumericVector cpp_rcatlp(const int& n, const NumericMatrix& log_prob); static SEXP _extraDistr_cpp_rcatlp_try(SEXP nSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rcatlp(n, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rcatlp(SEXP nSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rcatlp_try(nSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dcat NumericVector cpp_dcat(const NumericVector& x, const NumericMatrix& prob, const bool& log_prob); static SEXP _extraDistr_cpp_dcat_try(SEXP xSEXP, SEXP probSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type prob(probSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dcat(x, prob, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dcat(SEXP xSEXP, SEXP probSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dcat_try(xSEXP, probSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pcat NumericVector cpp_pcat(const NumericVector& x, const NumericMatrix& prob, bool lower_tail, bool log_prob); static SEXP _extraDistr_cpp_pcat_try(SEXP xSEXP, SEXP probSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type prob(probSEXP); Rcpp::traits::input_parameter< bool >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< bool >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pcat(x, prob, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pcat(SEXP xSEXP, SEXP probSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pcat_try(xSEXP, probSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qcat NumericVector cpp_qcat(const NumericVector& p, const NumericMatrix& prob, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qcat_try(SEXP pSEXP, SEXP probSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type prob(probSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qcat(p, prob, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qcat(SEXP pSEXP, SEXP probSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qcat_try(pSEXP, probSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rcat NumericVector cpp_rcat(const int& n, const NumericMatrix& prob); static SEXP _extraDistr_cpp_rcat_try(SEXP nSEXP, SEXP probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type prob(probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rcat(n, prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rcat(SEXP nSEXP, SEXP probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rcat_try(nSEXP, probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_ddirichlet NumericVector cpp_ddirichlet(const NumericMatrix& x, const NumericMatrix& alpha, const bool& log_prob); static SEXP _extraDistr_cpp_ddirichlet_try(SEXP xSEXP, SEXP alphaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericMatrix& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_ddirichlet(x, alpha, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_ddirichlet(SEXP xSEXP, SEXP alphaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_ddirichlet_try(xSEXP, alphaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rdirichlet NumericMatrix cpp_rdirichlet(const int& n, const NumericMatrix& alpha); static SEXP _extraDistr_cpp_rdirichlet_try(SEXP nSEXP, SEXP alphaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type alpha(alphaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rdirichlet(n, alpha)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rdirichlet(SEXP nSEXP, SEXP alphaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rdirichlet_try(nSEXP, alphaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_ddirmnom NumericVector cpp_ddirmnom(const NumericMatrix& x, const NumericVector& size, const NumericMatrix& alpha, const bool& log_prob); static SEXP _extraDistr_cpp_ddirmnom_try(SEXP xSEXP, SEXP sizeSEXP, SEXP alphaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericMatrix& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_ddirmnom(x, size, alpha, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_ddirmnom(SEXP xSEXP, SEXP sizeSEXP, SEXP alphaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_ddirmnom_try(xSEXP, sizeSEXP, alphaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rdirmnom NumericMatrix cpp_rdirmnom(const int& n, const NumericVector& size, const NumericMatrix& alpha); static SEXP _extraDistr_cpp_rdirmnom_try(SEXP nSEXP, SEXP sizeSEXP, SEXP alphaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type alpha(alphaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rdirmnom(n, size, alpha)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rdirmnom(SEXP nSEXP, SEXP sizeSEXP, SEXP alphaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rdirmnom_try(nSEXP, sizeSEXP, alphaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_ddgamma NumericVector cpp_ddgamma(const NumericVector& x, const NumericVector& shape, const NumericVector& scale, const bool& log_prob); static SEXP _extraDistr_cpp_ddgamma_try(SEXP xSEXP, SEXP shapeSEXP, SEXP scaleSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type shape(shapeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type scale(scaleSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_ddgamma(x, shape, scale, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_ddgamma(SEXP xSEXP, SEXP shapeSEXP, SEXP scaleSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_ddgamma_try(xSEXP, shapeSEXP, scaleSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_ddlaplace NumericVector cpp_ddlaplace(const NumericVector& x, const NumericVector& location, const NumericVector& scale, const bool& log_prob); static SEXP _extraDistr_cpp_ddlaplace_try(SEXP xSEXP, SEXP locationSEXP, SEXP scaleSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type location(locationSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type scale(scaleSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_ddlaplace(x, location, scale, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_ddlaplace(SEXP xSEXP, SEXP locationSEXP, SEXP scaleSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_ddlaplace_try(xSEXP, locationSEXP, scaleSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pdlaplace NumericVector cpp_pdlaplace(const NumericVector& x, const NumericVector& location, const NumericVector& scale, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pdlaplace_try(SEXP xSEXP, SEXP locationSEXP, SEXP scaleSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type location(locationSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type scale(scaleSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pdlaplace(x, location, scale, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pdlaplace(SEXP xSEXP, SEXP locationSEXP, SEXP scaleSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pdlaplace_try(xSEXP, locationSEXP, scaleSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rdlaplace NumericVector cpp_rdlaplace(const int& n, const NumericVector& location, const NumericVector& scale); static SEXP _extraDistr_cpp_rdlaplace_try(SEXP nSEXP, SEXP locationSEXP, SEXP scaleSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type location(locationSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type scale(scaleSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rdlaplace(n, location, scale)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rdlaplace(SEXP nSEXP, SEXP locationSEXP, SEXP scaleSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rdlaplace_try(nSEXP, locationSEXP, scaleSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_ddnorm NumericVector cpp_ddnorm(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob); static SEXP _extraDistr_cpp_ddnorm_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_ddnorm(x, mu, sigma, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_ddnorm(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_ddnorm_try(xSEXP, muSEXP, sigmaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_ddunif NumericVector cpp_ddunif(const NumericVector& x, const NumericVector& min, const NumericVector& max, const bool& log_prob); static SEXP _extraDistr_cpp_ddunif_try(SEXP xSEXP, SEXP minSEXP, SEXP maxSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type min(minSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type max(maxSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_ddunif(x, min, max, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_ddunif(SEXP xSEXP, SEXP minSEXP, SEXP maxSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_ddunif_try(xSEXP, minSEXP, maxSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pdunif NumericVector cpp_pdunif(const NumericVector& x, const NumericVector& min, const NumericVector& max, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pdunif_try(SEXP xSEXP, SEXP minSEXP, SEXP maxSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type min(minSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type max(maxSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pdunif(x, min, max, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pdunif(SEXP xSEXP, SEXP minSEXP, SEXP maxSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pdunif_try(xSEXP, minSEXP, maxSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qdunif NumericVector cpp_qdunif(const NumericVector& p, const NumericVector& min, const NumericVector& max, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qdunif_try(SEXP pSEXP, SEXP minSEXP, SEXP maxSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type min(minSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type max(maxSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qdunif(p, min, max, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qdunif(SEXP pSEXP, SEXP minSEXP, SEXP maxSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qdunif_try(pSEXP, minSEXP, maxSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rdunif NumericVector cpp_rdunif(const int& n, const NumericVector& min, const NumericVector& max); static SEXP _extraDistr_cpp_rdunif_try(SEXP nSEXP, SEXP minSEXP, SEXP maxSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type min(minSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type max(maxSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rdunif(n, min, max)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rdunif(SEXP nSEXP, SEXP minSEXP, SEXP maxSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rdunif_try(nSEXP, minSEXP, maxSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_ddweibull NumericVector cpp_ddweibull(const NumericVector& x, const NumericVector& q, const NumericVector& beta, const bool& log_prob); static SEXP _extraDistr_cpp_ddweibull_try(SEXP xSEXP, SEXP qSEXP, SEXP betaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type q(qSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_ddweibull(x, q, beta, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_ddweibull(SEXP xSEXP, SEXP qSEXP, SEXP betaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_ddweibull_try(xSEXP, qSEXP, betaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pdweibull NumericVector cpp_pdweibull(const NumericVector& x, const NumericVector& q, const NumericVector& beta, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pdweibull_try(SEXP xSEXP, SEXP qSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type q(qSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pdweibull(x, q, beta, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pdweibull(SEXP xSEXP, SEXP qSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pdweibull_try(xSEXP, qSEXP, betaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qdweibull NumericVector cpp_qdweibull(const NumericVector& p, const NumericVector& q, const NumericVector& beta, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qdweibull_try(SEXP pSEXP, SEXP qSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type q(qSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qdweibull(p, q, beta, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qdweibull(SEXP pSEXP, SEXP qSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qdweibull_try(pSEXP, qSEXP, betaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rdweibull NumericVector cpp_rdweibull(const int& n, const NumericVector& q, const NumericVector& beta); static SEXP _extraDistr_cpp_rdweibull_try(SEXP nSEXP, SEXP qSEXP, SEXP betaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type q(qSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rdweibull(n, q, beta)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rdweibull(SEXP nSEXP, SEXP qSEXP, SEXP betaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rdweibull_try(nSEXP, qSEXP, betaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dfrechet NumericVector cpp_dfrechet(const NumericVector& x, const NumericVector& lambda, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob); static SEXP _extraDistr_cpp_dfrechet_try(SEXP xSEXP, SEXP lambdaSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dfrechet(x, lambda, mu, sigma, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dfrechet(SEXP xSEXP, SEXP lambdaSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dfrechet_try(xSEXP, lambdaSEXP, muSEXP, sigmaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pfrechet NumericVector cpp_pfrechet(const NumericVector& x, const NumericVector& lambda, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pfrechet_try(SEXP xSEXP, SEXP lambdaSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pfrechet(x, lambda, mu, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pfrechet(SEXP xSEXP, SEXP lambdaSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pfrechet_try(xSEXP, lambdaSEXP, muSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qfrechet NumericVector cpp_qfrechet(const NumericVector& p, const NumericVector& lambda, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qfrechet_try(SEXP pSEXP, SEXP lambdaSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qfrechet(p, lambda, mu, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qfrechet(SEXP pSEXP, SEXP lambdaSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qfrechet_try(pSEXP, lambdaSEXP, muSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rfrechet NumericVector cpp_rfrechet(const int& n, const NumericVector& lambda, const NumericVector& mu, const NumericVector& sigma); static SEXP _extraDistr_cpp_rfrechet_try(SEXP nSEXP, SEXP lambdaSEXP, SEXP muSEXP, SEXP sigmaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rfrechet(n, lambda, mu, sigma)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rfrechet(SEXP nSEXP, SEXP lambdaSEXP, SEXP muSEXP, SEXP sigmaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rfrechet_try(nSEXP, lambdaSEXP, muSEXP, sigmaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dgpois NumericVector cpp_dgpois(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& log_prob); static SEXP _extraDistr_cpp_dgpois_try(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dgpois(x, alpha, beta, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dgpois(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dgpois_try(xSEXP, alphaSEXP, betaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pgpois NumericVector cpp_pgpois(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pgpois_try(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pgpois(x, alpha, beta, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pgpois(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pgpois_try(xSEXP, alphaSEXP, betaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rgpois NumericVector cpp_rgpois(const int& n, const NumericVector& alpha, const NumericVector& beta); static SEXP _extraDistr_cpp_rgpois_try(SEXP nSEXP, SEXP alphaSEXP, SEXP betaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rgpois(n, alpha, beta)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rgpois(SEXP nSEXP, SEXP alphaSEXP, SEXP betaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rgpois_try(nSEXP, alphaSEXP, betaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dgev NumericVector cpp_dgev(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi, const bool& log_prob); static SEXP _extraDistr_cpp_dgev_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type xi(xiSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dgev(x, mu, sigma, xi, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dgev(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dgev_try(xSEXP, muSEXP, sigmaSEXP, xiSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pgev NumericVector cpp_pgev(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi, bool lower_tail, bool log_prob); static SEXP _extraDistr_cpp_pgev_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type xi(xiSEXP); Rcpp::traits::input_parameter< bool >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< bool >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pgev(x, mu, sigma, xi, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pgev(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pgev_try(xSEXP, muSEXP, sigmaSEXP, xiSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qgev NumericVector cpp_qgev(const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi, bool lower_tail, bool log_prob); static SEXP _extraDistr_cpp_qgev_try(SEXP pSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type xi(xiSEXP); Rcpp::traits::input_parameter< bool >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< bool >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qgev(p, mu, sigma, xi, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qgev(SEXP pSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qgev_try(pSEXP, muSEXP, sigmaSEXP, xiSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rgev NumericVector cpp_rgev(const int& n, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi); static SEXP _extraDistr_cpp_rgev_try(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type xi(xiSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rgev(n, mu, sigma, xi)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rgev(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rgev_try(nSEXP, muSEXP, sigmaSEXP, xiSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dgompertz NumericVector cpp_dgompertz(const NumericVector& x, const NumericVector& a, const NumericVector& b, bool log_prob); static SEXP _extraDistr_cpp_dgompertz_try(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< bool >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dgompertz(x, a, b, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dgompertz(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dgompertz_try(xSEXP, aSEXP, bSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pgompertz NumericVector cpp_pgompertz(const NumericVector& x, const NumericVector& a, const NumericVector& b, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pgompertz_try(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pgompertz(x, a, b, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pgompertz(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pgompertz_try(xSEXP, aSEXP, bSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qgompertz NumericVector cpp_qgompertz(const NumericVector& p, const NumericVector& a, const NumericVector& b, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qgompertz_try(SEXP pSEXP, SEXP aSEXP, SEXP bSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qgompertz(p, a, b, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qgompertz(SEXP pSEXP, SEXP aSEXP, SEXP bSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qgompertz_try(pSEXP, aSEXP, bSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rgompertz NumericVector cpp_rgompertz(const int& n, const NumericVector& a, const NumericVector& b); static SEXP _extraDistr_cpp_rgompertz_try(SEXP nSEXP, SEXP aSEXP, SEXP bSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rgompertz(n, a, b)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rgompertz(SEXP nSEXP, SEXP aSEXP, SEXP bSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rgompertz_try(nSEXP, aSEXP, bSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dgpd NumericVector cpp_dgpd(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi, const bool& log_prob); static SEXP _extraDistr_cpp_dgpd_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type xi(xiSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dgpd(x, mu, sigma, xi, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dgpd(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dgpd_try(xSEXP, muSEXP, sigmaSEXP, xiSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pgpd NumericVector cpp_pgpd(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pgpd_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type xi(xiSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pgpd(x, mu, sigma, xi, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pgpd(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pgpd_try(xSEXP, muSEXP, sigmaSEXP, xiSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qgpd NumericVector cpp_qgpd(const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qgpd_try(SEXP pSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type xi(xiSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qgpd(p, mu, sigma, xi, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qgpd(SEXP pSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qgpd_try(pSEXP, muSEXP, sigmaSEXP, xiSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rgpd NumericVector cpp_rgpd(const int& n, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi); static SEXP _extraDistr_cpp_rgpd_try(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type xi(xiSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rgpd(n, mu, sigma, xi)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rgpd(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP xiSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rgpd_try(nSEXP, muSEXP, sigmaSEXP, xiSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dgumbel NumericVector cpp_dgumbel(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob); static SEXP _extraDistr_cpp_dgumbel_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dgumbel(x, mu, sigma, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dgumbel(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dgumbel_try(xSEXP, muSEXP, sigmaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pgumbel NumericVector cpp_pgumbel(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pgumbel_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pgumbel(x, mu, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pgumbel(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pgumbel_try(xSEXP, muSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qgumbel NumericVector cpp_qgumbel(const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qgumbel_try(SEXP pSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qgumbel(p, mu, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qgumbel(SEXP pSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qgumbel_try(pSEXP, muSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rgumbel NumericVector cpp_rgumbel(const int& n, const NumericVector& mu, const NumericVector& sigma); static SEXP _extraDistr_cpp_rgumbel_try(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rgumbel(n, mu, sigma)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rgumbel(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rgumbel_try(nSEXP, muSEXP, sigmaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dhcauchy NumericVector cpp_dhcauchy(const NumericVector& x, const NumericVector& sigma, const bool& log_prob); static SEXP _extraDistr_cpp_dhcauchy_try(SEXP xSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dhcauchy(x, sigma, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dhcauchy(SEXP xSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dhcauchy_try(xSEXP, sigmaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_phcauchy NumericVector cpp_phcauchy(const NumericVector& x, const NumericVector& sigma, bool lower_tail, bool log_prob); static SEXP _extraDistr_cpp_phcauchy_try(SEXP xSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< bool >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< bool >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_phcauchy(x, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_phcauchy(SEXP xSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_phcauchy_try(xSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qhcauchy NumericVector cpp_qhcauchy(const NumericVector& p, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qhcauchy_try(SEXP pSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qhcauchy(p, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qhcauchy(SEXP pSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qhcauchy_try(pSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rhcauchy NumericVector cpp_rhcauchy(const int& n, const NumericVector& sigma); static SEXP _extraDistr_cpp_rhcauchy_try(SEXP nSEXP, SEXP sigmaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rhcauchy(n, sigma)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rhcauchy(SEXP nSEXP, SEXP sigmaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rhcauchy_try(nSEXP, sigmaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dhnorm NumericVector cpp_dhnorm(const NumericVector& x, const NumericVector& sigma, const bool& log_prob); static SEXP _extraDistr_cpp_dhnorm_try(SEXP xSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dhnorm(x, sigma, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dhnorm(SEXP xSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dhnorm_try(xSEXP, sigmaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_phnorm NumericVector cpp_phnorm(const NumericVector& x, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_phnorm_try(SEXP xSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_phnorm(x, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_phnorm(SEXP xSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_phnorm_try(xSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qhnorm NumericVector cpp_qhnorm(const NumericVector& p, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qhnorm_try(SEXP pSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qhnorm(p, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qhnorm(SEXP pSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qhnorm_try(pSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rhnorm NumericVector cpp_rhnorm(const int& n, const NumericVector& sigma); static SEXP _extraDistr_cpp_rhnorm_try(SEXP nSEXP, SEXP sigmaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rhnorm(n, sigma)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rhnorm(SEXP nSEXP, SEXP sigmaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rhnorm_try(nSEXP, sigmaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dht NumericVector cpp_dht(const NumericVector& x, const NumericVector& nu, const NumericVector& sigma, const bool& log_prob); static SEXP _extraDistr_cpp_dht_try(SEXP xSEXP, SEXP nuSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type nu(nuSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dht(x, nu, sigma, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dht(SEXP xSEXP, SEXP nuSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dht_try(xSEXP, nuSEXP, sigmaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pht NumericVector cpp_pht(const NumericVector& x, const NumericVector& nu, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pht_try(SEXP xSEXP, SEXP nuSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type nu(nuSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pht(x, nu, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pht(SEXP xSEXP, SEXP nuSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pht_try(xSEXP, nuSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qht NumericVector cpp_qht(const NumericVector& p, const NumericVector& nu, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qht_try(SEXP pSEXP, SEXP nuSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type nu(nuSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qht(p, nu, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qht(SEXP pSEXP, SEXP nuSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qht_try(pSEXP, nuSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rht NumericVector cpp_rht(const int& n, const NumericVector& nu, const NumericVector& sigma); static SEXP _extraDistr_cpp_rht_try(SEXP nSEXP, SEXP nuSEXP, SEXP sigmaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type nu(nuSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rht(n, nu, sigma)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rht(SEXP nSEXP, SEXP nuSEXP, SEXP sigmaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rht_try(nSEXP, nuSEXP, sigmaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dhuber NumericVector cpp_dhuber(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& epsilon, const bool& log_prob); static SEXP _extraDistr_cpp_dhuber_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP epsilonSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type epsilon(epsilonSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dhuber(x, mu, sigma, epsilon, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dhuber(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP epsilonSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dhuber_try(xSEXP, muSEXP, sigmaSEXP, epsilonSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_phuber NumericVector cpp_phuber(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& epsilon, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_phuber_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP epsilonSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type epsilon(epsilonSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_phuber(x, mu, sigma, epsilon, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_phuber(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP epsilonSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_phuber_try(xSEXP, muSEXP, sigmaSEXP, epsilonSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qhuber NumericVector cpp_qhuber(const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const NumericVector& epsilon, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qhuber_try(SEXP pSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP epsilonSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type epsilon(epsilonSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qhuber(p, mu, sigma, epsilon, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qhuber(SEXP pSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP epsilonSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qhuber_try(pSEXP, muSEXP, sigmaSEXP, epsilonSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rhuber NumericVector cpp_rhuber(const int& n, const NumericVector& mu, const NumericVector& sigma, const NumericVector& epsilon); static SEXP _extraDistr_cpp_rhuber_try(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP epsilonSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type epsilon(epsilonSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rhuber(n, mu, sigma, epsilon)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rhuber(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP epsilonSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rhuber_try(nSEXP, muSEXP, sigmaSEXP, epsilonSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dinvgamma NumericVector cpp_dinvgamma(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& log_prob); static SEXP _extraDistr_cpp_dinvgamma_try(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dinvgamma(x, alpha, beta, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dinvgamma(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dinvgamma_try(xSEXP, alphaSEXP, betaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pinvgamma NumericVector cpp_pinvgamma(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pinvgamma_try(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pinvgamma(x, alpha, beta, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pinvgamma(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pinvgamma_try(xSEXP, alphaSEXP, betaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dkumar NumericVector cpp_dkumar(const NumericVector& x, const NumericVector& a, const NumericVector& b, const bool& log_prob); static SEXP _extraDistr_cpp_dkumar_try(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dkumar(x, a, b, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dkumar(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dkumar_try(xSEXP, aSEXP, bSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pkumar NumericVector cpp_pkumar(const NumericVector& x, const NumericVector& a, const NumericVector& b, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pkumar_try(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pkumar(x, a, b, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pkumar(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pkumar_try(xSEXP, aSEXP, bSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qkumar NumericVector cpp_qkumar(const NumericVector& p, const NumericVector& a, const NumericVector& b, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qkumar_try(SEXP pSEXP, SEXP aSEXP, SEXP bSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qkumar(p, a, b, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qkumar(SEXP pSEXP, SEXP aSEXP, SEXP bSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qkumar_try(pSEXP, aSEXP, bSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rkumar NumericVector cpp_rkumar(const int& n, const NumericVector& a, const NumericVector& b); static SEXP _extraDistr_cpp_rkumar_try(SEXP nSEXP, SEXP aSEXP, SEXP bSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rkumar(n, a, b)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rkumar(SEXP nSEXP, SEXP aSEXP, SEXP bSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rkumar_try(nSEXP, aSEXP, bSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dlaplace NumericVector cpp_dlaplace(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob); static SEXP _extraDistr_cpp_dlaplace_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dlaplace(x, mu, sigma, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dlaplace(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dlaplace_try(xSEXP, muSEXP, sigmaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_plaplace NumericVector cpp_plaplace(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_plaplace_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_plaplace(x, mu, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_plaplace(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_plaplace_try(xSEXP, muSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qlaplace NumericVector cpp_qlaplace(const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qlaplace_try(SEXP pSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qlaplace(p, mu, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qlaplace(SEXP pSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qlaplace_try(pSEXP, muSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rlaplace NumericVector cpp_rlaplace(const int& n, const NumericVector& mu, const NumericVector& sigma); static SEXP _extraDistr_cpp_rlaplace_try(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rlaplace(n, mu, sigma)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rlaplace(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rlaplace_try(nSEXP, muSEXP, sigmaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dlst NumericVector cpp_dlst(const NumericVector& x, const NumericVector& nu, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob); static SEXP _extraDistr_cpp_dlst_try(SEXP xSEXP, SEXP nuSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type nu(nuSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dlst(x, nu, mu, sigma, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dlst(SEXP xSEXP, SEXP nuSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dlst_try(xSEXP, nuSEXP, muSEXP, sigmaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_plst NumericVector cpp_plst(const NumericVector& x, const NumericVector& nu, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_plst_try(SEXP xSEXP, SEXP nuSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type nu(nuSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_plst(x, nu, mu, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_plst(SEXP xSEXP, SEXP nuSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_plst_try(xSEXP, nuSEXP, muSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qlst NumericVector cpp_qlst(const NumericVector& p, const NumericVector& nu, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qlst_try(SEXP pSEXP, SEXP nuSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type nu(nuSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qlst(p, nu, mu, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qlst(SEXP pSEXP, SEXP nuSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qlst_try(pSEXP, nuSEXP, muSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rlst NumericVector cpp_rlst(const int& n, const NumericVector& nu, const NumericVector& mu, const NumericVector& sigma); static SEXP _extraDistr_cpp_rlst_try(SEXP nSEXP, SEXP nuSEXP, SEXP muSEXP, SEXP sigmaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type nu(nuSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rlst(n, nu, mu, sigma)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rlst(SEXP nSEXP, SEXP nuSEXP, SEXP muSEXP, SEXP sigmaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rlst_try(nSEXP, nuSEXP, muSEXP, sigmaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dlgser NumericVector cpp_dlgser(const NumericVector& x, const NumericVector& theta, const bool& log_prob); static SEXP _extraDistr_cpp_dlgser_try(SEXP xSEXP, SEXP thetaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type theta(thetaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dlgser(x, theta, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dlgser(SEXP xSEXP, SEXP thetaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dlgser_try(xSEXP, thetaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_plgser NumericVector cpp_plgser(const NumericVector& x, const NumericVector& theta, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_plgser_try(SEXP xSEXP, SEXP thetaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type theta(thetaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_plgser(x, theta, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_plgser(SEXP xSEXP, SEXP thetaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_plgser_try(xSEXP, thetaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qlgser NumericVector cpp_qlgser(const NumericVector& p, const NumericVector& theta, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qlgser_try(SEXP pSEXP, SEXP thetaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type theta(thetaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qlgser(p, theta, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qlgser(SEXP pSEXP, SEXP thetaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qlgser_try(pSEXP, thetaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rlgser NumericVector cpp_rlgser(const int& n, const NumericVector& theta); static SEXP _extraDistr_cpp_rlgser_try(SEXP nSEXP, SEXP thetaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type theta(thetaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rlgser(n, theta)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rlgser(SEXP nSEXP, SEXP thetaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rlgser_try(nSEXP, thetaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dlomax NumericVector cpp_dlomax(const NumericVector& x, const NumericVector& lambda, const NumericVector& kappa, const bool& log_prob); static SEXP _extraDistr_cpp_dlomax_try(SEXP xSEXP, SEXP lambdaSEXP, SEXP kappaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type kappa(kappaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dlomax(x, lambda, kappa, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dlomax(SEXP xSEXP, SEXP lambdaSEXP, SEXP kappaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dlomax_try(xSEXP, lambdaSEXP, kappaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_plomax NumericVector cpp_plomax(const NumericVector& x, const NumericVector& lambda, const NumericVector& kappa, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_plomax_try(SEXP xSEXP, SEXP lambdaSEXP, SEXP kappaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type kappa(kappaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_plomax(x, lambda, kappa, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_plomax(SEXP xSEXP, SEXP lambdaSEXP, SEXP kappaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_plomax_try(xSEXP, lambdaSEXP, kappaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qlomax NumericVector cpp_qlomax(const NumericVector& p, const NumericVector& lambda, const NumericVector& kappa, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qlomax_try(SEXP pSEXP, SEXP lambdaSEXP, SEXP kappaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type kappa(kappaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qlomax(p, lambda, kappa, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qlomax(SEXP pSEXP, SEXP lambdaSEXP, SEXP kappaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qlomax_try(pSEXP, lambdaSEXP, kappaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rlomax NumericVector cpp_rlomax(const int& n, const NumericVector& lambda, const NumericVector& kappa); static SEXP _extraDistr_cpp_rlomax_try(SEXP nSEXP, SEXP lambdaSEXP, SEXP kappaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type kappa(kappaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rlomax(n, lambda, kappa)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rlomax(SEXP nSEXP, SEXP lambdaSEXP, SEXP kappaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rlomax_try(nSEXP, lambdaSEXP, kappaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dmixnorm NumericVector cpp_dmixnorm(const NumericVector& x, const NumericMatrix& mu, const NumericMatrix& sigma, const NumericMatrix& alpha, const bool& log_prob); static SEXP _extraDistr_cpp_dmixnorm_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP alphaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dmixnorm(x, mu, sigma, alpha, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dmixnorm(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP alphaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dmixnorm_try(xSEXP, muSEXP, sigmaSEXP, alphaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pmixnorm NumericVector cpp_pmixnorm(const NumericVector& x, const NumericMatrix& mu, const NumericMatrix& sigma, const NumericMatrix& alpha, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pmixnorm_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP alphaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pmixnorm(x, mu, sigma, alpha, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pmixnorm(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP alphaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pmixnorm_try(xSEXP, muSEXP, sigmaSEXP, alphaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rmixnorm NumericVector cpp_rmixnorm(const int& n, const NumericMatrix& mu, const NumericMatrix& sigma, const NumericMatrix& alpha); static SEXP _extraDistr_cpp_rmixnorm_try(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP alphaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type alpha(alphaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rmixnorm(n, mu, sigma, alpha)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rmixnorm(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP alphaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rmixnorm_try(nSEXP, muSEXP, sigmaSEXP, alphaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dmixpois NumericVector cpp_dmixpois(const NumericVector& x, const NumericMatrix& lambda, const NumericMatrix& alpha, const bool& log_prob); static SEXP _extraDistr_cpp_dmixpois_try(SEXP xSEXP, SEXP lambdaSEXP, SEXP alphaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dmixpois(x, lambda, alpha, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dmixpois(SEXP xSEXP, SEXP lambdaSEXP, SEXP alphaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dmixpois_try(xSEXP, lambdaSEXP, alphaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pmixpois NumericVector cpp_pmixpois(const NumericVector& x, const NumericMatrix& lambda, const NumericMatrix& alpha, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pmixpois_try(SEXP xSEXP, SEXP lambdaSEXP, SEXP alphaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pmixpois(x, lambda, alpha, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pmixpois(SEXP xSEXP, SEXP lambdaSEXP, SEXP alphaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pmixpois_try(xSEXP, lambdaSEXP, alphaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rmixpois NumericVector cpp_rmixpois(const int& n, const NumericMatrix& lambda, const NumericMatrix& alpha); static SEXP _extraDistr_cpp_rmixpois_try(SEXP nSEXP, SEXP lambdaSEXP, SEXP alphaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type alpha(alphaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rmixpois(n, lambda, alpha)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rmixpois(SEXP nSEXP, SEXP lambdaSEXP, SEXP alphaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rmixpois_try(nSEXP, lambdaSEXP, alphaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dmnom NumericVector cpp_dmnom(const NumericMatrix& x, const NumericVector& size, const NumericMatrix& prob, const bool& log_prob); static SEXP _extraDistr_cpp_dmnom_try(SEXP xSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericMatrix& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type prob(probSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dmnom(x, size, prob, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dmnom(SEXP xSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dmnom_try(xSEXP, sizeSEXP, probSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rmnom NumericMatrix cpp_rmnom(const int& n, const NumericVector& size, const NumericMatrix& prob); static SEXP _extraDistr_cpp_rmnom_try(SEXP nSEXP, SEXP sizeSEXP, SEXP probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type prob(probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rmnom(n, size, prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rmnom(SEXP nSEXP, SEXP sizeSEXP, SEXP probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rmnom_try(nSEXP, sizeSEXP, probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dmvhyper NumericVector cpp_dmvhyper(const NumericMatrix& x, const NumericMatrix& n, const NumericVector& k, const bool& log_prob); static SEXP _extraDistr_cpp_dmvhyper_try(SEXP xSEXP, SEXP nSEXP, SEXP kSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericMatrix& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type k(kSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dmvhyper(x, n, k, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dmvhyper(SEXP xSEXP, SEXP nSEXP, SEXP kSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dmvhyper_try(xSEXP, nSEXP, kSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rmvhyper NumericMatrix cpp_rmvhyper(const int& nn, const NumericMatrix& n, const NumericVector& k); static SEXP _extraDistr_cpp_rmvhyper_try(SEXP nnSEXP, SEXP nSEXP, SEXP kSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type nn(nnSEXP); Rcpp::traits::input_parameter< const NumericMatrix& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type k(kSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rmvhyper(nn, n, k)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rmvhyper(SEXP nnSEXP, SEXP nSEXP, SEXP kSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rmvhyper_try(nnSEXP, nSEXP, kSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dnhyper NumericVector cpp_dnhyper(const NumericVector& x, const NumericVector& n, const NumericVector& m, const NumericVector& r, const bool& log_prob); static SEXP _extraDistr_cpp_dnhyper_try(SEXP xSEXP, SEXP nSEXP, SEXP mSEXP, SEXP rSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type m(mSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type r(rSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dnhyper(x, n, m, r, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dnhyper(SEXP xSEXP, SEXP nSEXP, SEXP mSEXP, SEXP rSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dnhyper_try(xSEXP, nSEXP, mSEXP, rSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pnhyper NumericVector cpp_pnhyper(const NumericVector& x, const NumericVector& n, const NumericVector& m, const NumericVector& r, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pnhyper_try(SEXP xSEXP, SEXP nSEXP, SEXP mSEXP, SEXP rSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type m(mSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type r(rSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pnhyper(x, n, m, r, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pnhyper(SEXP xSEXP, SEXP nSEXP, SEXP mSEXP, SEXP rSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pnhyper_try(xSEXP, nSEXP, mSEXP, rSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qnhyper NumericVector cpp_qnhyper(const NumericVector& p, const NumericVector& n, const NumericVector& m, const NumericVector& r, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qnhyper_try(SEXP pSEXP, SEXP nSEXP, SEXP mSEXP, SEXP rSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type m(mSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type r(rSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qnhyper(p, n, m, r, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qnhyper(SEXP pSEXP, SEXP nSEXP, SEXP mSEXP, SEXP rSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qnhyper_try(pSEXP, nSEXP, mSEXP, rSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rnhyper NumericVector cpp_rnhyper(const int& nn, const NumericVector& n, const NumericVector& m, const NumericVector& r); static SEXP _extraDistr_cpp_rnhyper_try(SEXP nnSEXP, SEXP nSEXP, SEXP mSEXP, SEXP rSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type nn(nnSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type m(mSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type r(rSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rnhyper(nn, n, m, r)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rnhyper(SEXP nnSEXP, SEXP nSEXP, SEXP mSEXP, SEXP rSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rnhyper_try(nnSEXP, nSEXP, mSEXP, rSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dnsbeta NumericVector cpp_dnsbeta(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& lower, const NumericVector& upper, const bool& log_prob); static SEXP _extraDistr_cpp_dnsbeta_try(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dnsbeta(x, alpha, beta, lower, upper, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dnsbeta(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dnsbeta_try(xSEXP, alphaSEXP, betaSEXP, lowerSEXP, upperSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pnsbeta NumericVector cpp_pnsbeta(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pnsbeta_try(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pnsbeta(x, alpha, beta, lower, upper, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pnsbeta(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pnsbeta_try(xSEXP, alphaSEXP, betaSEXP, lowerSEXP, upperSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qnsbeta NumericVector cpp_qnsbeta(const NumericVector& p, const NumericVector& alpha, const NumericVector& beta, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qnsbeta_try(SEXP pSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qnsbeta(p, alpha, beta, lower, upper, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qnsbeta(SEXP pSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qnsbeta_try(pSEXP, alphaSEXP, betaSEXP, lowerSEXP, upperSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rnsbeta NumericVector cpp_rnsbeta(const int& n, const NumericVector& alpha, const NumericVector& beta, const NumericVector& lower, const NumericVector& upper); static SEXP _extraDistr_cpp_rnsbeta_try(SEXP nSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lowerSEXP, SEXP upperSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rnsbeta(n, alpha, beta, lower, upper)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rnsbeta(SEXP nSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lowerSEXP, SEXP upperSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rnsbeta_try(nSEXP, alphaSEXP, betaSEXP, lowerSEXP, upperSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dpareto NumericVector cpp_dpareto(const NumericVector& x, const NumericVector& a, const NumericVector& b, const bool& log_prob); static SEXP _extraDistr_cpp_dpareto_try(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dpareto(x, a, b, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dpareto(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dpareto_try(xSEXP, aSEXP, bSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_ppareto NumericVector cpp_ppareto(const NumericVector& x, const NumericVector& a, const NumericVector& b, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_ppareto_try(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_ppareto(x, a, b, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_ppareto(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_ppareto_try(xSEXP, aSEXP, bSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qpareto NumericVector cpp_qpareto(const NumericVector& p, const NumericVector& a, const NumericVector& b, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qpareto_try(SEXP pSEXP, SEXP aSEXP, SEXP bSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qpareto(p, a, b, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qpareto(SEXP pSEXP, SEXP aSEXP, SEXP bSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qpareto_try(pSEXP, aSEXP, bSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rpareto NumericVector cpp_rpareto(const int& n, const NumericVector& a, const NumericVector& b); static SEXP _extraDistr_cpp_rpareto_try(SEXP nSEXP, SEXP aSEXP, SEXP bSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rpareto(n, a, b)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rpareto(SEXP nSEXP, SEXP aSEXP, SEXP bSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rpareto_try(nSEXP, aSEXP, bSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dpower NumericVector cpp_dpower(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& log_prob); static SEXP _extraDistr_cpp_dpower_try(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dpower(x, alpha, beta, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dpower(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dpower_try(xSEXP, alphaSEXP, betaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_ppower NumericVector cpp_ppower(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_ppower_try(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_ppower(x, alpha, beta, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_ppower(SEXP xSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_ppower_try(xSEXP, alphaSEXP, betaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qpower NumericVector cpp_qpower(const NumericVector& p, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qpower_try(SEXP pSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qpower(p, alpha, beta, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qpower(SEXP pSEXP, SEXP alphaSEXP, SEXP betaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qpower_try(pSEXP, alphaSEXP, betaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rpower NumericVector cpp_rpower(const int& n, const NumericVector& alpha, const NumericVector& beta); static SEXP _extraDistr_cpp_rpower_try(SEXP nSEXP, SEXP alphaSEXP, SEXP betaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type alpha(alphaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type beta(betaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rpower(n, alpha, beta)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rpower(SEXP nSEXP, SEXP alphaSEXP, SEXP betaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rpower_try(nSEXP, alphaSEXP, betaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dprop NumericVector cpp_dprop(const NumericVector& x, const NumericVector& size, const NumericVector& mean, const NumericVector& prior, const bool& log_prob); static SEXP _extraDistr_cpp_dprop_try(SEXP xSEXP, SEXP sizeSEXP, SEXP meanSEXP, SEXP priorSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mean(meanSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prior(priorSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dprop(x, size, mean, prior, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dprop(SEXP xSEXP, SEXP sizeSEXP, SEXP meanSEXP, SEXP priorSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dprop_try(xSEXP, sizeSEXP, meanSEXP, priorSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pprop NumericVector cpp_pprop(const NumericVector& x, const NumericVector& size, const NumericVector& mean, const NumericVector& prior, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pprop_try(SEXP xSEXP, SEXP sizeSEXP, SEXP meanSEXP, SEXP priorSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mean(meanSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prior(priorSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pprop(x, size, mean, prior, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pprop(SEXP xSEXP, SEXP sizeSEXP, SEXP meanSEXP, SEXP priorSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pprop_try(xSEXP, sizeSEXP, meanSEXP, priorSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qprop NumericVector cpp_qprop(const NumericVector& p, const NumericVector& size, const NumericVector& mean, const NumericVector& prior, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qprop_try(SEXP pSEXP, SEXP sizeSEXP, SEXP meanSEXP, SEXP priorSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mean(meanSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prior(priorSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qprop(p, size, mean, prior, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qprop(SEXP pSEXP, SEXP sizeSEXP, SEXP meanSEXP, SEXP priorSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qprop_try(pSEXP, sizeSEXP, meanSEXP, priorSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rprop NumericVector cpp_rprop(const int& n, const NumericVector& size, const NumericVector& mean, const NumericVector& prior); static SEXP _extraDistr_cpp_rprop_try(SEXP nSEXP, SEXP sizeSEXP, SEXP meanSEXP, SEXP priorSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mean(meanSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prior(priorSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rprop(n, size, mean, prior)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rprop(SEXP nSEXP, SEXP sizeSEXP, SEXP meanSEXP, SEXP priorSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rprop_try(nSEXP, sizeSEXP, meanSEXP, priorSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rsign NumericVector cpp_rsign(const int& n); static SEXP _extraDistr_cpp_rsign_try(SEXP nSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rsign(n)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rsign(SEXP nSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rsign_try(nSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_drayleigh NumericVector cpp_drayleigh(const NumericVector& x, const NumericVector& sigma, const bool& log_prob); static SEXP _extraDistr_cpp_drayleigh_try(SEXP xSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_drayleigh(x, sigma, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_drayleigh(SEXP xSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_drayleigh_try(xSEXP, sigmaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_prayleigh NumericVector cpp_prayleigh(const NumericVector& x, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_prayleigh_try(SEXP xSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_prayleigh(x, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_prayleigh(SEXP xSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_prayleigh_try(xSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qrayleigh NumericVector cpp_qrayleigh(const NumericVector& p, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qrayleigh_try(SEXP pSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qrayleigh(p, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qrayleigh(SEXP pSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qrayleigh_try(pSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rrayleigh NumericVector cpp_rrayleigh(const int& n, const NumericVector& sigma); static SEXP _extraDistr_cpp_rrayleigh_try(SEXP nSEXP, SEXP sigmaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rrayleigh(n, sigma)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rrayleigh(SEXP nSEXP, SEXP sigmaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rrayleigh_try(nSEXP, sigmaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dsgomp NumericVector cpp_dsgomp(const NumericVector& x, const NumericVector& b, const NumericVector& eta, bool log_prob); static SEXP _extraDistr_cpp_dsgomp_try(SEXP xSEXP, SEXP bSEXP, SEXP etaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type eta(etaSEXP); Rcpp::traits::input_parameter< bool >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dsgomp(x, b, eta, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dsgomp(SEXP xSEXP, SEXP bSEXP, SEXP etaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dsgomp_try(xSEXP, bSEXP, etaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_psgomp NumericVector cpp_psgomp(const NumericVector& x, const NumericVector& b, const NumericVector& eta, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_psgomp_try(SEXP xSEXP, SEXP bSEXP, SEXP etaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type eta(etaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_psgomp(x, b, eta, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_psgomp(SEXP xSEXP, SEXP bSEXP, SEXP etaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_psgomp_try(xSEXP, bSEXP, etaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rsgomp NumericVector cpp_rsgomp(const int& n, const NumericVector& b, const NumericVector& eta); static SEXP _extraDistr_cpp_rsgomp_try(SEXP nSEXP, SEXP bSEXP, SEXP etaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type eta(etaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rsgomp(n, b, eta)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rsgomp(SEXP nSEXP, SEXP bSEXP, SEXP etaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rsgomp_try(nSEXP, bSEXP, etaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dskellam NumericVector cpp_dskellam(const NumericVector& x, const NumericVector& mu1, const NumericVector& mu2, const bool& log_prob); static SEXP _extraDistr_cpp_dskellam_try(SEXP xSEXP, SEXP mu1SEXP, SEXP mu2SEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu1(mu1SEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu2(mu2SEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dskellam(x, mu1, mu2, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dskellam(SEXP xSEXP, SEXP mu1SEXP, SEXP mu2SEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dskellam_try(xSEXP, mu1SEXP, mu2SEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rskellam NumericVector cpp_rskellam(const int& n, const NumericVector& mu1, const NumericVector& mu2); static SEXP _extraDistr_cpp_rskellam_try(SEXP nSEXP, SEXP mu1SEXP, SEXP mu2SEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu1(mu1SEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu2(mu2SEXP); rcpp_result_gen = Rcpp::wrap(cpp_rskellam(n, mu1, mu2)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rskellam(SEXP nSEXP, SEXP mu1SEXP, SEXP mu2SEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rskellam_try(nSEXP, mu1SEXP, mu2SEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dslash NumericVector cpp_dslash(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob); static SEXP _extraDistr_cpp_dslash_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dslash(x, mu, sigma, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dslash(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dslash_try(xSEXP, muSEXP, sigmaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pslash NumericVector cpp_pslash(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pslash_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pslash(x, mu, sigma, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pslash(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pslash_try(xSEXP, muSEXP, sigmaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rslash NumericVector cpp_rslash(const int& n, const NumericVector& mu, const NumericVector& sigma); static SEXP _extraDistr_cpp_rslash_try(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rslash(n, mu, sigma)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rslash(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rslash_try(nSEXP, muSEXP, sigmaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dtriang NumericVector cpp_dtriang(const NumericVector& x, const NumericVector& a, const NumericVector& b, const NumericVector& c, const bool& log_prob); static SEXP _extraDistr_cpp_dtriang_try(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP cSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type c(cSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dtriang(x, a, b, c, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dtriang(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP cSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dtriang_try(xSEXP, aSEXP, bSEXP, cSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_ptriang NumericVector cpp_ptriang(const NumericVector& x, const NumericVector& a, const NumericVector& b, const NumericVector& c, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_ptriang_try(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP cSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type c(cSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_ptriang(x, a, b, c, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_ptriang(SEXP xSEXP, SEXP aSEXP, SEXP bSEXP, SEXP cSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_ptriang_try(xSEXP, aSEXP, bSEXP, cSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qtriang NumericVector cpp_qtriang(const NumericVector& p, const NumericVector& a, const NumericVector& b, const NumericVector& c, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qtriang_try(SEXP pSEXP, SEXP aSEXP, SEXP bSEXP, SEXP cSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type c(cSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qtriang(p, a, b, c, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qtriang(SEXP pSEXP, SEXP aSEXP, SEXP bSEXP, SEXP cSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qtriang_try(pSEXP, aSEXP, bSEXP, cSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rtriang NumericVector cpp_rtriang(const int& n, const NumericVector& a, const NumericVector& b, const NumericVector& c); static SEXP _extraDistr_cpp_rtriang_try(SEXP nSEXP, SEXP aSEXP, SEXP bSEXP, SEXP cSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type a(aSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type b(bSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type c(cSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rtriang(n, a, b, c)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rtriang(SEXP nSEXP, SEXP aSEXP, SEXP bSEXP, SEXP cSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rtriang_try(nSEXP, aSEXP, bSEXP, cSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dtbinom NumericVector cpp_dtbinom(const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& lower, const NumericVector& upper, const bool& log_prob); static SEXP _extraDistr_cpp_dtbinom_try(SEXP xSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dtbinom(x, size, prob, lower, upper, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dtbinom(SEXP xSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dtbinom_try(xSEXP, sizeSEXP, probSEXP, lowerSEXP, upperSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_ptbinom NumericVector cpp_ptbinom(const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_ptbinom_try(SEXP xSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_ptbinom(x, size, prob, lower, upper, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_ptbinom(SEXP xSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_ptbinom_try(xSEXP, sizeSEXP, probSEXP, lowerSEXP, upperSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qtbinom NumericVector cpp_qtbinom(const NumericVector& p, const NumericVector& size, const NumericVector& prob, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qtbinom_try(SEXP pSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qtbinom(p, size, prob, lower, upper, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qtbinom(SEXP pSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qtbinom_try(pSEXP, sizeSEXP, probSEXP, lowerSEXP, upperSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rtbinom NumericVector cpp_rtbinom(const int& n, const NumericVector& size, const NumericVector& prob, const NumericVector& lower, const NumericVector& upper); static SEXP _extraDistr_cpp_rtbinom_try(SEXP nSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP lowerSEXP, SEXP upperSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rtbinom(n, size, prob, lower, upper)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rtbinom(SEXP nSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP lowerSEXP, SEXP upperSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rtbinom_try(nSEXP, sizeSEXP, probSEXP, lowerSEXP, upperSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dtnorm NumericVector cpp_dtnorm(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& lower, const NumericVector& upper, const bool& log_prob); static SEXP _extraDistr_cpp_dtnorm_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dtnorm(x, mu, sigma, lower, upper, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dtnorm(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dtnorm_try(xSEXP, muSEXP, sigmaSEXP, lowerSEXP, upperSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_ptnorm NumericVector cpp_ptnorm(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_ptnorm_try(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_ptnorm(x, mu, sigma, lower, upper, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_ptnorm(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_ptnorm_try(xSEXP, muSEXP, sigmaSEXP, lowerSEXP, upperSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qtnorm NumericVector cpp_qtnorm(const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qtnorm_try(SEXP pSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qtnorm(p, mu, sigma, lower, upper, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qtnorm(SEXP pSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qtnorm_try(pSEXP, muSEXP, sigmaSEXP, lowerSEXP, upperSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rtnorm NumericVector cpp_rtnorm(const int& n, const NumericVector& mu, const NumericVector& sigma, const NumericVector& lower, const NumericVector& upper); static SEXP _extraDistr_cpp_rtnorm_try(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lowerSEXP, SEXP upperSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type sigma(sigmaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rtnorm(n, mu, sigma, lower, upper)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rtnorm(SEXP nSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP lowerSEXP, SEXP upperSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rtnorm_try(nSEXP, muSEXP, sigmaSEXP, lowerSEXP, upperSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dtpois NumericVector cpp_dtpois(const NumericVector& x, const NumericVector& lambda, const NumericVector& lower, const NumericVector& upper, const bool& log_prob); static SEXP _extraDistr_cpp_dtpois_try(SEXP xSEXP, SEXP lambdaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dtpois(x, lambda, lower, upper, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dtpois(SEXP xSEXP, SEXP lambdaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dtpois_try(xSEXP, lambdaSEXP, lowerSEXP, upperSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_ptpois NumericVector cpp_ptpois(const NumericVector& x, const NumericVector& lambda, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_ptpois_try(SEXP xSEXP, SEXP lambdaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_ptpois(x, lambda, lower, upper, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_ptpois(SEXP xSEXP, SEXP lambdaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_ptpois_try(xSEXP, lambdaSEXP, lowerSEXP, upperSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qtpois NumericVector cpp_qtpois(const NumericVector& p, const NumericVector& lambda, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qtpois_try(SEXP pSEXP, SEXP lambdaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qtpois(p, lambda, lower, upper, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qtpois(SEXP pSEXP, SEXP lambdaSEXP, SEXP lowerSEXP, SEXP upperSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qtpois_try(pSEXP, lambdaSEXP, lowerSEXP, upperSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rtpois NumericVector cpp_rtpois(const int& n, const NumericVector& lambda, const NumericVector& lower, const NumericVector& upper); static SEXP _extraDistr_cpp_rtpois_try(SEXP nSEXP, SEXP lambdaSEXP, SEXP lowerSEXP, SEXP upperSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lower(lowerSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type upper(upperSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rtpois(n, lambda, lower, upper)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rtpois(SEXP nSEXP, SEXP lambdaSEXP, SEXP lowerSEXP, SEXP upperSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rtpois_try(nSEXP, lambdaSEXP, lowerSEXP, upperSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qtlambda NumericVector cpp_qtlambda(const NumericVector& p, const NumericVector& lambda, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qtlambda_try(SEXP pSEXP, SEXP lambdaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qtlambda(p, lambda, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qtlambda(SEXP pSEXP, SEXP lambdaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qtlambda_try(pSEXP, lambdaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rtlambda NumericVector cpp_rtlambda(const int& n, const NumericVector& lambda); static SEXP _extraDistr_cpp_rtlambda_try(SEXP nSEXP, SEXP lambdaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rtlambda(n, lambda)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rtlambda(SEXP nSEXP, SEXP lambdaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rtlambda_try(nSEXP, lambdaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dwald NumericVector cpp_dwald(const NumericVector& x, const NumericVector& mu, const NumericVector& lambda, const bool& log_prob); static SEXP _extraDistr_cpp_dwald_try(SEXP xSEXP, SEXP muSEXP, SEXP lambdaSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dwald(x, mu, lambda, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dwald(SEXP xSEXP, SEXP muSEXP, SEXP lambdaSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dwald_try(xSEXP, muSEXP, lambdaSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pwald NumericVector cpp_pwald(const NumericVector& x, const NumericVector& mu, const NumericVector& lambda, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pwald_try(SEXP xSEXP, SEXP muSEXP, SEXP lambdaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pwald(x, mu, lambda, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pwald(SEXP xSEXP, SEXP muSEXP, SEXP lambdaSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pwald_try(xSEXP, muSEXP, lambdaSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rwald NumericVector cpp_rwald(const int& n, const NumericVector& mu, const NumericVector& lambda); static SEXP _extraDistr_cpp_rwald_try(SEXP nSEXP, SEXP muSEXP, SEXP lambdaSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type mu(muSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rwald(n, mu, lambda)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rwald(SEXP nSEXP, SEXP muSEXP, SEXP lambdaSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rwald_try(nSEXP, muSEXP, lambdaSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dzib NumericVector cpp_dzib(const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& log_prob); static SEXP _extraDistr_cpp_dzib_try(SEXP xSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type pi(piSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dzib(x, size, prob, pi, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dzib(SEXP xSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dzib_try(xSEXP, sizeSEXP, probSEXP, piSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pzib NumericVector cpp_pzib(const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pzib_try(SEXP xSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type pi(piSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pzib(x, size, prob, pi, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pzib(SEXP xSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pzib_try(xSEXP, sizeSEXP, probSEXP, piSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qzib NumericVector cpp_qzib(const NumericVector& p, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qzib_try(SEXP pSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type pi(piSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qzib(p, size, prob, pi, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qzib(SEXP pSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qzib_try(pSEXP, sizeSEXP, probSEXP, piSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rzib NumericVector cpp_rzib(const int& n, const NumericVector& size, const NumericVector& prob, const NumericVector& pi); static SEXP _extraDistr_cpp_rzib_try(SEXP nSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type pi(piSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rzib(n, size, prob, pi)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rzib(SEXP nSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rzib_try(nSEXP, sizeSEXP, probSEXP, piSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dzinb NumericVector cpp_dzinb(const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& log_prob); static SEXP _extraDistr_cpp_dzinb_try(SEXP xSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type pi(piSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dzinb(x, size, prob, pi, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dzinb(SEXP xSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dzinb_try(xSEXP, sizeSEXP, probSEXP, piSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pzinb NumericVector cpp_pzinb(const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pzinb_try(SEXP xSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type pi(piSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pzinb(x, size, prob, pi, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pzinb(SEXP xSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pzinb_try(xSEXP, sizeSEXP, probSEXP, piSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qzinb NumericVector cpp_qzinb(const NumericVector& p, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qzinb_try(SEXP pSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type pi(piSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qzinb(p, size, prob, pi, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qzinb(SEXP pSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qzinb_try(pSEXP, sizeSEXP, probSEXP, piSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rzinb NumericVector cpp_rzinb(const int& n, const NumericVector& size, const NumericVector& prob, const NumericVector& pi); static SEXP _extraDistr_cpp_rzinb_try(SEXP nSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type size(sizeSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type prob(probSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type pi(piSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rzinb(n, size, prob, pi)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rzinb(SEXP nSEXP, SEXP sizeSEXP, SEXP probSEXP, SEXP piSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rzinb_try(nSEXP, sizeSEXP, probSEXP, piSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_dzip NumericVector cpp_dzip(const NumericVector& x, const NumericVector& lambda, const NumericVector& pi, const bool& log_prob); static SEXP _extraDistr_cpp_dzip_try(SEXP xSEXP, SEXP lambdaSEXP, SEXP piSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type pi(piSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_dzip(x, lambda, pi, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_dzip(SEXP xSEXP, SEXP lambdaSEXP, SEXP piSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_dzip_try(xSEXP, lambdaSEXP, piSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_pzip NumericVector cpp_pzip(const NumericVector& x, const NumericVector& lambda, const NumericVector& pi, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_pzip_try(SEXP xSEXP, SEXP lambdaSEXP, SEXP piSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type x(xSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type pi(piSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_pzip(x, lambda, pi, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_pzip(SEXP xSEXP, SEXP lambdaSEXP, SEXP piSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_pzip_try(xSEXP, lambdaSEXP, piSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_qzip NumericVector cpp_qzip(const NumericVector& p, const NumericVector& lambda, const NumericVector& pi, const bool& lower_tail, const bool& log_prob); static SEXP _extraDistr_cpp_qzip_try(SEXP pSEXP, SEXP lambdaSEXP, SEXP piSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const NumericVector& >::type p(pSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type pi(piSEXP); Rcpp::traits::input_parameter< const bool& >::type lower_tail(lower_tailSEXP); Rcpp::traits::input_parameter< const bool& >::type log_prob(log_probSEXP); rcpp_result_gen = Rcpp::wrap(cpp_qzip(p, lambda, pi, lower_tail, log_prob)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_qzip(SEXP pSEXP, SEXP lambdaSEXP, SEXP piSEXP, SEXP lower_tailSEXP, SEXP log_probSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_qzip_try(pSEXP, lambdaSEXP, piSEXP, lower_tailSEXP, log_probSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // cpp_rzip NumericVector cpp_rzip(const int& n, const NumericVector& lambda, const NumericVector& pi); static SEXP _extraDistr_cpp_rzip_try(SEXP nSEXP, SEXP lambdaSEXP, SEXP piSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::traits::input_parameter< const int& >::type n(nSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type lambda(lambdaSEXP); Rcpp::traits::input_parameter< const NumericVector& >::type pi(piSEXP); rcpp_result_gen = Rcpp::wrap(cpp_rzip(n, lambda, pi)); return rcpp_result_gen; END_RCPP_RETURN_ERROR } RcppExport SEXP _extraDistr_cpp_rzip(SEXP nSEXP, SEXP lambdaSEXP, SEXP piSEXP) { SEXP rcpp_result_gen; { Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = PROTECT(_extraDistr_cpp_rzip_try(nSEXP, lambdaSEXP, piSEXP)); } Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error"); if (rcpp_isInterrupt_gen) { UNPROTECT(1); Rf_onintr(); } bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen); if (rcpp_isLongjump_gen) { Rcpp::internal::resumeJump(rcpp_result_gen); } Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error"); if (rcpp_isError_gen) { SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen); UNPROTECT(1); Rf_error("%s", CHAR(rcpp_msgSEXP_gen)); } UNPROTECT(1); return rcpp_result_gen; } // validate (ensure exported C++ functions exist before calling them) static int _extraDistr_RcppExport_validate(const char* sig) { static std::set signatures; if (signatures.empty()) { signatures.insert("NumericVector(*cpp_dbern)(const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pbern)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qbern)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rbern)(const int&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dbbinom)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pbbinom)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rbbinom)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dbnbinom)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pbnbinom)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rbnbinom)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dbetapr)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pbetapr)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qbetapr)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rbetapr)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dbhatt)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pbhatt)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rbhatt)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dfatigue)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pfatigue)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qfatigue)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rfatigue)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dbnorm)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericMatrix(*cpp_rbnorm)(const int&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dbpois)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericMatrix(*cpp_rbpois)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_rcatlp)(const int&,const NumericMatrix&)"); signatures.insert("NumericVector(*cpp_dcat)(const NumericVector&,const NumericMatrix&,const bool&)"); signatures.insert("NumericVector(*cpp_pcat)(const NumericVector&,const NumericMatrix&,bool,bool)"); signatures.insert("NumericVector(*cpp_qcat)(const NumericVector&,const NumericMatrix&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rcat)(const int&,const NumericMatrix&)"); signatures.insert("NumericVector(*cpp_ddirichlet)(const NumericMatrix&,const NumericMatrix&,const bool&)"); signatures.insert("NumericMatrix(*cpp_rdirichlet)(const int&,const NumericMatrix&)"); signatures.insert("NumericVector(*cpp_ddirmnom)(const NumericMatrix&,const NumericVector&,const NumericMatrix&,const bool&)"); signatures.insert("NumericMatrix(*cpp_rdirmnom)(const int&,const NumericVector&,const NumericMatrix&)"); signatures.insert("NumericVector(*cpp_ddgamma)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_ddlaplace)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pdlaplace)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rdlaplace)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_ddnorm)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_ddunif)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pdunif)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qdunif)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rdunif)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_ddweibull)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pdweibull)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qdweibull)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rdweibull)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dfrechet)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pfrechet)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qfrechet)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rfrechet)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dgpois)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pgpois)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rgpois)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dgev)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pgev)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,bool,bool)"); signatures.insert("NumericVector(*cpp_qgev)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,bool,bool)"); signatures.insert("NumericVector(*cpp_rgev)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dgompertz)(const NumericVector&,const NumericVector&,const NumericVector&,bool)"); signatures.insert("NumericVector(*cpp_pgompertz)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qgompertz)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rgompertz)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dgpd)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pgpd)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qgpd)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rgpd)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dgumbel)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pgumbel)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qgumbel)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rgumbel)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dhcauchy)(const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_phcauchy)(const NumericVector&,const NumericVector&,bool,bool)"); signatures.insert("NumericVector(*cpp_qhcauchy)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rhcauchy)(const int&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dhnorm)(const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_phnorm)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qhnorm)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rhnorm)(const int&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dht)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pht)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qht)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rht)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dhuber)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_phuber)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qhuber)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rhuber)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dinvgamma)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pinvgamma)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_dkumar)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pkumar)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qkumar)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rkumar)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dlaplace)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_plaplace)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qlaplace)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rlaplace)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dlst)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_plst)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qlst)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rlst)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dlgser)(const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_plgser)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qlgser)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rlgser)(const int&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dlomax)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_plomax)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qlomax)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rlomax)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dmixnorm)(const NumericVector&,const NumericMatrix&,const NumericMatrix&,const NumericMatrix&,const bool&)"); signatures.insert("NumericVector(*cpp_pmixnorm)(const NumericVector&,const NumericMatrix&,const NumericMatrix&,const NumericMatrix&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rmixnorm)(const int&,const NumericMatrix&,const NumericMatrix&,const NumericMatrix&)"); signatures.insert("NumericVector(*cpp_dmixpois)(const NumericVector&,const NumericMatrix&,const NumericMatrix&,const bool&)"); signatures.insert("NumericVector(*cpp_pmixpois)(const NumericVector&,const NumericMatrix&,const NumericMatrix&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rmixpois)(const int&,const NumericMatrix&,const NumericMatrix&)"); signatures.insert("NumericVector(*cpp_dmnom)(const NumericMatrix&,const NumericVector&,const NumericMatrix&,const bool&)"); signatures.insert("NumericMatrix(*cpp_rmnom)(const int&,const NumericVector&,const NumericMatrix&)"); signatures.insert("NumericVector(*cpp_dmvhyper)(const NumericMatrix&,const NumericMatrix&,const NumericVector&,const bool&)"); signatures.insert("NumericMatrix(*cpp_rmvhyper)(const int&,const NumericMatrix&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dnhyper)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pnhyper)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qnhyper)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rnhyper)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dnsbeta)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pnsbeta)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qnsbeta)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rnsbeta)(const int&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dpareto)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_ppareto)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qpareto)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rpareto)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dpower)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_ppower)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qpower)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rpower)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dprop)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pprop)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qprop)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rprop)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_rsign)(const int&)"); signatures.insert("NumericVector(*cpp_drayleigh)(const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_prayleigh)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qrayleigh)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rrayleigh)(const int&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dsgomp)(const NumericVector&,const NumericVector&,const NumericVector&,bool)"); signatures.insert("NumericVector(*cpp_psgomp)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rsgomp)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dskellam)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_rskellam)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dslash)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pslash)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rslash)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dtriang)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_ptriang)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qtriang)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rtriang)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dtbinom)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_ptbinom)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qtbinom)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rtbinom)(const int&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dtnorm)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_ptnorm)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qtnorm)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rtnorm)(const int&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dtpois)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_ptpois)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qtpois)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rtpois)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_qtlambda)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rtlambda)(const int&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dwald)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pwald)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rwald)(const int&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dzib)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pzib)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qzib)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rzib)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dzinb)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pzinb)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qzinb)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rzinb)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); signatures.insert("NumericVector(*cpp_dzip)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); signatures.insert("NumericVector(*cpp_pzip)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_qzip)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); signatures.insert("NumericVector(*cpp_rzip)(const int&,const NumericVector&,const NumericVector&)"); } return signatures.find(sig) != signatures.end(); } // registerCCallable (register entry points for exported C++ functions) RcppExport SEXP _extraDistr_RcppExport_registerCCallable() { R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dbern", (DL_FUNC)_extraDistr_cpp_dbern_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pbern", (DL_FUNC)_extraDistr_cpp_pbern_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qbern", (DL_FUNC)_extraDistr_cpp_qbern_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rbern", (DL_FUNC)_extraDistr_cpp_rbern_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dbbinom", (DL_FUNC)_extraDistr_cpp_dbbinom_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pbbinom", (DL_FUNC)_extraDistr_cpp_pbbinom_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rbbinom", (DL_FUNC)_extraDistr_cpp_rbbinom_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dbnbinom", (DL_FUNC)_extraDistr_cpp_dbnbinom_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pbnbinom", (DL_FUNC)_extraDistr_cpp_pbnbinom_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rbnbinom", (DL_FUNC)_extraDistr_cpp_rbnbinom_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dbetapr", (DL_FUNC)_extraDistr_cpp_dbetapr_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pbetapr", (DL_FUNC)_extraDistr_cpp_pbetapr_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qbetapr", (DL_FUNC)_extraDistr_cpp_qbetapr_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rbetapr", (DL_FUNC)_extraDistr_cpp_rbetapr_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dbhatt", (DL_FUNC)_extraDistr_cpp_dbhatt_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pbhatt", (DL_FUNC)_extraDistr_cpp_pbhatt_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rbhatt", (DL_FUNC)_extraDistr_cpp_rbhatt_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dfatigue", (DL_FUNC)_extraDistr_cpp_dfatigue_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pfatigue", (DL_FUNC)_extraDistr_cpp_pfatigue_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qfatigue", (DL_FUNC)_extraDistr_cpp_qfatigue_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rfatigue", (DL_FUNC)_extraDistr_cpp_rfatigue_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dbnorm", (DL_FUNC)_extraDistr_cpp_dbnorm_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rbnorm", (DL_FUNC)_extraDistr_cpp_rbnorm_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dbpois", (DL_FUNC)_extraDistr_cpp_dbpois_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rbpois", (DL_FUNC)_extraDistr_cpp_rbpois_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rcatlp", (DL_FUNC)_extraDistr_cpp_rcatlp_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dcat", (DL_FUNC)_extraDistr_cpp_dcat_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pcat", (DL_FUNC)_extraDistr_cpp_pcat_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qcat", (DL_FUNC)_extraDistr_cpp_qcat_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rcat", (DL_FUNC)_extraDistr_cpp_rcat_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_ddirichlet", (DL_FUNC)_extraDistr_cpp_ddirichlet_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rdirichlet", (DL_FUNC)_extraDistr_cpp_rdirichlet_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_ddirmnom", (DL_FUNC)_extraDistr_cpp_ddirmnom_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rdirmnom", (DL_FUNC)_extraDistr_cpp_rdirmnom_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_ddgamma", (DL_FUNC)_extraDistr_cpp_ddgamma_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_ddlaplace", (DL_FUNC)_extraDistr_cpp_ddlaplace_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pdlaplace", (DL_FUNC)_extraDistr_cpp_pdlaplace_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rdlaplace", (DL_FUNC)_extraDistr_cpp_rdlaplace_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_ddnorm", (DL_FUNC)_extraDistr_cpp_ddnorm_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_ddunif", (DL_FUNC)_extraDistr_cpp_ddunif_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pdunif", (DL_FUNC)_extraDistr_cpp_pdunif_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qdunif", (DL_FUNC)_extraDistr_cpp_qdunif_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rdunif", (DL_FUNC)_extraDistr_cpp_rdunif_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_ddweibull", (DL_FUNC)_extraDistr_cpp_ddweibull_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pdweibull", (DL_FUNC)_extraDistr_cpp_pdweibull_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qdweibull", (DL_FUNC)_extraDistr_cpp_qdweibull_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rdweibull", (DL_FUNC)_extraDistr_cpp_rdweibull_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dfrechet", (DL_FUNC)_extraDistr_cpp_dfrechet_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pfrechet", (DL_FUNC)_extraDistr_cpp_pfrechet_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qfrechet", (DL_FUNC)_extraDistr_cpp_qfrechet_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rfrechet", (DL_FUNC)_extraDistr_cpp_rfrechet_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dgpois", (DL_FUNC)_extraDistr_cpp_dgpois_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pgpois", (DL_FUNC)_extraDistr_cpp_pgpois_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rgpois", (DL_FUNC)_extraDistr_cpp_rgpois_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dgev", (DL_FUNC)_extraDistr_cpp_dgev_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pgev", (DL_FUNC)_extraDistr_cpp_pgev_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qgev", (DL_FUNC)_extraDistr_cpp_qgev_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rgev", (DL_FUNC)_extraDistr_cpp_rgev_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dgompertz", (DL_FUNC)_extraDistr_cpp_dgompertz_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pgompertz", (DL_FUNC)_extraDistr_cpp_pgompertz_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qgompertz", (DL_FUNC)_extraDistr_cpp_qgompertz_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rgompertz", (DL_FUNC)_extraDistr_cpp_rgompertz_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dgpd", (DL_FUNC)_extraDistr_cpp_dgpd_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pgpd", (DL_FUNC)_extraDistr_cpp_pgpd_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qgpd", (DL_FUNC)_extraDistr_cpp_qgpd_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rgpd", (DL_FUNC)_extraDistr_cpp_rgpd_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dgumbel", (DL_FUNC)_extraDistr_cpp_dgumbel_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pgumbel", (DL_FUNC)_extraDistr_cpp_pgumbel_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qgumbel", (DL_FUNC)_extraDistr_cpp_qgumbel_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rgumbel", (DL_FUNC)_extraDistr_cpp_rgumbel_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dhcauchy", (DL_FUNC)_extraDistr_cpp_dhcauchy_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_phcauchy", (DL_FUNC)_extraDistr_cpp_phcauchy_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qhcauchy", (DL_FUNC)_extraDistr_cpp_qhcauchy_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rhcauchy", (DL_FUNC)_extraDistr_cpp_rhcauchy_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dhnorm", (DL_FUNC)_extraDistr_cpp_dhnorm_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_phnorm", (DL_FUNC)_extraDistr_cpp_phnorm_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qhnorm", (DL_FUNC)_extraDistr_cpp_qhnorm_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rhnorm", (DL_FUNC)_extraDistr_cpp_rhnorm_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dht", (DL_FUNC)_extraDistr_cpp_dht_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pht", (DL_FUNC)_extraDistr_cpp_pht_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qht", (DL_FUNC)_extraDistr_cpp_qht_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rht", (DL_FUNC)_extraDistr_cpp_rht_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dhuber", (DL_FUNC)_extraDistr_cpp_dhuber_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_phuber", (DL_FUNC)_extraDistr_cpp_phuber_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qhuber", (DL_FUNC)_extraDistr_cpp_qhuber_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rhuber", (DL_FUNC)_extraDistr_cpp_rhuber_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dinvgamma", (DL_FUNC)_extraDistr_cpp_dinvgamma_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pinvgamma", (DL_FUNC)_extraDistr_cpp_pinvgamma_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dkumar", (DL_FUNC)_extraDistr_cpp_dkumar_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pkumar", (DL_FUNC)_extraDistr_cpp_pkumar_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qkumar", (DL_FUNC)_extraDistr_cpp_qkumar_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rkumar", (DL_FUNC)_extraDistr_cpp_rkumar_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dlaplace", (DL_FUNC)_extraDistr_cpp_dlaplace_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_plaplace", (DL_FUNC)_extraDistr_cpp_plaplace_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qlaplace", (DL_FUNC)_extraDistr_cpp_qlaplace_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rlaplace", (DL_FUNC)_extraDistr_cpp_rlaplace_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dlst", (DL_FUNC)_extraDistr_cpp_dlst_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_plst", (DL_FUNC)_extraDistr_cpp_plst_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qlst", (DL_FUNC)_extraDistr_cpp_qlst_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rlst", (DL_FUNC)_extraDistr_cpp_rlst_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dlgser", (DL_FUNC)_extraDistr_cpp_dlgser_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_plgser", (DL_FUNC)_extraDistr_cpp_plgser_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qlgser", (DL_FUNC)_extraDistr_cpp_qlgser_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rlgser", (DL_FUNC)_extraDistr_cpp_rlgser_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dlomax", (DL_FUNC)_extraDistr_cpp_dlomax_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_plomax", (DL_FUNC)_extraDistr_cpp_plomax_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qlomax", (DL_FUNC)_extraDistr_cpp_qlomax_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rlomax", (DL_FUNC)_extraDistr_cpp_rlomax_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dmixnorm", (DL_FUNC)_extraDistr_cpp_dmixnorm_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pmixnorm", (DL_FUNC)_extraDistr_cpp_pmixnorm_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rmixnorm", (DL_FUNC)_extraDistr_cpp_rmixnorm_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dmixpois", (DL_FUNC)_extraDistr_cpp_dmixpois_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pmixpois", (DL_FUNC)_extraDistr_cpp_pmixpois_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rmixpois", (DL_FUNC)_extraDistr_cpp_rmixpois_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dmnom", (DL_FUNC)_extraDistr_cpp_dmnom_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rmnom", (DL_FUNC)_extraDistr_cpp_rmnom_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dmvhyper", (DL_FUNC)_extraDistr_cpp_dmvhyper_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rmvhyper", (DL_FUNC)_extraDistr_cpp_rmvhyper_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dnhyper", (DL_FUNC)_extraDistr_cpp_dnhyper_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pnhyper", (DL_FUNC)_extraDistr_cpp_pnhyper_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qnhyper", (DL_FUNC)_extraDistr_cpp_qnhyper_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rnhyper", (DL_FUNC)_extraDistr_cpp_rnhyper_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dnsbeta", (DL_FUNC)_extraDistr_cpp_dnsbeta_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pnsbeta", (DL_FUNC)_extraDistr_cpp_pnsbeta_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qnsbeta", (DL_FUNC)_extraDistr_cpp_qnsbeta_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rnsbeta", (DL_FUNC)_extraDistr_cpp_rnsbeta_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dpareto", (DL_FUNC)_extraDistr_cpp_dpareto_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_ppareto", (DL_FUNC)_extraDistr_cpp_ppareto_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qpareto", (DL_FUNC)_extraDistr_cpp_qpareto_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rpareto", (DL_FUNC)_extraDistr_cpp_rpareto_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dpower", (DL_FUNC)_extraDistr_cpp_dpower_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_ppower", (DL_FUNC)_extraDistr_cpp_ppower_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qpower", (DL_FUNC)_extraDistr_cpp_qpower_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rpower", (DL_FUNC)_extraDistr_cpp_rpower_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dprop", (DL_FUNC)_extraDistr_cpp_dprop_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pprop", (DL_FUNC)_extraDistr_cpp_pprop_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qprop", (DL_FUNC)_extraDistr_cpp_qprop_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rprop", (DL_FUNC)_extraDistr_cpp_rprop_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rsign", (DL_FUNC)_extraDistr_cpp_rsign_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_drayleigh", (DL_FUNC)_extraDistr_cpp_drayleigh_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_prayleigh", (DL_FUNC)_extraDistr_cpp_prayleigh_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qrayleigh", (DL_FUNC)_extraDistr_cpp_qrayleigh_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rrayleigh", (DL_FUNC)_extraDistr_cpp_rrayleigh_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dsgomp", (DL_FUNC)_extraDistr_cpp_dsgomp_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_psgomp", (DL_FUNC)_extraDistr_cpp_psgomp_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rsgomp", (DL_FUNC)_extraDistr_cpp_rsgomp_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dskellam", (DL_FUNC)_extraDistr_cpp_dskellam_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rskellam", (DL_FUNC)_extraDistr_cpp_rskellam_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dslash", (DL_FUNC)_extraDistr_cpp_dslash_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pslash", (DL_FUNC)_extraDistr_cpp_pslash_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rslash", (DL_FUNC)_extraDistr_cpp_rslash_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dtriang", (DL_FUNC)_extraDistr_cpp_dtriang_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_ptriang", (DL_FUNC)_extraDistr_cpp_ptriang_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qtriang", (DL_FUNC)_extraDistr_cpp_qtriang_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rtriang", (DL_FUNC)_extraDistr_cpp_rtriang_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dtbinom", (DL_FUNC)_extraDistr_cpp_dtbinom_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_ptbinom", (DL_FUNC)_extraDistr_cpp_ptbinom_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qtbinom", (DL_FUNC)_extraDistr_cpp_qtbinom_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rtbinom", (DL_FUNC)_extraDistr_cpp_rtbinom_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dtnorm", (DL_FUNC)_extraDistr_cpp_dtnorm_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_ptnorm", (DL_FUNC)_extraDistr_cpp_ptnorm_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qtnorm", (DL_FUNC)_extraDistr_cpp_qtnorm_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rtnorm", (DL_FUNC)_extraDistr_cpp_rtnorm_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dtpois", (DL_FUNC)_extraDistr_cpp_dtpois_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_ptpois", (DL_FUNC)_extraDistr_cpp_ptpois_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qtpois", (DL_FUNC)_extraDistr_cpp_qtpois_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rtpois", (DL_FUNC)_extraDistr_cpp_rtpois_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qtlambda", (DL_FUNC)_extraDistr_cpp_qtlambda_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rtlambda", (DL_FUNC)_extraDistr_cpp_rtlambda_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dwald", (DL_FUNC)_extraDistr_cpp_dwald_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pwald", (DL_FUNC)_extraDistr_cpp_pwald_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rwald", (DL_FUNC)_extraDistr_cpp_rwald_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dzib", (DL_FUNC)_extraDistr_cpp_dzib_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pzib", (DL_FUNC)_extraDistr_cpp_pzib_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qzib", (DL_FUNC)_extraDistr_cpp_qzib_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rzib", (DL_FUNC)_extraDistr_cpp_rzib_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dzinb", (DL_FUNC)_extraDistr_cpp_dzinb_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pzinb", (DL_FUNC)_extraDistr_cpp_pzinb_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qzinb", (DL_FUNC)_extraDistr_cpp_qzinb_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rzinb", (DL_FUNC)_extraDistr_cpp_rzinb_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_dzip", (DL_FUNC)_extraDistr_cpp_dzip_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_pzip", (DL_FUNC)_extraDistr_cpp_pzip_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_qzip", (DL_FUNC)_extraDistr_cpp_qzip_try); R_RegisterCCallable("extraDistr", "_extraDistr_cpp_rzip", (DL_FUNC)_extraDistr_cpp_rzip_try); R_RegisterCCallable("extraDistr", "_extraDistr_RcppExport_validate", (DL_FUNC)_extraDistr_RcppExport_validate); return R_NilValue; } static const R_CallMethodDef CallEntries[] = { {"_extraDistr_cpp_dbern", (DL_FUNC) &_extraDistr_cpp_dbern, 3}, {"_extraDistr_cpp_pbern", (DL_FUNC) &_extraDistr_cpp_pbern, 4}, {"_extraDistr_cpp_qbern", (DL_FUNC) &_extraDistr_cpp_qbern, 4}, {"_extraDistr_cpp_rbern", (DL_FUNC) &_extraDistr_cpp_rbern, 2}, {"_extraDistr_cpp_dbbinom", (DL_FUNC) &_extraDistr_cpp_dbbinom, 5}, {"_extraDistr_cpp_pbbinom", (DL_FUNC) &_extraDistr_cpp_pbbinom, 6}, {"_extraDistr_cpp_rbbinom", (DL_FUNC) &_extraDistr_cpp_rbbinom, 4}, {"_extraDistr_cpp_dbnbinom", (DL_FUNC) &_extraDistr_cpp_dbnbinom, 5}, {"_extraDistr_cpp_pbnbinom", (DL_FUNC) &_extraDistr_cpp_pbnbinom, 6}, {"_extraDistr_cpp_rbnbinom", (DL_FUNC) &_extraDistr_cpp_rbnbinom, 4}, {"_extraDistr_cpp_dbetapr", (DL_FUNC) &_extraDistr_cpp_dbetapr, 5}, {"_extraDistr_cpp_pbetapr", (DL_FUNC) &_extraDistr_cpp_pbetapr, 6}, {"_extraDistr_cpp_qbetapr", (DL_FUNC) &_extraDistr_cpp_qbetapr, 6}, {"_extraDistr_cpp_rbetapr", (DL_FUNC) &_extraDistr_cpp_rbetapr, 4}, {"_extraDistr_cpp_dbhatt", (DL_FUNC) &_extraDistr_cpp_dbhatt, 5}, {"_extraDistr_cpp_pbhatt", (DL_FUNC) &_extraDistr_cpp_pbhatt, 6}, {"_extraDistr_cpp_rbhatt", (DL_FUNC) &_extraDistr_cpp_rbhatt, 4}, {"_extraDistr_cpp_dfatigue", (DL_FUNC) &_extraDistr_cpp_dfatigue, 5}, {"_extraDistr_cpp_pfatigue", (DL_FUNC) &_extraDistr_cpp_pfatigue, 6}, {"_extraDistr_cpp_qfatigue", (DL_FUNC) &_extraDistr_cpp_qfatigue, 6}, {"_extraDistr_cpp_rfatigue", (DL_FUNC) &_extraDistr_cpp_rfatigue, 4}, {"_extraDistr_cpp_dbnorm", (DL_FUNC) &_extraDistr_cpp_dbnorm, 8}, {"_extraDistr_cpp_rbnorm", (DL_FUNC) &_extraDistr_cpp_rbnorm, 6}, {"_extraDistr_cpp_dbpois", (DL_FUNC) &_extraDistr_cpp_dbpois, 6}, {"_extraDistr_cpp_rbpois", (DL_FUNC) &_extraDistr_cpp_rbpois, 4}, {"_extraDistr_cpp_rcatlp", (DL_FUNC) &_extraDistr_cpp_rcatlp, 2}, {"_extraDistr_cpp_dcat", (DL_FUNC) &_extraDistr_cpp_dcat, 3}, {"_extraDistr_cpp_pcat", (DL_FUNC) &_extraDistr_cpp_pcat, 4}, {"_extraDistr_cpp_qcat", (DL_FUNC) &_extraDistr_cpp_qcat, 4}, {"_extraDistr_cpp_rcat", (DL_FUNC) &_extraDistr_cpp_rcat, 2}, {"_extraDistr_cpp_ddirichlet", (DL_FUNC) &_extraDistr_cpp_ddirichlet, 3}, {"_extraDistr_cpp_rdirichlet", (DL_FUNC) &_extraDistr_cpp_rdirichlet, 2}, {"_extraDistr_cpp_ddirmnom", (DL_FUNC) &_extraDistr_cpp_ddirmnom, 4}, {"_extraDistr_cpp_rdirmnom", (DL_FUNC) &_extraDistr_cpp_rdirmnom, 3}, {"_extraDistr_cpp_ddgamma", (DL_FUNC) &_extraDistr_cpp_ddgamma, 4}, {"_extraDistr_cpp_ddlaplace", (DL_FUNC) &_extraDistr_cpp_ddlaplace, 4}, {"_extraDistr_cpp_pdlaplace", (DL_FUNC) &_extraDistr_cpp_pdlaplace, 5}, {"_extraDistr_cpp_rdlaplace", (DL_FUNC) &_extraDistr_cpp_rdlaplace, 3}, {"_extraDistr_cpp_ddnorm", (DL_FUNC) &_extraDistr_cpp_ddnorm, 4}, {"_extraDistr_cpp_ddunif", (DL_FUNC) &_extraDistr_cpp_ddunif, 4}, {"_extraDistr_cpp_pdunif", (DL_FUNC) &_extraDistr_cpp_pdunif, 5}, {"_extraDistr_cpp_qdunif", (DL_FUNC) &_extraDistr_cpp_qdunif, 5}, {"_extraDistr_cpp_rdunif", (DL_FUNC) &_extraDistr_cpp_rdunif, 3}, {"_extraDistr_cpp_ddweibull", (DL_FUNC) &_extraDistr_cpp_ddweibull, 4}, {"_extraDistr_cpp_pdweibull", (DL_FUNC) &_extraDistr_cpp_pdweibull, 5}, {"_extraDistr_cpp_qdweibull", (DL_FUNC) &_extraDistr_cpp_qdweibull, 5}, {"_extraDistr_cpp_rdweibull", (DL_FUNC) &_extraDistr_cpp_rdweibull, 3}, {"_extraDistr_cpp_dfrechet", (DL_FUNC) &_extraDistr_cpp_dfrechet, 5}, {"_extraDistr_cpp_pfrechet", (DL_FUNC) &_extraDistr_cpp_pfrechet, 6}, {"_extraDistr_cpp_qfrechet", (DL_FUNC) &_extraDistr_cpp_qfrechet, 6}, {"_extraDistr_cpp_rfrechet", (DL_FUNC) &_extraDistr_cpp_rfrechet, 4}, {"_extraDistr_cpp_dgpois", (DL_FUNC) &_extraDistr_cpp_dgpois, 4}, {"_extraDistr_cpp_pgpois", (DL_FUNC) &_extraDistr_cpp_pgpois, 5}, {"_extraDistr_cpp_rgpois", (DL_FUNC) &_extraDistr_cpp_rgpois, 3}, {"_extraDistr_cpp_dgev", (DL_FUNC) &_extraDistr_cpp_dgev, 5}, {"_extraDistr_cpp_pgev", (DL_FUNC) &_extraDistr_cpp_pgev, 6}, {"_extraDistr_cpp_qgev", (DL_FUNC) &_extraDistr_cpp_qgev, 6}, {"_extraDistr_cpp_rgev", (DL_FUNC) &_extraDistr_cpp_rgev, 4}, {"_extraDistr_cpp_dgompertz", (DL_FUNC) &_extraDistr_cpp_dgompertz, 4}, {"_extraDistr_cpp_pgompertz", (DL_FUNC) &_extraDistr_cpp_pgompertz, 5}, {"_extraDistr_cpp_qgompertz", (DL_FUNC) &_extraDistr_cpp_qgompertz, 5}, {"_extraDistr_cpp_rgompertz", (DL_FUNC) &_extraDistr_cpp_rgompertz, 3}, {"_extraDistr_cpp_dgpd", (DL_FUNC) &_extraDistr_cpp_dgpd, 5}, {"_extraDistr_cpp_pgpd", (DL_FUNC) &_extraDistr_cpp_pgpd, 6}, {"_extraDistr_cpp_qgpd", (DL_FUNC) &_extraDistr_cpp_qgpd, 6}, {"_extraDistr_cpp_rgpd", (DL_FUNC) &_extraDistr_cpp_rgpd, 4}, {"_extraDistr_cpp_dgumbel", (DL_FUNC) &_extraDistr_cpp_dgumbel, 4}, {"_extraDistr_cpp_pgumbel", (DL_FUNC) &_extraDistr_cpp_pgumbel, 5}, {"_extraDistr_cpp_qgumbel", (DL_FUNC) &_extraDistr_cpp_qgumbel, 5}, {"_extraDistr_cpp_rgumbel", (DL_FUNC) &_extraDistr_cpp_rgumbel, 3}, {"_extraDistr_cpp_dhcauchy", (DL_FUNC) &_extraDistr_cpp_dhcauchy, 3}, {"_extraDistr_cpp_phcauchy", (DL_FUNC) &_extraDistr_cpp_phcauchy, 4}, {"_extraDistr_cpp_qhcauchy", (DL_FUNC) &_extraDistr_cpp_qhcauchy, 4}, {"_extraDistr_cpp_rhcauchy", (DL_FUNC) &_extraDistr_cpp_rhcauchy, 2}, {"_extraDistr_cpp_dhnorm", (DL_FUNC) &_extraDistr_cpp_dhnorm, 3}, {"_extraDistr_cpp_phnorm", (DL_FUNC) &_extraDistr_cpp_phnorm, 4}, {"_extraDistr_cpp_qhnorm", (DL_FUNC) &_extraDistr_cpp_qhnorm, 4}, {"_extraDistr_cpp_rhnorm", (DL_FUNC) &_extraDistr_cpp_rhnorm, 2}, {"_extraDistr_cpp_dht", (DL_FUNC) &_extraDistr_cpp_dht, 4}, {"_extraDistr_cpp_pht", (DL_FUNC) &_extraDistr_cpp_pht, 5}, {"_extraDistr_cpp_qht", (DL_FUNC) &_extraDistr_cpp_qht, 5}, {"_extraDistr_cpp_rht", (DL_FUNC) &_extraDistr_cpp_rht, 3}, {"_extraDistr_cpp_dhuber", (DL_FUNC) &_extraDistr_cpp_dhuber, 5}, {"_extraDistr_cpp_phuber", (DL_FUNC) &_extraDistr_cpp_phuber, 6}, {"_extraDistr_cpp_qhuber", (DL_FUNC) &_extraDistr_cpp_qhuber, 6}, {"_extraDistr_cpp_rhuber", (DL_FUNC) &_extraDistr_cpp_rhuber, 4}, {"_extraDistr_cpp_dinvgamma", (DL_FUNC) &_extraDistr_cpp_dinvgamma, 4}, {"_extraDistr_cpp_pinvgamma", (DL_FUNC) &_extraDistr_cpp_pinvgamma, 5}, {"_extraDistr_cpp_dkumar", (DL_FUNC) &_extraDistr_cpp_dkumar, 4}, {"_extraDistr_cpp_pkumar", (DL_FUNC) &_extraDistr_cpp_pkumar, 5}, {"_extraDistr_cpp_qkumar", (DL_FUNC) &_extraDistr_cpp_qkumar, 5}, {"_extraDistr_cpp_rkumar", (DL_FUNC) &_extraDistr_cpp_rkumar, 3}, {"_extraDistr_cpp_dlaplace", (DL_FUNC) &_extraDistr_cpp_dlaplace, 4}, {"_extraDistr_cpp_plaplace", (DL_FUNC) &_extraDistr_cpp_plaplace, 5}, {"_extraDistr_cpp_qlaplace", (DL_FUNC) &_extraDistr_cpp_qlaplace, 5}, {"_extraDistr_cpp_rlaplace", (DL_FUNC) &_extraDistr_cpp_rlaplace, 3}, {"_extraDistr_cpp_dlst", (DL_FUNC) &_extraDistr_cpp_dlst, 5}, {"_extraDistr_cpp_plst", (DL_FUNC) &_extraDistr_cpp_plst, 6}, {"_extraDistr_cpp_qlst", (DL_FUNC) &_extraDistr_cpp_qlst, 6}, {"_extraDistr_cpp_rlst", (DL_FUNC) &_extraDistr_cpp_rlst, 4}, {"_extraDistr_cpp_dlgser", (DL_FUNC) &_extraDistr_cpp_dlgser, 3}, {"_extraDistr_cpp_plgser", (DL_FUNC) &_extraDistr_cpp_plgser, 4}, {"_extraDistr_cpp_qlgser", (DL_FUNC) &_extraDistr_cpp_qlgser, 4}, {"_extraDistr_cpp_rlgser", (DL_FUNC) &_extraDistr_cpp_rlgser, 2}, {"_extraDistr_cpp_dlomax", (DL_FUNC) &_extraDistr_cpp_dlomax, 4}, {"_extraDistr_cpp_plomax", (DL_FUNC) &_extraDistr_cpp_plomax, 5}, {"_extraDistr_cpp_qlomax", (DL_FUNC) &_extraDistr_cpp_qlomax, 5}, {"_extraDistr_cpp_rlomax", (DL_FUNC) &_extraDistr_cpp_rlomax, 3}, {"_extraDistr_cpp_dmixnorm", (DL_FUNC) &_extraDistr_cpp_dmixnorm, 5}, {"_extraDistr_cpp_pmixnorm", (DL_FUNC) &_extraDistr_cpp_pmixnorm, 6}, {"_extraDistr_cpp_rmixnorm", (DL_FUNC) &_extraDistr_cpp_rmixnorm, 4}, {"_extraDistr_cpp_dmixpois", (DL_FUNC) &_extraDistr_cpp_dmixpois, 4}, {"_extraDistr_cpp_pmixpois", (DL_FUNC) &_extraDistr_cpp_pmixpois, 5}, {"_extraDistr_cpp_rmixpois", (DL_FUNC) &_extraDistr_cpp_rmixpois, 3}, {"_extraDistr_cpp_dmnom", (DL_FUNC) &_extraDistr_cpp_dmnom, 4}, {"_extraDistr_cpp_rmnom", (DL_FUNC) &_extraDistr_cpp_rmnom, 3}, {"_extraDistr_cpp_dmvhyper", (DL_FUNC) &_extraDistr_cpp_dmvhyper, 4}, {"_extraDistr_cpp_rmvhyper", (DL_FUNC) &_extraDistr_cpp_rmvhyper, 3}, {"_extraDistr_cpp_dnhyper", (DL_FUNC) &_extraDistr_cpp_dnhyper, 5}, {"_extraDistr_cpp_pnhyper", (DL_FUNC) &_extraDistr_cpp_pnhyper, 6}, {"_extraDistr_cpp_qnhyper", (DL_FUNC) &_extraDistr_cpp_qnhyper, 6}, {"_extraDistr_cpp_rnhyper", (DL_FUNC) &_extraDistr_cpp_rnhyper, 4}, {"_extraDistr_cpp_dnsbeta", (DL_FUNC) &_extraDistr_cpp_dnsbeta, 6}, {"_extraDistr_cpp_pnsbeta", (DL_FUNC) &_extraDistr_cpp_pnsbeta, 7}, {"_extraDistr_cpp_qnsbeta", (DL_FUNC) &_extraDistr_cpp_qnsbeta, 7}, {"_extraDistr_cpp_rnsbeta", (DL_FUNC) &_extraDistr_cpp_rnsbeta, 5}, {"_extraDistr_cpp_dpareto", (DL_FUNC) &_extraDistr_cpp_dpareto, 4}, {"_extraDistr_cpp_ppareto", (DL_FUNC) &_extraDistr_cpp_ppareto, 5}, {"_extraDistr_cpp_qpareto", (DL_FUNC) &_extraDistr_cpp_qpareto, 5}, {"_extraDistr_cpp_rpareto", (DL_FUNC) &_extraDistr_cpp_rpareto, 3}, {"_extraDistr_cpp_dpower", (DL_FUNC) &_extraDistr_cpp_dpower, 4}, {"_extraDistr_cpp_ppower", (DL_FUNC) &_extraDistr_cpp_ppower, 5}, {"_extraDistr_cpp_qpower", (DL_FUNC) &_extraDistr_cpp_qpower, 5}, {"_extraDistr_cpp_rpower", (DL_FUNC) &_extraDistr_cpp_rpower, 3}, {"_extraDistr_cpp_dprop", (DL_FUNC) &_extraDistr_cpp_dprop, 5}, {"_extraDistr_cpp_pprop", (DL_FUNC) &_extraDistr_cpp_pprop, 6}, {"_extraDistr_cpp_qprop", (DL_FUNC) &_extraDistr_cpp_qprop, 6}, {"_extraDistr_cpp_rprop", (DL_FUNC) &_extraDistr_cpp_rprop, 4}, {"_extraDistr_cpp_rsign", (DL_FUNC) &_extraDistr_cpp_rsign, 1}, {"_extraDistr_cpp_drayleigh", (DL_FUNC) &_extraDistr_cpp_drayleigh, 3}, {"_extraDistr_cpp_prayleigh", (DL_FUNC) &_extraDistr_cpp_prayleigh, 4}, {"_extraDistr_cpp_qrayleigh", (DL_FUNC) &_extraDistr_cpp_qrayleigh, 4}, {"_extraDistr_cpp_rrayleigh", (DL_FUNC) &_extraDistr_cpp_rrayleigh, 2}, {"_extraDistr_cpp_dsgomp", (DL_FUNC) &_extraDistr_cpp_dsgomp, 4}, {"_extraDistr_cpp_psgomp", (DL_FUNC) &_extraDistr_cpp_psgomp, 5}, {"_extraDistr_cpp_rsgomp", (DL_FUNC) &_extraDistr_cpp_rsgomp, 3}, {"_extraDistr_cpp_dskellam", (DL_FUNC) &_extraDistr_cpp_dskellam, 4}, {"_extraDistr_cpp_rskellam", (DL_FUNC) &_extraDistr_cpp_rskellam, 3}, {"_extraDistr_cpp_dslash", (DL_FUNC) &_extraDistr_cpp_dslash, 4}, {"_extraDistr_cpp_pslash", (DL_FUNC) &_extraDistr_cpp_pslash, 5}, {"_extraDistr_cpp_rslash", (DL_FUNC) &_extraDistr_cpp_rslash, 3}, {"_extraDistr_cpp_dtriang", (DL_FUNC) &_extraDistr_cpp_dtriang, 5}, {"_extraDistr_cpp_ptriang", (DL_FUNC) &_extraDistr_cpp_ptriang, 6}, {"_extraDistr_cpp_qtriang", (DL_FUNC) &_extraDistr_cpp_qtriang, 6}, {"_extraDistr_cpp_rtriang", (DL_FUNC) &_extraDistr_cpp_rtriang, 4}, {"_extraDistr_cpp_dtbinom", (DL_FUNC) &_extraDistr_cpp_dtbinom, 6}, {"_extraDistr_cpp_ptbinom", (DL_FUNC) &_extraDistr_cpp_ptbinom, 7}, {"_extraDistr_cpp_qtbinom", (DL_FUNC) &_extraDistr_cpp_qtbinom, 7}, {"_extraDistr_cpp_rtbinom", (DL_FUNC) &_extraDistr_cpp_rtbinom, 5}, {"_extraDistr_cpp_dtnorm", (DL_FUNC) &_extraDistr_cpp_dtnorm, 6}, {"_extraDistr_cpp_ptnorm", (DL_FUNC) &_extraDistr_cpp_ptnorm, 7}, {"_extraDistr_cpp_qtnorm", (DL_FUNC) &_extraDistr_cpp_qtnorm, 7}, {"_extraDistr_cpp_rtnorm", (DL_FUNC) &_extraDistr_cpp_rtnorm, 5}, {"_extraDistr_cpp_dtpois", (DL_FUNC) &_extraDistr_cpp_dtpois, 5}, {"_extraDistr_cpp_ptpois", (DL_FUNC) &_extraDistr_cpp_ptpois, 6}, {"_extraDistr_cpp_qtpois", (DL_FUNC) &_extraDistr_cpp_qtpois, 6}, {"_extraDistr_cpp_rtpois", (DL_FUNC) &_extraDistr_cpp_rtpois, 4}, {"_extraDistr_cpp_qtlambda", (DL_FUNC) &_extraDistr_cpp_qtlambda, 4}, {"_extraDistr_cpp_rtlambda", (DL_FUNC) &_extraDistr_cpp_rtlambda, 2}, {"_extraDistr_cpp_dwald", (DL_FUNC) &_extraDistr_cpp_dwald, 4}, {"_extraDistr_cpp_pwald", (DL_FUNC) &_extraDistr_cpp_pwald, 5}, {"_extraDistr_cpp_rwald", (DL_FUNC) &_extraDistr_cpp_rwald, 3}, {"_extraDistr_cpp_dzib", (DL_FUNC) &_extraDistr_cpp_dzib, 5}, {"_extraDistr_cpp_pzib", (DL_FUNC) &_extraDistr_cpp_pzib, 6}, {"_extraDistr_cpp_qzib", (DL_FUNC) &_extraDistr_cpp_qzib, 6}, {"_extraDistr_cpp_rzib", (DL_FUNC) &_extraDistr_cpp_rzib, 4}, {"_extraDistr_cpp_dzinb", (DL_FUNC) &_extraDistr_cpp_dzinb, 5}, {"_extraDistr_cpp_pzinb", (DL_FUNC) &_extraDistr_cpp_pzinb, 6}, {"_extraDistr_cpp_qzinb", (DL_FUNC) &_extraDistr_cpp_qzinb, 6}, {"_extraDistr_cpp_rzinb", (DL_FUNC) &_extraDistr_cpp_rzinb, 4}, {"_extraDistr_cpp_dzip", (DL_FUNC) &_extraDistr_cpp_dzip, 4}, {"_extraDistr_cpp_pzip", (DL_FUNC) &_extraDistr_cpp_pzip, 5}, {"_extraDistr_cpp_qzip", (DL_FUNC) &_extraDistr_cpp_qzip, 5}, {"_extraDistr_cpp_rzip", (DL_FUNC) &_extraDistr_cpp_rzip, 3}, {"_extraDistr_RcppExport_registerCCallable", (DL_FUNC) &_extraDistr_RcppExport_registerCCallable, 0}, {NULL, NULL, 0} }; RcppExport void R_init_extraDistr(DllInfo *dll) { R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); R_useDynamicSymbols(dll, FALSE); } extraDistr/src/logarithmic-series-distribution.cpp0000755000176200001440000001117214475546572022235 0ustar liggesusers#include #include "shared.h" // [[Rcpp::interfaces(r, cpp)]] // [[Rcpp::plugins(cpp11)]] using std::pow; using std::sqrt; using std::abs; using std::exp; using std::log; using std::floor; using std::ceil; using Rcpp::NumericVector; using std::log1p; /* * Logarithmic Series distribution * * Values: * x * * Parameters: * 0 < theta < 1 * * f(x) = (-1/log(1-theta)*theta^x) / x * F(x) = -1/log(1-theta) * sum((theta^x)/x) * */ inline double logpdf_lgser(double x, double theta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(theta)) return x+theta; #endif if (theta <= 0.0 || theta >= 1.0) { throw_warning = true; return NAN; } if (!isInteger(x) || x < 1.0) return R_NegInf; // a = -1.0/log(1.0 - theta); double a = -1.0/log1p(-theta); // a * pow(theta, x) / x; return log(a) + (log(theta) * x) - log(x); } inline double cdf_lgser(double x, double theta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(x) || ISNAN(theta)) return x+theta; #endif if (theta <= 0.0 || theta >= 1.0) { throw_warning = true; return NAN; } if (x < 1.0) return 0.0; if (!R_FINITE(x)) return 1.0; if (is_large_int(x)) { Rcpp::warning("NAs introduced by coercion to integer range"); return NA_REAL; } double a = -1.0/log1p(-theta); double b = 0.0; double dk; int ix = to_pos_int(x); for (int k = 1; k <= ix; k++) { dk = to_dbl(k); b += pow(theta, dk) / dk; } return a * b; } inline double invcdf_lgser(double p, double theta, bool& throw_warning) { #ifdef IEEE_754 if (ISNAN(p) || ISNAN(theta)) return p+theta; #endif if (theta <= 0.0 || theta >= 1.0 || !VALID_PROB(p)) { throw_warning = true; return NAN; } if (p == 0.0) return 1.0; if (p == 1.0) return R_PosInf; double pk = -theta/log(1.0 - theta); double k = 1.0; while (p > pk) { p -= pk; pk *= theta * k/(k+1.0); k += 1.0; } return k; } inline double rng_lgser(double theta, bool& throw_warning) { if (ISNAN(theta) || theta <= 0.0 || theta >= 1.0) { throw_warning = true; return NA_REAL; } double u = rng_unif(); double pk = -theta/log(1.0 - theta); double k = 1.0; while (u > pk) { u -= pk; pk *= theta * k/(k+1.0); k += 1.0; } return k; } // [[Rcpp::export]] NumericVector cpp_dlgser( const NumericVector& x, const NumericVector& theta, const bool& log_prob = false ) { if (std::min({x.length(), theta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), theta.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = logpdf_lgser(GETV(x, i), GETV(theta, i), throw_warning); if (!log_prob) p = Rcpp::exp(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_plgser( const NumericVector& x, const NumericVector& theta, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({x.length(), theta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ x.length(), theta.length() }); NumericVector p(Nmax); bool throw_warning = false; for (int i = 0; i < Nmax; i++) p[i] = cdf_lgser(GETV(x, i), GETV(theta, i), throw_warning); if (!lower_tail) p = 1.0 - p; if (log_prob) p = Rcpp::log(p); if (throw_warning) Rcpp::warning("NaNs produced"); return p; } // [[Rcpp::export]] NumericVector cpp_qlgser( const NumericVector& p, const NumericVector& theta, const bool& lower_tail = true, const bool& log_prob = false ) { if (std::min({p.length(), theta.length()}) < 1) { return NumericVector(0); } int Nmax = std::max({ p.length(), theta.length() }); NumericVector x(Nmax); NumericVector pp = Rcpp::clone(p); bool throw_warning = false; if (log_prob) pp = Rcpp::exp(pp); if (!lower_tail) pp = 1.0 - pp; for (int i = 0; i < Nmax; i++) x[i] = invcdf_lgser(GETV(pp, i), GETV(theta, i), throw_warning); if (throw_warning) Rcpp::warning("NaNs produced"); return x; } // [[Rcpp::export]] NumericVector cpp_rlgser( const int& n, const NumericVector& theta ) { if (theta.length() < 1) { Rcpp::warning("NAs produced"); return NumericVector(n, NA_REAL); } NumericVector x(n); bool throw_warning = false; for (int i = 0; i < n; i++) x[i] = rng_lgser(GETV(theta, i), throw_warning); if (throw_warning) Rcpp::warning("NAs produced"); return x; } extraDistr/R/0000755000176200001440000000000014532041715012606 5ustar liggesusersextraDistr/R/wald-distribution.R0000755000176200001440000000446214475546572016427 0ustar liggesusers #' Wald (inverse Gaussian) distribution #' #' Density, distribution function and random generation #' for the Wald distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param mu,lambda location and shape parameters. Scale must be positive. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \sqrt{\frac{\lambda}{2\pi x^3}} \exp\left( \frac{-\lambda(x-\mu)^2}{2\mu^2 x} \right) #' }{ #' f(x) = sqrt(\lambda/(2*\pi*x^3)) * exp((-\lambda*(x-\mu)^2)/(2*\mu^2*x)) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = \Phi\left(\sqrt{\frac{\lambda}{x}} \left(\frac{x}{\mu}-1 \right) \right) + #' \exp\left(\frac{2\lambda}{\mu} \right) \Phi\left(\sqrt{\frac{\lambda}{x}} #' \left(\frac{x}{\mu}+1 \right) \right) #' }{ #' F(x) = \Phi(sqrt(\lambda/\mu)*(x/\mu-1)) - exp((2*\lambda)/\mu) * #' \Phi(sqrt(\lambda/\mu)*(x/\mu+1)) #' } #' #' Random generation is done using the algorithm described by Michael, Schucany and Haas (1976). #' #' @references #' #' Michael, J.R., Schucany, W.R., and Haas, R.W. (1976). #' Generating Random Variates Using Transformations with Multiple Roots. #' The American Statistician, 30(2): 88-90. #' #' @examples #' #' x <- rwald(1e5, 5, 16) #' hist(x, 100, freq = FALSE) #' curve(dwald(x, 5, 16), 0, 50, col = "red", add = TRUE) #' hist(pwald(x, 5, 16)) #' plot(ecdf(x)) #' curve(pwald(x, 5, 16), 0, 50, col = "red", lwd = 2, add = TRUE) #' #' @name Wald #' @aliases Wald #' @aliases dwald #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dwald <- function(x, mu, lambda, log = FALSE) { cpp_dwald(x, mu, lambda, log[1L]) } #' @rdname Wald #' @export pwald <- function(q, mu, lambda, lower.tail = TRUE, log.p = FALSE) { cpp_pwald(q, mu, lambda, lower.tail[1L], log.p[1L]) } #' @rdname Wald #' @export rwald <- function(n, mu, lambda) { if (length(n) > 1) n <- length(n) cpp_rwald(n, mu, lambda) } extraDistr/R/multivariate-hypergeometric-distribution.R0000755000176200001440000000455114475546572023231 0ustar liggesusers #' Multivariate hypergeometric distribution #' #' Probability mass function and random generation #' for the multivariate hypergeometric distribution. #' #' @param x \eqn{m}-column matrix of quantiles. #' @param nn number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param n \eqn{m}-length vector or \eqn{m}-column matrix #' of numbers of balls in \eqn{m} colors. #' @param k the number of balls drawn from the urn. #' @param log logical; if TRUE, probabilities p are given as log(p). #' #' @details #' #' Probability mass function #' \deqn{ #' f(x) = \frac{\prod_{i=1}^m {n_i \choose x_i}}{{N \choose k}} #' }{ #' f(x) = prod(choose(n, x)) / choose(N, k) #' } #' #' @details #' The multivariate hypergeometric distribution is generalization of #' hypergeometric distribution. It is used for sampling \emph{without} replacement #' \eqn{k} out of \eqn{N} marbles in \eqn{m} colors, where each of the colors appears #' \eqn{n_i}{n[i]} times. Where \eqn{k=\sum_{i=1}^m x_i}{k=sum(x)}, #' \eqn{N=\sum_{i=1}^m n_i}{N=sum(n)} and \eqn{k \le N}{k<=N}. #' #' @references #' Gentle, J.E. (2006). Random number generation and Monte Carlo methods. Springer. #' #' @seealso \code{\link[stats]{Hypergeometric}} #' #' @examples #' #' # Generating 10 random draws from multivariate hypergeometric #' # distribution parametrized using a vector #' #' rmvhyper(10, c(10, 12, 5, 8, 11), 33) #' #' @name MultiHypergeometric #' @aliases MultiHypergeometric #' @aliases dmvhyper #' #' @keywords distribution #' @concept Multivariate #' @concept Discrete #' #' @export dmvhyper <- function(x, n, k, log = FALSE) { if (is.vector(n)) n <- matrix(n, nrow = 1) else if (!is.matrix(n)) n <- as.matrix(n) if (is.vector(x)) x <- matrix(x, nrow = 1) else if (!is.matrix(x)) x <- as.matrix(x) cpp_dmvhyper(x, n, k, log[1L]) } #' @rdname MultiHypergeometric #' @export rmvhyper <- function(nn, n, k) { if (length(nn) > 1) nn <- length(nn) if (is.vector(n) && length(k) == 1) { if (anyNA(n) || is.na(k)) { warning("NAs produced") return(matrix(rep(NA, nn), nrow = nn, byrow = TRUE)) } if (sum(n) == k) return(matrix(rep(n, nn), nrow = nn, byrow = TRUE)) n <- matrix(n, nrow = 1) } else if (!is.matrix(n)) { n <- as.matrix(n) } cpp_rmvhyper(nn, n, k) } extraDistr/R/dirichlet-multinomial-distribution.R0000755000176200001440000000505214475546572021773 0ustar liggesusers #' Dirichlet-multinomial (multivariate Polya) distribution #' #' Density function, cumulative distribution function and random generation #' for the Dirichlet-multinomial (multivariate Polya) distribution. #' #' @param x \eqn{k}-column matrix of quantiles. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param size numeric vector; number of trials (zero or more). #' @param alpha \eqn{k}-values vector or \eqn{k}-column matrix; #' concentration parameter. Must be positive. #' @param log logical; if TRUE, probabilities p are given as log(p). #' #' @details #' #' If \eqn{(p_1,\dots,p_k) \sim \mathrm{Dirichlet}(\alpha_1,\dots,\alpha_k)}{(p[1],\dots,p[k]) ~ Dirichlet(\alpha[1],\dots,\alpha[k])} and #' \eqn{(x_1,\dots,x_k) \sim \mathrm{Multinomial}(n, p_1,\dots,p_k)}{(x[1],\dots,x[k]) ~ Multinomial(n, p[1],\dots,p[k])}, then #' \eqn{(x_1,\dots,x_k) \sim \mathrm{DirichletMultinomial(n, \alpha_1,\dots,\alpha_k)}}{(x[1],\dots,x[k]) ~ DirichletMultinomial(n, \alpha[1],\dots,\alpha[k])}. #' #' Probability density function #' \deqn{ #' f(x) = \frac{\left(n!\right)\Gamma\left(\sum \alpha_k\right)}{\Gamma\left(n+\sum \alpha_k\right)}\prod_{k=1}^K\frac{\Gamma(x_{k}+\alpha_{k})}{\left(x_{k}!\right)\Gamma(\alpha_{k})} #' }{ #' f(x) = (n! * \Gamma(sum(\alpha[k]))) / (\Gamma(n + sum(\alpha[k]))) * prod((\Gamma(x[k] + \alpha[k])) / (x[k]! * \Gamma(\alpha[k])) #' } #' #' @seealso \code{\link{Dirichlet}}, \code{\link{Multinomial}} #' #' @references #' Gentle, J.E. (2006). Random number generation and Monte Carlo methods. Springer. #' #' @references #' Kvam, P. and Day, D. (2001) The multivariate Polya distribution in combat modeling. #' Naval Research Logistics, 48, 1-17. #' #' @name DirMnom #' @aliases DirMnom #' @aliases ddirmnom #' #' @keywords distribution #' @concept Multivariate #' @concept Discrete #' #' @export ddirmnom <- function(x, size, alpha, log = FALSE) { if (is.vector(alpha)) alpha <- matrix(alpha, nrow = 1) else if (!is.matrix(alpha)) alpha <- as.matrix(alpha) if (is.data.frame(x)) x <- as.matrix(x) else if (is.vector(x)) x <- matrix(x, byrow = TRUE, nrow = 1) cpp_ddirmnom(x, size, alpha, log[1L]) } #' @rdname DirMnom #' @export rdirmnom <- function (n, size, alpha) { if (length(n) > 1) n <- length(n) if (is.vector(alpha)) alpha <- matrix(alpha, nrow = 1) else if (!is.matrix(alpha)) alpha <- as.matrix(alpha) cpp_rdirmnom(n, size, alpha) } extraDistr/R/birnbaum-saunders-distribution.R0000755000176200001440000000704114475546572021115 0ustar liggesusers #' Birnbaum-Saunders (fatigue life) distribution #' #' Density, distribution function, quantile function and random generation #' for the Birnbaum-Saunders (fatigue life) distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param alpha,beta,mu shape, scale and location parameters. #' Scale and shape must be positive. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \left (\frac{\sqrt{\frac{x-\mu} {\beta}} + \sqrt{\frac{\beta} #' {x-\mu}}} {2\alpha (x-\mu)} \right) #' \phi \left( \frac{1}{\alpha}\left( \sqrt{\frac{x-\mu}{\beta}} - #' \sqrt{\frac{\beta}{x-\mu}} \right) \right) #' }{ #' f(x) = ((sqrt((x-\mu)/\beta) + sqrt(\beta/(x-\mu)))/(2*\alpha*(x-\mu))) * #' \phi((sqrt((x-\mu)/\beta) - sqrt(\beta/(x-\mu)))/\alpha) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = \Phi \left(\frac{1}{\alpha}\left( \sqrt{\frac{x-\mu}{\beta}} - #' \sqrt{\frac{\beta}{x-\mu}} \right) \right) #' }{ #' F(x) = \Phi(((sqrt((x-\mu)/\beta) - sqrt(\beta/(x-\mu)))/\alpha) #' } #' #' Quantile function #' \deqn{ #' F^{-1}(p) = \left[\frac{\alpha}{2} \Phi^{-1}(p) + #' \sqrt{\left(\frac{\alpha}{2} \Phi^{-1}(p)\right)^{2} + 1}\right]^{2} \beta + \mu #' }{ #' F^-1(p) = (\alpha/2 * \Phi^-1(p) + #' sqrt((\alpha/2 * \Phi^-1(p))^2 + 1)^2 * \beta + \mu #' } #' #' @references #' Birnbaum, Z. W. and Saunders, S. C. (1969). #' A new family of life distributions. #' Journal of Applied Probability, 6(2), 637-652. #' #' @references #' Desmond, A. (1985) Stochastic models of failure in random environments. #' Canadian Journal of Statistics, 13, 171-183. #' #' @references #' Vilca-Labra, F., and Leiva-Sanchez, V. (2006). #' A new fatigue life model based on the family of skew-elliptical distributions. #' Communications in Statistics-Theory and Methods, 35(2), 229-244. #' #' @references #' Leiva, V., Sanhueza, A., Sen, P. K., and Paula, G. A. (2008). #' Random number generators for the generalized Birnbaum-Saunders distribution. #' Journal of Statistical Computation and Simulation, 78(11), 1105-1118. #' #' @examples #' #' x <- rfatigue(1e5, .5, 2, 5) #' hist(x, 100, freq = FALSE) #' curve(dfatigue(x, .5, 2, 5), 2, 20, col = "red", add = TRUE) #' hist(pfatigue(x, .5, 2, 5)) #' plot(ecdf(x)) #' curve(pfatigue(x, .5, 2, 5), 2, 20, col = "red", lwd = 2, add = TRUE) #' #' @name BirnbaumSaunders #' @aliases BirnbaumSaunders #' @aliases dfatigue #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dfatigue <- function(x, alpha, beta = 1, mu = 0, log = FALSE) { cpp_dfatigue(x, alpha, beta, mu, log[1L]) } #' @rdname BirnbaumSaunders #' @export pfatigue <- function(q, alpha, beta = 1, mu = 0, lower.tail = TRUE, log.p = FALSE) { cpp_pfatigue(q, alpha, beta, mu, lower.tail[1L], log.p[1L]) } #' @rdname BirnbaumSaunders #' @export qfatigue <- function(p, alpha, beta = 1, mu = 0, lower.tail = TRUE, log.p = FALSE) { cpp_qfatigue(p, alpha, beta, mu, lower.tail[1L], log.p[1L]) } #' @rdname BirnbaumSaunders #' @export rfatigue <- function(n, alpha, beta = 1, mu = 0) { if (length(n) > 1) n <- length(n) cpp_rfatigue(n, alpha, beta, mu) } extraDistr/R/discrete-laplace-distribution.R0000755000176200001440000000542514475546572020701 0ustar liggesusers #' Discrete Laplace distribution #' #' Probability mass, distribution function and random generation #' for the discrete Laplace distribution parametrized by location and scale. #' #' @param x,q vector of quantiles. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param scale scale parameter; \code{0 < scale < 1}. #' @param location location parameter. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' If \eqn{U \sim \mathrm{Geometric}(1-p)}{U ~ Geometric(1-p)} and #' \eqn{V \sim \mathrm{Geometric}(1-p)}{V ~ Geometric(1-p)}, #' then \eqn{U-V \sim \mathrm{DiscreteLaplace}(p)}{U-V ~ DiscreteLaplace(p)}, #' where geometric distribution is related to discrete Laplace distribution #' in similar way as exponential distribution is related to Laplace distribution. #' #' Probability mass function #' #' \deqn{ #' f(x) = \frac{1-p}{1+p} p^{|x-\mu|} #' }{ #' f(x) = (1-p)/(1+p) * p^(|x-\mu|) #' } #' #' Cumulative distribution function #' #' \deqn{ #' F(x) = \left\{\begin{array}{ll} #' \frac{p^{-|x-\mu|}}{1+p} & x < 0 \\ #' 1 - \frac{p^{|x-\mu|+1}}{1+p} & x \ge 0 #' \end{array}\right. #' }{ #' F(x) = [if x < 0:] p^-floor(x-\mu))/(1+p) [else:] 1-(p^(floor(x-\mu)+1))/(1+p) #' } #' #' @references #' Inusah, S., & Kozubowski, T.J. (2006). A discrete analogue of the Laplace distribution. #' Journal of statistical planning and inference, 136(3), 1090-1102. #' #' @references #' Kotz, S., Kozubowski, T., & Podgorski, K. (2012). #' The Laplace distribution and generalizations: a revisit with applications #' to communications, economics, engineering, and finance. #' Springer Science & Business Media. #' #' @examples #' #' p <- 0.45 #' x <- rdlaplace(1e5, 0, p) #' xx <- seq(-200, 200, by = 1) #' plot(prop.table(table(x))) #' lines(xx, ddlaplace(xx, 0, p), col = "red") #' hist(pdlaplace(x, 0, p)) #' plot(ecdf(x)) #' lines(xx, pdlaplace(xx, 0, p), col = "red", type = "s") #' #' @name DiscreteLaplace #' @aliases DiscreteLaplace #' @aliases ddlaplace #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export ddlaplace <- function(x, location, scale, log = FALSE) { cpp_ddlaplace(x, location, scale, log[1L]) } #' @rdname DiscreteLaplace #' @export pdlaplace <- function(q, location, scale, lower.tail = TRUE, log.p = FALSE) { cpp_pdlaplace(q, location, scale, lower.tail[1L], log.p[1L]) } #' @rdname DiscreteLaplace #' @export rdlaplace <- function(n, location, scale) { if (length(n) > 1) n <- length(n) cpp_rdlaplace(n, location, scale) } extraDistr/R/discrete-normal-distribution.R0000755000176200001440000000401414475546572020561 0ustar liggesusers #' Discrete normal distribution #' #' Probability mass function, distribution function and random generation #' for discrete normal distribution. #' #' @param x,q vector of quantiles. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param mean vector of means. #' @param sd vector of standard deviations. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' @details #' #' Probability mass function #' #' \deqn{ #' f(x) = \Phi\left(\frac{x-\mu+1}{\sigma}\right) - \Phi\left(\frac{x-\mu}{\sigma}\right) #' }{ #' f(x) = \Phi((x-\mu+1)/\sigma) - \Phi((x-\mu)/\sigma) #' } #' #' Cumulative distribution function #' #' \deqn{ #' F(x) = \Phi\left(\frac{\lfloor x \rfloor + 1 - \mu}{\sigma}\right) #' }{ #' F(x) = \Phi((floor(x)+1-\mu)/\sigma) #' } #' #' @references #' Roy, D. (2003). The discrete normal distribution. #' Communications in Statistics-Theory and Methods, 32, 1871-1883. #' #' @seealso \code{\link[stats]{Normal}} #' #' @examples #' #' x <- rdnorm(1e5, 0, 3) #' xx <- -15:15 #' plot(prop.table(table(x))) #' lines(xx, ddnorm(xx, 0, 3), col = "red") #' hist(pdnorm(x, 0, 3)) #' plot(ecdf(x)) #' xx <- seq(-15, 15, 0.1) #' lines(xx, pdnorm(xx, 0, 3), col = "red", lwd = 2, type = "s") #' #' @name DiscreteNormal #' @aliases DiscreteNormal #' @aliases ddnorm #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export ddnorm <- function(x, mean = 0, sd = 1, log = FALSE) { cpp_ddnorm(x, mean, sd, log[1L]) } #' @rdname DiscreteNormal #' @export pdnorm <- function(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE) { pnorm(floor(q)+1, mean, sd, lower.tail[1L], log.p[1L]) } #' @rdname DiscreteNormal #' @export rdnorm <- function(n, mean = 0, sd = 1) { floor(rnorm(n, mean, sd)) } extraDistr/R/half-normal-distribution.R0000755000176200001440000000436714475546572017704 0ustar liggesusers #' Half-normal distribution #' #' Density, distribution function, quantile function and random generation #' for the half-normal distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param sigma positive valued scale parameter. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' If \eqn{X} follows normal distribution centered at 0 and parametrized #' by scale \eqn{\sigma}, then \eqn{|X|} follows half-normal distribution #' parametrized by scale \eqn{\sigma}. Half-t distribution with \eqn{\nu=\infty} #' degrees of freedom converges to half-normal distribution. #' #' @references #' Gelman, A. (2006). Prior distributions for variance parameters in hierarchical #' models (comment on article by Browne and Draper). #' Bayesian analysis, 1(3), 515-534. #' #' @references #' Jacob, E. and Jayakumar, K. (2012). #' On Half-Cauchy Distribution and Process. #' International Journal of Statistika and Mathematika, 3(2), 77-81. #' #' @seealso \code{\link{HalfT}} #' #' @examples #' #' x <- rhnorm(1e5, 2) #' hist(x, 100, freq = FALSE) #' curve(dhnorm(x, 2), 0, 8, col = "red", add = TRUE) #' hist(phnorm(x, 2)) #' plot(ecdf(x)) #' curve(phnorm(x, 2), 0, 8, col = "red", lwd = 2, add = TRUE) #' #' @name HalfNormal #' @aliases HalfNormal #' @aliases dhnorm #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dhnorm <- function(x, sigma = 1, log = FALSE) { cpp_dhnorm(x, sigma, log[1L]) } #' @rdname HalfNormal #' @export phnorm <- function(q, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_phnorm(q, sigma, lower.tail[1L], log.p[1L]) } #' @rdname HalfNormal #' @export qhnorm <- function(p, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_qhnorm(p, sigma, lower.tail[1L], log.p[1L]) } #' @rdname HalfNormal #' @export rhnorm <- function(n, sigma = 1) { if (length(n) > 1) n <- length(n) cpp_rhnorm(n, sigma) } extraDistr/R/inverse-chi-squared-distribution.R0000755000176200001440000000576714475546572021367 0ustar liggesusers #' Inverse chi-squared and scaled chi-squared distributions #' #' Density, distribution function and random generation #' for the inverse chi-squared distribution and scaled chi-squared distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param nu positive valued shape parameter. #' @param tau positive valued scaling parameter; if provided it #' returns values for scaled chi-squared distributions. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' If \eqn{X} follows \eqn{\chi^2 (\nu)} distribution, then \eqn{1/X} follows inverse #' chi-squared distribution parametrized by \eqn{\nu}. Inverse chi-squared distribution #' is a special case of inverse gamma distribution with parameters #' \eqn{\alpha=\frac{\nu}{2}}{\alpha=\nu/2} and \eqn{\beta=\frac{1}{2}}{\beta=1/2}; #' or \eqn{\alpha=\frac{\nu}{2}}{\alpha=\nu/2} and #' \eqn{\beta=\frac{\nu\tau^2}{2}}{\beta=(\nu\tau^2)/2} for scaled inverse #' chi-squared distribution. #' #' @seealso \code{\link[stats]{Chisquare}}, \code{\link[stats]{GammaDist}} #' #' @examples #' #' x <- rinvchisq(1e5, 20) #' hist(x, 100, freq = FALSE) #' curve(dinvchisq(x, 20), 0, 1, n = 501, col = "red", add = TRUE) #' hist(pinvchisq(x, 20)) #' plot(ecdf(x)) #' curve(pinvchisq(x, 20), 0, 1, n = 501, col = "red", lwd = 2, add = TRUE) #' #' # scaled #' #' x <- rinvchisq(1e5, 10, 5) #' hist(x, 100, freq = FALSE) #' curve(dinvchisq(x, 10, 5), 0, 150, n = 501, col = "red", add = TRUE) #' hist(pinvchisq(x, 10, 5)) #' plot(ecdf(x)) #' curve(pinvchisq(x, 10, 5), 0, 150, n = 501, col = "red", lwd = 2, add = TRUE) #' #' @name InvChiSq #' @aliases InvChiSq #' @aliases dinvchisq #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dinvchisq <- function(x, nu, tau, log = FALSE) { if (missing(tau)) dinvgamma(x, nu/2, 0.5, log = log[1L]) else dinvgamma(x, nu/2, (nu*tau)/2, log = log[1L]) } #' @rdname InvChiSq #' @export pinvchisq <- function(q, nu, tau, lower.tail = TRUE, log.p = FALSE) { if (missing(tau)) cpp_pinvgamma(q, nu/2, 0.5, lower.tail, log.p[1L]) else cpp_pinvgamma(q, nu/2, (nu*tau)/2, lower.tail, log.p[1L]) } #' @rdname InvChiSq #' @export qinvchisq <- function(p, nu, tau, lower.tail = TRUE, log.p = FALSE) { if (missing(tau)) 1/qchisq(p, nu, lower.tail = !lower.tail[1L], log.p = log.p[1L]) else 1/qgamma(p, nu/2, (nu*tau)/2, lower.tail = !lower.tail[1L], log.p = log.p[1L]) } #' @rdname InvChiSq #' @export rinvchisq <- function(n, nu, tau) { if (length(n) > 1) n <- length(n) if (missing(tau)) 1/rchisq(n, nu) else 1/rgamma(n, nu/2, (nu*tau)/2) } extraDistr/R/zero-inflated-negative-binomial-distribution.R0000755000176200001440000000447314475546572023635 0ustar liggesusers #' Zero-inflated negative binomial distribution #' #' Probability mass function and random generation #' for the zero-inflated negative binomial distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param size target for number of successful trials, or dispersion #' parameter (the shape parameter of the gamma mixing #' distribution). Must be strictly positive, need not be #' integer. #' @param prob probability of success in each trial. \code{0 < prob <= 1}. #' @param pi probability of extra zeros. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \left\{\begin{array}{ll} #' \pi + (1 - \pi) p^r & x = 0 \\ #' (1 - \pi) {x+r-1 \choose x} p^r (1-p)^x & x > 0 \\ #' \end{array}\right. #' }{ #' f(x) = [if x = 0:] (1-\pi)+\pi * p^r [else:] (1-\pi) * dnbinom(x, size, prob) #' } #' #' @seealso \code{\link[stats]{NegBinomial}} #' #' @examples #' #' x <- rzinb(1e5, 100, 0.6, 0.33) #' xx <- -2:200 #' plot(prop.table(table(x)), type = "h") #' lines(xx, dzinb(xx, 100, 0.6, 0.33), col = "red") #' #' xx <- seq(0, 200, by = 0.01) #' plot(ecdf(x)) #' lines(xx, pzinb(xx, 100, 0.6, 0.33), col = "red") #' #' @name ZINB #' @aliases ZINB #' @aliases dzinb #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export dzinb <- function(x, size, prob, pi, log = FALSE) { cpp_dzinb(x, size, prob, pi, log[1L]) } #' @rdname ZINB #' @export pzinb <- function(q, size, prob, pi, lower.tail = TRUE, log.p = FALSE) { cpp_pzinb(q, size, prob, pi, lower.tail[1L], log.p[1L]) } #' @rdname ZINB #' @export qzinb <- function(p, size, prob, pi, lower.tail = TRUE, log.p = FALSE) { cpp_qzinb(p, size, prob, pi, lower.tail[1L], log.p[1L]) } #' @rdname ZINB #' @export rzinb <- function(n, size, prob, pi) { if (length(n) > 1) n <- length(n) cpp_rzinb(n, size, prob, pi) } extraDistr/R/non-standard-beta-distribution.R0000755000176200001440000000375214475546572021002 0ustar liggesusers #' Non-standard beta distribution #' #' Non-standard form of beta distribution with lower and upper bounds #' denoted as \code{min} and \code{max}. By default \code{min=0} #' and \code{max=1} what leads to standard beta distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param shape1,shape2 non-negative parameters of the Beta distribution. #' @param min,max lower and upper bounds. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \leq x]}, #' otherwise, \eqn{P[X > x]}. #' #' @seealso \code{\link[stats]{Beta}} #' #' @examples #' #' x <- rnsbeta(1e5, 5, 13, -4, 8) #' hist(x, 100, freq = FALSE) #' curve(dnsbeta(x, 5, 13, -4, 8), -4, 6, col = "red", add = TRUE) #' hist(pnsbeta(x, 5, 13, -4, 8)) #' plot(ecdf(x)) #' curve(pnsbeta(x, 5, 13, -4, 8), -4, 6, col = "red", lwd = 2, add = TRUE) #' #' @name NSBeta #' @aliases NSBeta #' @aliases dgbeta #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dnsbeta <- function(x, shape1, shape2, min = 0, max = 1, log = FALSE) { cpp_dnsbeta(x, shape1, shape2, min, max, log[1L]) } #' @rdname NSBeta #' @export pnsbeta <- function(q, shape1, shape2, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE) { cpp_pnsbeta(q, shape1, shape2, min, max, lower.tail[1L], log.p[1L]) } #' @rdname NSBeta #' @export qnsbeta <- function(p, shape1, shape2, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE) { cpp_qnsbeta(p, shape1, shape2, min, max, lower.tail[1L], log.p[1L]) } #' @rdname NSBeta #' @export rnsbeta <- function(n, shape1, shape2, min = 0, max = 1) { if (length(n) > 1) n <- length(n) cpp_rnsbeta(n, shape1, shape2, min, max) } extraDistr/R/zzz.R0000755000176200001440000000012314475546572013606 0ustar liggesusers .onUnload <- function (libpath) { library.dynam.unload("extraDistr", libpath) } extraDistr/R/lomax-distribution.R0000755000176200001440000000403414475546572016613 0ustar liggesusers #' Lomax distribution #' #' Density, distribution function, quantile function and random generation #' for the Lomax distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param lambda,kappa positive valued parameters. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \frac{\lambda \kappa}{(1+\lambda x)^{\kappa+1}} #' }{ #' f(x) = \lambda*\kappa / (1+\lambda*x)^(\kappa+1) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = 1-(1+\lambda x)^{-\kappa} #' }{ #' F(x) = 1-(1+\lambda*x)^-\kappa #' } #' #' Quantile function #' \deqn{ #' F^{-1}(p) = \frac{(1-p)^{-1/\kappa} -1}{\lambda} #' }{ #' F^-1(p) = ((1-p)^(-1/\kappa)-1) / \lambda #' } #' #' @examples #' #' x <- rlomax(1e5, 5, 16) #' hist(x, 100, freq = FALSE) #' curve(dlomax(x, 5, 16), 0, 1, col = "red", add = TRUE, n = 5000) #' hist(plomax(x, 5, 16)) #' plot(ecdf(x)) #' curve(plomax(x, 5, 16), 0, 1, col = "red", lwd = 2, add = TRUE) #' #' @name Lomax #' @aliases Lomax #' @aliases dlomax #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dlomax <- function(x, lambda, kappa, log = FALSE) { cpp_dlomax(x, lambda, kappa, log[1L]) } #' @rdname Lomax #' @export plomax <- function(q, lambda, kappa, lower.tail = TRUE, log.p = FALSE) { cpp_plomax(q, lambda, kappa, lower.tail[1L], log.p[1L]) } #' @rdname Lomax #' @export qlomax <- function(p, lambda, kappa, lower.tail = TRUE, log.p = FALSE) { cpp_qlomax(p, lambda, kappa, lower.tail[1L], log.p[1L]) } #' @rdname Lomax #' @export rlomax <- function(n, lambda, kappa) { if (length(n) > 1) n <- length(n) cpp_rlomax(n, lambda, kappa) } extraDistr/R/pareto-distribution.R0000755000176200001440000000407114475546572016766 0ustar liggesusers #' Pareto distribution #' #' Density, distribution function, quantile function and random generation #' for the Pareto distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param a,b positive valued scale and location parameters. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \frac{ab^a}{x^{a+1}} #' }{ #' f(x) = (a*b^a) / x^(a+1) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = 1 - \left(\frac{b}{x}\right)^a #' }{ #' F(x) = 1 - (b/x)^a #' } #' #' Quantile function #' \deqn{ #' F^{-1}(p) = \frac{b}{(1-p)^{1-a}} #' }{ #' F^-1(p) = b/(1-p)^(1-a) #' } #' #' @references #' Krishnamoorthy, K. (2006). Handbook of Statistical Distributions #' with Applications. Chapman & Hall/CRC #' #' @examples #' #' x <- rpareto(1e5, 5, 16) #' hist(x, 100, freq = FALSE) #' curve(dpareto(x, 5, 16), 0, 200, col = "red", add = TRUE) #' hist(ppareto(x, 5, 16)) #' plot(ecdf(x)) #' curve(ppareto(x, 5, 16), 0, 200, col = "red", lwd = 2, add = TRUE) #' #' @name Pareto #' @aliases Pareto #' @aliases dpareto #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dpareto <- function(x, a = 1, b = 1, log = FALSE) { cpp_dpareto(x, a, b, log[1L]) } #' @rdname Pareto #' @export ppareto <- function(q, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) { cpp_ppareto(q, a, b, lower.tail[1L], log.p[1L]) } #' @rdname Pareto #' @export qpareto <- function(p, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) { cpp_qpareto(p, a, b, lower.tail[1L], log.p[1L]) } #' @rdname Pareto #' @export rpareto <- function(n, a = 1, b = 1) { if (length(n) > 1) n <- length(n) cpp_rpareto(n, a, b) } extraDistr/R/gumbel-distribution.R0000755000176200001440000000442014475546572016745 0ustar liggesusers #' Gumbel distribution #' #' Density, distribution function, quantile function and random generation #' for the Gumbel distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param mu,sigma location and scale parameters. Scale must be positive. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \frac{1}{\sigma} \exp\left(-\left(\frac{x-\mu}{\sigma} + \exp\left(-\frac{x-\mu}{\sigma}\right)\right)\right) #' }{ #' f(x) = 1/\sigma * exp(-((x-\mu)/\sigma + exp(-(x-\mu)/\sigma))) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = \exp\left(-\exp\left(-\frac{x-\mu}{\sigma}\right)\right) #' }{ #' F(x) = exp(-exp(-(x-\mu)/\sigma)) #' } #' #' Quantile function #' \deqn{ #' F^{-1}(p) = \mu - \sigma \log(-\log(p)) #' }{ #' F^-1(p) = \mu - \sigma * log(-log(p)) #' } #' #' @references #' Bury, K. (1999). Statistical Distributions in Engineering. #' Cambridge University Press. #' #' @examples #' #' x <- rgumbel(1e5, 5, 2) #' hist(x, 100, freq = FALSE) #' curve(dgumbel(x, 5, 2), 0, 25, col = "red", add = TRUE) #' hist(pgumbel(x, 5, 2)) #' plot(ecdf(x)) #' curve(pgumbel(x, 5, 2), 0, 25, col = "red", lwd = 2, add = TRUE) #' #' @name Gumbel #' @aliases Gumbel #' @aliases dgumbel #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dgumbel <- function(x, mu = 0, sigma = 1, log = FALSE) { cpp_dgumbel(x, mu, sigma, log[1L]) } #' @rdname Gumbel #' @export pgumbel <- function(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_pgumbel(q, mu, sigma, lower.tail[1L], log.p[1L]) } #' @rdname Gumbel #' @export qgumbel <- function(p, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_qgumbel(p, mu, sigma, lower.tail[1L], log.p[1L]) } #' @rdname Gumbel #' @export rgumbel <- function(n, mu = 0, sigma = 1) { if (length(n) > 1) n <- length(n) cpp_rgumbel(n, mu, sigma) } extraDistr/R/bhattacharjee-distribution.R0000755000176200001440000000526214475546572020264 0ustar liggesusers #' Bhattacharjee distribution #' #' Density, distribution function, and random generation for the Bhattacharjee #' distribution. #' #' @param x,q vector of quantiles. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param mu,sigma,a location, scale and shape parameters. #' Scale and shape must be positive. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' If \eqn{Z \sim \mathrm{Normal}(0, 1)}{Z ~ Normal(0, 1)} and #' \eqn{U \sim \mathrm{Uniform}(0, 1)}{U ~ Uniform(0, 1)}, then #' \eqn{Z+U} follows Bhattacharjee distribution. #' #' Probability density function #' #' \deqn{ #' f(z) = \frac{1}{2a} \left[\Phi\left(\frac{x-\mu+a}{\sigma}\right) - \Phi\left(\frac{x-\mu-a}{\sigma}\right)\right] #' }{ #' f(z) = 1/(2*a) * (\Phi((x-\mu+a)/\sigma) - \Phi((x-\mu+a)/\sigma)) #' } #' #' Cumulative distribution function #' #' \deqn{ #' F(z) = \frac{\sigma}{2a} \left[(x-\mu)\Phi\left(\frac{x-\mu+a}{\sigma}\right) - #' (x-\mu)\Phi\left(\frac{x-\mu-a}{\sigma}\right) + #' \phi\left(\frac{x-\mu+a}{\sigma}\right) - #' \phi\left(\frac{x-\mu-a}{\sigma}\right)\right] #' }{ #' F(z) = \sigma/(2*a) * ((x-\mu)*\Phi((x-\mu+a)/\sigma) - (x-\mu)*\Phi((x-\mu-a)/\sigma) + #' \phi((x-\mu+a)/\sigma) - \phi((x-\mu-a)/\sigma)) #' } #' #' @references #' Bhattacharjee, G.P., Pandit, S.N.N., and Mohan, R. (1963). #' Dimensional chains involving rectangular and normal error-distributions. #' Technometrics, 5, 404-406. #' #' @examples #' #' x <- rbhatt(1e5, 5, 3, 5) #' hist(x, 100, freq = FALSE) #' curve(dbhatt(x, 5, 3, 5), -20, 20, col = "red", add = TRUE) #' hist(pbhatt(x, 5, 3, 5)) #' plot(ecdf(x)) #' curve(pbhatt(x, 5, 3, 5), -20, 20, col = "red", lwd = 2, add = TRUE) #' #' @name Bhattacharjee #' @aliases Bhattacharjee #' @aliases dbhatt #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dbhatt <- function(x, mu = 0, sigma = 1, a = sigma, log = FALSE) { cpp_dbhatt(x, mu, sigma, a, log[1L]) } #' @rdname Bhattacharjee #' @export pbhatt <- function(q, mu = 0, sigma = 1, a = sigma, lower.tail = TRUE, log.p = FALSE) { cpp_pbhatt(q, mu, sigma, a, lower.tail[1L], log.p[1L]) } #' @rdname Bhattacharjee #' @export rbhatt <- function(n, mu = 0, sigma = 1, a = sigma) { if (length(n) > 1) n <- length(n) cpp_rbhatt(n, mu, sigma, a) } extraDistr/R/kumaraswamy-distribution.R0000755000176200001440000000440014475546572020031 0ustar liggesusers #' Kumaraswamy distribution #' #' Density, distribution function, quantile function and random generation #' for the Kumaraswamy distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param a,b positive valued parameters. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = abx^{a-1} (1-x^a)^{b-1} #' }{ #' f(x) = a*b*x^(a-1)*(1-x^a)^(b-1) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = 1-(1-x^a)^b #' }{ #' F(x) = 1-(1-x^a)^b #' } #' #' Quantile function #' \deqn{ #' F^{-1}(p) = 1-(1-p^{1/b})^{1/a} #' }{ #' F^-1(p) = 1-(1-p^(1/b))^(1/a) #' } #' #' @references #' Jones, M. C. (2009). Kumaraswamy's distribution: A beta-type distribution with #' some tractability advantages. Statistical Methodology, 6, 70-81. #' #' @references #' Cordeiro, G.M. and de Castro, M. (2009). A new family of generalized distributions. #' Journal of Statistical Computation & Simulation, 1-17. #' #' @examples #' #' x <- rkumar(1e5, 5, 16) #' hist(x, 100, freq = FALSE) #' curve(dkumar(x, 5, 16), 0, 1, col = "red", add = TRUE) #' hist(pkumar(x, 5, 16)) #' plot(ecdf(x)) #' curve(pkumar(x, 5, 16), 0, 1, col = "red", lwd = 2, add = TRUE) #' #' @name Kumaraswamy #' @aliases Kumaraswamy #' @aliases dkumar #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dkumar <- function(x, a = 1, b = 1, log = FALSE) { cpp_dkumar(x, a, b, log[1L]) } #' @rdname Kumaraswamy #' @export pkumar <- function(q, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) { cpp_pkumar(q, a, b, lower.tail[1L], log.p[1L]) } #' @rdname Kumaraswamy #' @export qkumar <- function(p, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) { cpp_qkumar(p, a, b, lower.tail[1L], log.p[1L]) } #' @rdname Kumaraswamy #' @export rkumar <- function(n, a = 1, b = 1) { if (length(n) > 1) n <- length(n) cpp_rkumar(n, a, b) } extraDistr/R/slash-distribution.R0000755000176200001440000000430114475546572016602 0ustar liggesusers #' Slash distribution #' #' Probability mass function, distribution function and random generation #' for slash distribution. #' #' @param x,q vector of quantiles. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param mu vector of locations #' @param sigma vector of positive valued scale parameters. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' If \eqn{Z \sim \mathrm{Normal}(0, 1)}{Z ~ Normal(0, 1)} and \eqn{U \sim \mathrm{Uniform}(0, 1)}{U ~ Uniform(0, 1)}, #' then \eqn{Z/U} follows slash distribution. #' #' Probability density function #' #' \deqn{ #' f(x) = \left\{\begin{array}{ll} #' \frac{\phi(0) - \phi(x)}{x^2} & x \ne 0 \\ #' \frac{1}{2\sqrt{2\pi}} & x = 0 #' \end{array}\right. #' }{ #' f(x) = [if x != 0:] (\phi(0)-\phi(x))/x^2 [else:] 1/(2*sqrt(2*\pi)) #' } #' #' Cumulative distribution function #' #' \deqn{ #' F(x) = \left\{\begin{array}{ll} #' \Phi(x) - \frac{\phi(0)-\phi(x)}{x} & x \neq 0 \\ #' \frac{1}{2} & x = 0 #' \end{array}\right. #' }{ #' F(x) = [if x != 0:] \Phi(x) - [\phi(0)-\phi(x)]/x [else:] 1/2 #' } #' #' @examples #' #' x <- rslash(1e5, 5, 3) #' hist(x, 1e5, freq = FALSE, xlim = c(-100, 100)) #' curve(dslash(x, 5, 3), -100, 100, col = "red", n = 500, add = TRUE) #' hist(pslash(x, 5, 3)) #' plot(ecdf(x), xlim = c(-100, 100)) #' curve(pslash(x, 5, 3), -100, 100, col = "red", lwd = 2, n = 500, add = TRUE) #' #' @name Slash #' @aliases Slash #' @aliases dslash #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dslash <- function(x, mu = 0, sigma = 1, log = FALSE) { cpp_dslash(x, mu, sigma, log[1L]) } #' @rdname Slash #' @export pslash <- function(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_pslash(q, mu, sigma, lower.tail[1L], log.p[1L]) } #' @rdname Slash #' @export rslash <- function(n, mu = 0, sigma = 1) { if (length(n) > 1) n <- length(n) cpp_rslash(n, mu, sigma) } extraDistr/R/triangular-distribution.R0000755000176200001440000000610614475546572017645 0ustar liggesusers #' Triangular distribution #' #' Density, distribution function, quantile function and random generation #' for the triangular distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param a,b,c minimum, maximum and mode of the distribution. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \left\{\begin{array}{ll} #' \frac{2(x-a)}{(b-a)(c-a)} & x < c \\ #' \frac{2}{b-a} & x = c \\ #' \frac{2(b-x)}{(b-a)(b-c)} & x > c #' \end{array}\right. #' }{ #' f(x) = [if x < c:] (2*(x-a)) / ((b-a)*(c-a)) #' [if x = c:] 2/(b-a) #' [if x >= c:] (2*(b-x)) / ((b-a)*(b-c)) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = \left\{\begin{array}{ll} #' \frac{(x-a)^2}{(b-a)(c-a)} & x \leq c \\ #' 1 - \frac{(b-x)^2}{(b-a)(b-c)} & x > c #' \end{array}\right. #' }{ #' F(x) = [if x <= c:] (x-a)^2 / ((b-a)*(c-a)) #' [if x > c:] 1 - ((b-x)^2 / ((b-a)*(b-c))) #' } #' #' Quantile function #' \deqn{ #' F^{-1}(p) = \left\{\begin{array}{ll} #' a + \sqrt{p \times (b-a)(c-a)} & p \leq \frac{c-a}{b-a} \\ #' b - \sqrt{(1-p)(b-a)(b-c)} & p > \frac{c-a}{b-a} #' \end{array}\right. #' }{ #' F^-1(p) = [if p < (c-a)/(b-a):] a + sqrt(p*(b-a)*(c-a)) #' [else:] b - sqrt((1-p)*(b-a)*(b-c)) #' } #' #' For random generation MINMAX method described by #' Stein and Keblis (2009) is used. #' #' @references #' Forbes, C., Evans, M. Hastings, N., & Peacock, B. (2011). #' Statistical Distributions. John Wiley & Sons. #' #' @references #' Stein, W. E., & Keblis, M. F. (2009). #' A new method to simulate the triangular distribution. #' Mathematical and computer modelling, 49(5), 1143-1147. #' #' @examples #' #' x <- rtriang(1e5, 5, 7, 6) #' hist(x, 100, freq = FALSE) #' curve(dtriang(x, 5, 7, 6), 3, 10, n = 500, col = "red", add = TRUE) #' hist(ptriang(x, 5, 7, 6)) #' plot(ecdf(x)) #' curve(ptriang(x, 5, 7, 6), 3, 10, n = 500, col = "red", lwd = 2, add = TRUE) #' #' @name Triangular #' @aliases Triangular #' @aliases dtriang #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dtriang <- function(x, a = -1, b = 1, c = (a+b)/2, log = FALSE) { cpp_dtriang(x, a, b, c, log[1L]) } #' @rdname Triangular #' @export ptriang <- function(q, a = -1, b = 1, c = (a+b)/2, lower.tail = TRUE, log.p = FALSE) { cpp_ptriang(q, a, b, c, lower.tail[1L], log.p[1L]) } #' @rdname Triangular #' @export qtriang <- function(p, a = -1, b = 1, c = (a+b)/2, lower.tail = TRUE, log.p = FALSE) { cpp_qtriang(p, a, b, c, lower.tail[1L], log.p[1L]) } #' @rdname Triangular #' @export rtriang <- function(n, a = -1, b = 1, c = (a+b)/2) { if (length(n) > 1) n <- length(n) cpp_rtriang(n, a, b, c) } extraDistr/R/location-scale-t-distribution.R0000755000176200001440000000423014475546572020627 0ustar liggesusers #' Location-scale version of the t-distribution #' #' Probability mass function, distribution function and random generation #' for location-scale version of the t-distribution. Location-scale version #' of the t-distribution besides degrees of freedom \eqn{\nu}, is parametrized #' using additional parameters \eqn{\mu} for location and \eqn{\sigma} for #' scale (\eqn{\mu = 0} and \eqn{\sigma = 1} for standard t-distribution). #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param mu vector of locations #' @param sigma vector of positive valued scale parameters. #' @param df degrees of freedom (> 0, maybe non-integer). \code{df = Inf} is allowed. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @seealso \code{\link[stats]{TDist}} #' #' @examples #' #' x <- rlst(1e5, 1000, 5, 13) #' hist(x, 100, freq = FALSE) #' curve(dlst(x, 1000, 5, 13), -60, 60, col = "red", add = TRUE) #' hist(plst(x, 1000, 5, 13)) #' plot(ecdf(x)) #' curve(plst(x, 1000, 5, 13), -60, 60, col = "red", lwd = 2, add = TRUE) #' #' @name LocationScaleT #' @aliases LocationScaleT #' @aliases dlst #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dlst <- function(x, df, mu = 0, sigma = 1, log = FALSE) { cpp_dlst(x, df, mu, sigma, log[1L]) } #' @rdname LocationScaleT #' @export plst <- function(q, df, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_plst(q, df, mu, sigma, lower.tail[1L], log.p[1L]) } #' @rdname LocationScaleT #' @export qlst <- function(p, df, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_qlst(p, df, mu, sigma, lower.tail[1L], log.p[1L]) } #' @rdname LocationScaleT #' @export rlst <- function(n, df, mu = 0, sigma = 1) { if (length(n) > 1) n <- length(n) cpp_rlst(n, df, mu, sigma) } extraDistr/R/rademacher-distribution.R0000755000176200001440000000075314475546572017572 0ustar liggesusers #' Random generation from Rademacher distribution #' #' Random generation for the Rademacher distribution (values -1 and +1 #' with equal probability). #' #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' #' @name Rademacher #' @aliases Rademacher #' @aliases rsign #' #' @keywords distribution #' #' @export rsign <- function(n) { if (length(n) > 1) n <- length(n) cpp_rsign(n) } extraDistr/R/dirichlet-distribution.R0000755000176200001440000000367514475546572017454 0ustar liggesusers #' Dirichlet distribution #' #' Density function, cumulative distribution function and random generation #' for the Dirichlet distribution. #' #' @param x \eqn{k}-column matrix of quantiles. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param alpha \eqn{k}-values vector or \eqn{k}-column matrix; #' concentration parameter. Must be positive. #' @param log logical; if TRUE, probabilities p are given as log(p). #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \frac{\Gamma(\sum_k \alpha_k)}{\prod_k \Gamma(\alpha_k)} \prod_k x_k^{k-1} #' }{ #' f(x) = \Gamma(sum(\alpha[k])) / prod(\Gamma(\alpha[k])) * prod(x[k]^{k-1}) #' } #' #' @references #' Devroye, L. (1986). Non-Uniform Random Variate Generation. Springer-Verlag. #' #' @examples #' #' # Generating 10 random draws from Dirichlet distribution #' # parametrized using a vector #' #' rdirichlet(10, c(1, 1, 1, 1)) #' #' # or parametrized using a matrix where each row #' # is a vector of parameters #' #' alpha <- matrix(c(1, 1, 1, 1:3, 7:9), ncol = 3, byrow = TRUE) #' rdirichlet(10, alpha) #' #' @name Dirichlet #' @aliases Dirichlet #' @aliases ddirichlet #' #' @keywords distribution #' @concept Multivariate #' @concept Continuous #' #' @export ddirichlet <- function(x, alpha, log = FALSE) { if (is.vector(alpha)) alpha <- matrix(alpha, nrow = 1) else if (!is.matrix(alpha)) alpha <- as.matrix(alpha) if (is.data.frame(x)) x <- as.matrix(x) else if (is.vector(x)) x <- matrix(x, byrow = TRUE, nrow = 1) cpp_ddirichlet(x, alpha, log[1L]) } #' @rdname Dirichlet #' @export rdirichlet <- function (n, alpha) { if (length(n) > 1) n <- length(n) if (is.vector(alpha)) alpha <- matrix(alpha, nrow = 1) else if (!is.matrix(alpha)) alpha <- as.matrix(alpha) cpp_rdirichlet(n, alpha) } extraDistr/R/inverse-gamma-distribution.R0000755000176200001440000000455614475546572020237 0ustar liggesusers #' Inverse-gamma distribution #' #' Density, distribution function and random generation #' for the inverse-gamma distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param alpha,beta positive valued shape and scale parameters. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability mass function #' \deqn{ #' f(x) = \frac{\beta^\alpha x^{-\alpha-1} \exp(-\frac{\beta}{x})}{\Gamma(\alpha)} #' }{ #' f(x) = (\beta^\alpha * x^(-\alpha-1) * exp(-\beta/x)) / \Gamma(\alpha) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = \frac{\gamma(\alpha, \frac{\beta}{x})}{\Gamma(\alpha)} #' }{ #' F(x) = \gamma(\alpha, \beta/x) / \Gamma(\alpha) #' } #' #' @references #' Witkovsky, V. (2001). Computing the distribution of a linear #' combination of inverted gamma variables. Kybernetika 37(1), 79-90. #' #' @references #' Leemis, L.M. and McQueston, L.T. (2008). Univariate Distribution #' Relationships. American Statistician 62(1): 45-53. #' #' @seealso \code{\link[stats]{GammaDist}} #' #' @examples #' #' x <- rinvgamma(1e5, 20, 3) #' hist(x, 100, freq = FALSE) #' curve(dinvgamma(x, 20, 3), 0, 1, col = "red", add = TRUE, n = 5000) #' hist(pinvgamma(x, 20, 3)) #' plot(ecdf(x)) #' curve(pinvgamma(x, 20, 3), 0, 1, col = "red", lwd = 2, add = TRUE, n = 5000) #' #' @name InvGamma #' @aliases InvGamma #' @aliases dinvgamma #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dinvgamma <- function(x, alpha, beta = 1, log = FALSE) { cpp_dinvgamma(x, alpha, 1/beta, log[1L]) } #' @rdname InvGamma #' @export pinvgamma <- function(q, alpha, beta = 1, lower.tail = TRUE, log.p = FALSE) { cpp_pinvgamma(q, alpha, beta, lower.tail, log.p[1L]) } #' @rdname InvGamma #' @export qinvgamma <- function(p, alpha, beta = 1, lower.tail = TRUE, log.p = FALSE) { 1/qgamma(p, alpha, beta, lower.tail = !lower.tail[1L], log.p = log.p[1L]) } #' @rdname InvGamma #' @export rinvgamma <- function(n, alpha, beta = 1) { 1/rgamma(n, alpha, beta) } extraDistr/R/rayleigh-distribution.R0000755000176200001440000000444414475546572017304 0ustar liggesusers #' Rayleigh distribution #' #' Density, distribution function, quantile function and random generation #' for the Rayleigh distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param sigma positive valued parameter. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \frac{x}{\sigma^2} \exp\left(-\frac{x^2}{2\sigma^2}\right) #' }{ #' f(x) = x/\sigma^2 * exp(-(x^2 / 2*\sigma^2)) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = 1 - \exp\left(-\frac{x^2}{2\sigma^2}\right) #' }{ #' F(x) = 1 - exp(-x^2 / 2*\sigma^2) #' } #' #' Quantile function #' \deqn{ #' F^{-1}(p) = \sqrt{-2\sigma^2 \log(1-p)} #' }{ #' F^-1(p) = sqrt(-2*\sigma^2 * log(1-p)) #' } #' #' @references #' Krishnamoorthy, K. (2006). Handbook of Statistical Distributions #' with Applications. Chapman & Hall/CRC. #' #' @references #' Forbes, C., Evans, M. Hastings, N., & Peacock, B. (2011). #' Statistical Distributions. John Wiley & Sons. #' #' @examples #' #' x <- rrayleigh(1e5, 13) #' hist(x, 100, freq = FALSE) #' curve(drayleigh(x, 13), 0, 60, col = "red", add = TRUE) #' hist(prayleigh(x, 13)) #' plot(ecdf(x)) #' curve(prayleigh(x, 13), 0, 60, col = "red", lwd = 2, add = TRUE) #' #' @name Rayleigh #' @aliases Rayleigh #' @aliases drayleigh #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export drayleigh <- function(x, sigma = 1, log = FALSE) { cpp_drayleigh(x, sigma, log[1L]) } #' @rdname Rayleigh #' @export prayleigh <- function(q, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_prayleigh(q, sigma, lower.tail[1L], log.p[1L]) } #' @rdname Rayleigh #' @export qrayleigh <- function(p, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_qrayleigh(p, sigma, lower.tail[1L], log.p[1L]) } #' @rdname Rayleigh #' @export rrayleigh <- function(n, sigma = 1) { if (length(n) > 1) n <- length(n) cpp_rrayleigh(n, sigma) } extraDistr/R/gompertz-distribution.R0000755000176200001440000000446214524412013017320 0ustar liggesusers#' Gompertz distribution #' #' Density, distribution function, quantile function and random generation #' for the Gompertz distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param a,b positive valued scale and location parameters. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = a \exp\left(bx - \frac{a}{b} (\exp(bx)-1)\right) #' }{ #' f(x) = a*exp(b*x - a/b * (exp(b*x)-1)) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = 1-\exp\left(-\frac{a}{b} (\exp(bx)-1)\right) #' }{ #' F(x) = 1-exp(-a/b * (exp(b*x)-1)) #' } #' #' Quantile function #' \deqn{ #' F^{-1}(p) = \frac{1}{b} \log\left(1-\frac{b}{a}\log(1-p)\right) #' }{ #' F^-1(p) = 1/b * log(1 - b/a * log(1-p)) #' } #' #' @references #' Lenart, A. (2012). The Gompertz distribution and Maximum Likelihood Estimation #' of its parameters - a revision. MPIDR WORKING PAPER WP 2012-008. #' \url{https://www.demogr.mpg.de/papers/working/wp-2012-008.pdf} #' #' @examples #' #' x <- rgompertz(1e5, 5, 2) #' hist(x, 100, freq = FALSE) #' curve(dgompertz(x, 5, 2), 0, 1, col = "red", add = TRUE) #' hist(pgompertz(x, 5, 2)) #' plot(ecdf(x)) #' curve(pgompertz(x, 5, 2), 0, 1, col = "red", lwd = 2, add = TRUE) #' #' @name Gompertz #' @aliases Gompertz #' @aliases dgompertz #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dgompertz <- function(x, a = 1, b = 1, log = FALSE) { cpp_dgompertz(x, a, b, log[1L]) } #' @rdname Gompertz #' @export pgompertz <- function(q, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) { cpp_pgompertz(q, a, b, lower.tail[1L], log.p[1L]) } #' @rdname Gompertz #' @export qgompertz <- function(p, a = 1, b = 1, lower.tail = TRUE, log.p = FALSE) { cpp_qgompertz(p, a, b, lower.tail[1L], log.p[1L]) } #' @rdname Gompertz #' @export rgompertz <- function(n, a = 1, b = 1) { if (length(n) > 1) n <- length(n) cpp_rgompertz(n, a, b) } extraDistr/R/truncated-normal-distribution.R0000755000176200001440000001074614475546572020761 0ustar liggesusers #' Truncated normal distribution #' #' Density, distribution function, quantile function and random generation #' for the truncated normal distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param mean,sd location and scale parameters. Scale must be positive. #' @param a,b lower and upper truncation points (\code{a < x <= b}, #' with \code{a = -Inf} and \code{b = Inf} by default). #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \frac{\phi(\frac{x-\mu}{\sigma})} #' {\Phi(\frac{b-\mu}{\sigma}) - \Phi(\frac{a-\mu}{\sigma})} #' }{ #' f(x) = \phi((x-\mu)/\sigma) / (\Phi((b-\mu)/\sigma) - \Phi((a-\mu)/\sigma)) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = \frac{\Phi(\frac{x-\mu}{\sigma}) - \Phi(\frac{a-\mu}{\sigma})} #' {\Phi(\frac{b-\mu}{\sigma}) - \Phi(\frac{a-\mu}{\sigma})} #' }{ #' F(x) = (\Phi((x-\mu)/\sigma) - \Phi((a-\mu)/\sigma)) / (\Phi((b-\mu)/\sigma) - \Phi((a-\mu)/\sigma)) #' } #' #' Quantile function #' \deqn{ #' F^{-1}(p) = \Phi^{-1}\left(\Phi\left(\frac{a-\mu}{\sigma}\right) + p \times #' \left[\Phi\left(\frac{b-\mu}{\sigma}\right) - #' \Phi\left(\frac{a-\mu}{\sigma}\right)\right]\right) #' }{ #' F^-1(p) = \Phi^-1(\Phi((a-\mu)/\sigma) + p * (\Phi((b-\mu)/\sigma) - \Phi((a-\mu)/\sigma))) #' } #' #' For random generation algorithm described by Robert (1995) is used. #' #' @references #' Robert, C.P. (1995). Simulation of truncated normal variables. #' Statistics and Computing 5(2): 121-125. \url{https://arxiv.org/abs/0907.4010} #' #' @references #' Burkardt, J. (17 October 2014). The Truncated Normal Distribution. Florida State University. #' \url{https://people.sc.fsu.edu/~jburkardt/presentations/truncated_normal.pdf} #' #' @examples #' #' x <- rtnorm(1e5, 5, 3, b = 7) #' hist(x, 100, freq = FALSE) #' curve(dtnorm(x, 5, 3, b = 7), -8, 8, col = "red", add = TRUE) #' hist(ptnorm(x, 5, 3, b = 7)) #' plot(ecdf(x)) #' curve(ptnorm(x, 5, 3, b = 7), -8, 8, col = "red", lwd = 2, add = TRUE) #' #' R <- 1e5 #' partmp <- par(mfrow = c(2,4), mar = c(2,2,2,2)) #' #' hist(rtnorm(R), freq= FALSE, main = "", xlab = "", ylab = "") #' curve(dtnorm(x), -5, 5, col = "red", add = TRUE) #' #' hist(rtnorm(R, a = 0), freq= FALSE, main = "", xlab = "", ylab = "") #' curve(dtnorm(x, a = 0), -1, 5, col = "red", add = TRUE) #' #' hist(rtnorm(R, b = 0), freq= FALSE, main = "", xlab = "", ylab = "") #' curve(dtnorm(x, b = 0), -5, 5, col = "red", add = TRUE) #' #' hist(rtnorm(R, a = 0, b = 1), freq= FALSE, main = "", xlab = "", ylab = "") #' curve(dtnorm(x, a = 0, b = 1), -1, 2, col = "red", add = TRUE) #' #' hist(rtnorm(R, a = -1, b = 0), freq= FALSE, main = "", xlab = "", ylab = "") #' curve(dtnorm(x, a = -1, b = 0), -2, 2, col = "red", add = TRUE) #' #' hist(rtnorm(R, mean = -6, a = 0), freq= FALSE, main = "", xlab = "", ylab = "") #' curve(dtnorm(x, mean = -6, a = 0), -2, 1, col = "red", add = TRUE) #' #' hist(rtnorm(R, mean = 8, b = 0), freq= FALSE, main = "", xlab = "", ylab = "") #' curve(dtnorm(x, mean = 8, b = 0), -2, 1, col = "red", add = TRUE) #' #' hist(rtnorm(R, a = 3, b = 5), freq= FALSE, main = "", xlab = "", ylab = "") #' curve(dtnorm(x, a = 3, b = 5), 2, 5, col = "red", add = TRUE) #' #' par(partmp) #' #' @name TruncNormal #' @aliases TruncNormal #' @aliases dtnorm #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dtnorm <- function(x, mean = 0, sd = 1, a = -Inf, b = Inf, log = FALSE) { cpp_dtnorm(x, mean, sd, a, b, log[1L]) } #' @rdname TruncNormal #' @export ptnorm <- function(q, mean = 0, sd = 1, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) { cpp_ptnorm(q, mean, sd, a, b, lower.tail[1L], log.p[1L]) } #' @rdname TruncNormal #' @export qtnorm <- function(p, mean = 0, sd = 1, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) { cpp_qtnorm(p, mean, sd, a, b, lower.tail[1L], log.p[1L]) } #' @rdname TruncNormal #' @export rtnorm <- function(n, mean = 0, sd = 1, a = -Inf, b = Inf) { if (length(n) > 1) n <- length(n) cpp_rtnorm(n, mean, sd, a, b) } extraDistr/R/laplace-distribution.R0000755000176200001440000000536014475546572017077 0ustar liggesusers #' Laplace distribution #' #' Density, distribution function, quantile function and random generation #' for the Laplace distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param mu,sigma location and scale parameters. Scale must be positive. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \frac{1}{2\sigma} \exp\left(-\left|\frac{x-\mu}{\sigma}\right|\right) #' }{ #' f(x) = 1/(2*\sigma) * exp(-|(x-\mu)/\sigma|) #' } #' #' Cumulative distribution function #' \deqn{ F(x) = \left\{\begin{array}{ll} #' \frac{1}{2} \exp\left(\frac{x-\mu}{\sigma}\right) & x < \mu \\ #' 1 - \frac{1}{2} \exp\left(\frac{x-\mu}{\sigma}\right) & x \geq \mu #' \end{array}\right. #' }{ #' F(x) = [if x < mu:] 1/2 * exp((x-\mu)/\sigma) #' [else:] 1 - 1/2 * exp((x-\mu)/\sigma) #' } #' #' Quantile function #' \deqn{ F^{-1}(p) = \left\{\begin{array}{ll} #' \mu + \sigma \log(2p) & p < 0.5 \\ #' \mu - \sigma \log(2(1-p)) & p \geq 0.5 #' \end{array}\right. #' }{ #' F^-1(p) = [if p < 0.5:] \mu + \sigma * log(2*p) #' [else:] \mu - \sigma * log(2*(1-p)) #' } #' #' @references #' Krishnamoorthy, K. (2006). Handbook of Statistical Distributions #' with Applications. Chapman & Hall/CRC #' #' @references #' Forbes, C., Evans, M. Hastings, N., & Peacock, B. (2011). #' Statistical Distributions. John Wiley & Sons. #' #' @examples #' #' x <- rlaplace(1e5, 5, 16) #' hist(x, 100, freq = FALSE) #' curve(dlaplace(x, 5, 16), -200, 200, n = 500, col = "red", add = TRUE) #' hist(plaplace(x, 5, 16)) #' plot(ecdf(x)) #' curve(plaplace(x, 5, 16), -200, 200, n = 500, col = "red", lwd = 2, add = TRUE) #' #' @name Laplace #' @aliases Laplace #' @aliases dlaplace #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dlaplace <- function(x, mu = 0, sigma = 1, log = FALSE) { cpp_dlaplace(x, mu, sigma, log[1L]) } #' @rdname Laplace #' @export plaplace <- function(q, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_plaplace(q, mu, sigma, lower.tail[1L], log.p[1L]) } #' @rdname Laplace #' @export qlaplace <- function(p, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_qlaplace(p, mu, sigma, lower.tail[1L], log.p[1L]) } #' @rdname Laplace #' @export rlaplace <- function(n, mu = 0, sigma = 1) { if (length(n) > 1) n <- length(n) cpp_rlaplace(n, mu, sigma) } extraDistr/R/truncated-poisson-distributtion.R0000755000176200001440000000527414475546572021347 0ustar liggesusers #' Truncated Poisson distribution #' #' Density, distribution function, quantile function and random generation #' for the truncated Poisson distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param lambda vector of (non-negative) means. #' @param a,b lower and upper truncation points (\code{a < x <= b}). #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @references #' Plackett, R.L. (1953). The truncated Poisson distribution. #' Biometrics, 9(4), 485-488. #' #' @references #' Singh, J. (1978). A characterization of positive Poisson distribution and #' its statistical application. #' SIAM Journal on Applied Mathematics, 34(3), 545-548. #' #' @references #' Dalgaard, P. (May 1, 2005). [R] simulate zero-truncated Poisson distribution. #' R-help mailing list. #' \url{https://stat.ethz.ch/pipermail/r-help/2005-May/070680.html} #' #' @examples #' #' x <- rtpois(1e5, 14, 16) #' xx <- seq(-1, 50) #' plot(prop.table(table(x))) #' lines(xx, dtpois(xx, 14, 16), col = "red") #' hist(ptpois(x, 14, 16)) #' #' xx <- seq(0, 50, by = 0.01) #' plot(ecdf(x)) #' lines(xx, ptpois(xx, 14, 16), col = "red", lwd = 2) #' #' uu <- seq(0, 1, by = 0.001) #' lines(qtpois(uu, 14, 16), uu, col = "blue", lty = 2) #' #' # Zero-truncated Poisson #' #' x <- rtpois(1e5, 5, 0) #' xx <- seq(-1, 50) #' plot(prop.table(table(x))) #' lines(xx, dtpois(xx, 5, 0), col = "red") #' hist(ptpois(x, 5, 0)) #' #' xx <- seq(0, 50, by = 0.01) #' plot(ecdf(x)) #' lines(xx, ptpois(xx, 5, 0), col = "red", lwd = 2) #' lines(qtpois(uu, 5, 0), uu, col = "blue", lty = 2) #' #' @name TruncPoisson #' @aliases TruncPoisson #' @aliases dtpois #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export dtpois <- function(x, lambda, a = -Inf, b = Inf, log = FALSE) { cpp_dtpois(x, lambda, a, b, log) } #' @rdname TruncPoisson #' @export ptpois <- function(q, lambda, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) { cpp_ptpois(q, lambda, a, b, lower.tail[1L], log.p[1L]) } #' @rdname TruncPoisson #' @export qtpois <- function(p, lambda, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) { cpp_qtpois(p, lambda, a, b, lower.tail[1L], log.p[1L]) } #' @rdname TruncPoisson #' @export rtpois <- function(n, lambda, a = -Inf, b = Inf) { if (length(n) > 1) n <- length(n) cpp_rtpois(n, lambda, a, b) } extraDistr/R/zero-inflated-binomial-distribution.R0000755000176200001440000000407714475546572022035 0ustar liggesusers #' Zero-inflated binomial distribution #' #' Probability mass function and random generation #' for the zero-inflated binomial distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param size number of trials (zero or more). #' @param prob probability of success in each trial. \code{0 < prob <= 1}. #' @param pi probability of extra zeros. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \left\{\begin{array}{ll} #' \pi + (1 - \pi) (1-p)^n & x = 0 \\ #' (1 - \pi) {n \choose x} p^x (1-p)^{n-x} & x > 0 \\ #' \end{array}\right. #' }{ #' f(x) = [if x = 0:] (1-\pi)+\pi * p^r [else:] (1-\pi) * dnbinom(x, size, prob) #' } #' #' @seealso \code{\link[stats]{Binomial}} #' #' @examples #' #' x <- rzib(1e5, 10, 0.6, 0.33) #' xx <- -2:20 #' plot(prop.table(table(x)), type = "h") #' lines(xx, dzib(xx, 10, 0.6, 0.33), col = "red") #' #' xx <- seq(0, 20, by = 0.01) #' plot(ecdf(x)) #' lines(xx, pzib(xx, 10, 0.6, 0.33), col = "red") #' #' @name ZIB #' @aliases ZIB #' @aliases dzib #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export dzib <- function(x, size, prob, pi, log = FALSE) { cpp_dzib(x, size, prob, pi, log[1L]) } #' @rdname ZIB #' @export pzib <- function(q, size, prob, pi, lower.tail = TRUE, log.p = FALSE) { cpp_pzib(q, size, prob, pi, lower.tail[1L], log.p[1L]) } #' @rdname ZIB #' @export qzib <- function(p, size, prob, pi, lower.tail = TRUE, log.p = FALSE) { cpp_qzib(p, size, prob, pi, lower.tail[1L], log.p[1L]) } #' @rdname ZIB #' @export rzib <- function(n, size, prob, pi) { if (length(n) > 1) n <- length(n) cpp_rzib(n, size, prob, pi) } extraDistr/R/beta-binomial-distribution.R0000755000176200001440000000674314475546572020207 0ustar liggesusers #' Beta-binomial distribution #' #' Probability mass function and random generation #' for the beta-binomial distribution. #' #' @param x,q vector of quantiles. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param alpha,beta non-negative parameters of the beta distribution. #' @param size number of trials (zero or more). #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' If \eqn{p \sim \mathrm{Beta}(\alpha, \beta)}{p ~ Beta(\alpha, \beta)} and #' \eqn{X \sim \mathrm{Binomial}(n, p)}{X ~ Binomial(n, p)}, then #' \eqn{X \sim \mathrm{BetaBinomial}(n, \alpha, \beta)}{X ~ BetaBinomial(n, \alpha, \beta)}. #' #' Probability mass function #' \deqn{ #' f(x) = {n \choose x} \frac{\mathrm{B}(x+\alpha, n-x+\beta)}{\mathrm{B}(\alpha, \beta)} #' }{ #' f(x) = choose(n, x) * B(x+\alpha, n-x+\beta) / B(\alpha, \beta) #' } #' #' Cumulative distribution function is calculated using recursive algorithm that employs the fact that #' \eqn{\Gamma(x) = (x - 1)!}, and #' \eqn{ #' \mathrm{B}(x, y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)} #' }{ #' B(x, y) = (\Gamma(x)\Gamma(y))/\Gamma(x+y) #' }, and that #' \eqn{ #' {n \choose k} = \prod_{i=1}^k \frac{n+1-i}{i} #' }{ #' choose(n,k) = prod((n+1-(1:k))/(1:k)) #' }. This enables re-writing probability mass function as #' #' \deqn{ #' f(x) = \left( \prod_{i=1}^x \frac{n+1-i}{i} \right) \frac{\frac{(\alpha+x-1)!\,(\beta+n-x-1)!}{(\alpha+\beta+n-1)!}}{\mathrm{B}(\alpha,\beta)} #' }{ #' f(x) = prod((n+1-(1:x))/(1:x)) * (((\alpha+x-1)!*(\beta+n-x-1)!)/((\alpha+\beta+n+1)!)) / B(\alpha, \beta) #' } #' #' what makes recursive updating from \eqn{x} to \eqn{x+1} easy using the properties of factorials #' #' \deqn{ #' f(x+1) = \left( \prod_{i=1}^x \frac{n+1-i}{i} \right) \frac{n+1-x+1}{x+1} \frac{\frac{(\alpha+x-1)! \,(\alpha+x)\,(\beta+n-x-1)! \, (\beta+n-x)^{-1}}{(\alpha+\beta+n-1)!\,(\alpha+\beta+n)}}{\mathrm{B}(\alpha,\beta)} #' }{ #' f(x+1) = prod((n+1-(1:x))/(1:x)) * ((n+1-x+1)/(x+1)) * (((\alpha+x-1)!*(\alpha+x)*(\beta+n-x-1)!/(\beta+n-x))/((\alpha+\beta+n+1)!*(\alpha+\beta+n))) / B(\alpha, \beta) #' } #' #' and let's us efficiently calculate cumulative distribution function as a sum of probability mass functions #' #' \deqn{F(x) = \sum_{k=0}^x f(k)}{F(x) = f(0)+...+f(x)} #' #' #' @seealso \code{\link[stats]{Beta}}, \code{\link[stats]{Binomial}} #' #' @examples #' #' x <- rbbinom(1e5, 1000, 5, 13) #' xx <- 0:1000 #' hist(x, 100, freq = FALSE) #' lines(xx-0.5, dbbinom(xx, 1000, 5, 13), col = "red") #' hist(pbbinom(x, 1000, 5, 13)) #' xx <- seq(0, 1000, by = 0.1) #' plot(ecdf(x)) #' lines(xx, pbbinom(xx, 1000, 5, 13), col = "red", lwd = 2) #' #' @name BetaBinom #' @aliases BetaBinom #' @aliases dbbinom #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export dbbinom <- function(x, size, alpha = 1, beta = 1, log = FALSE) { cpp_dbbinom(x, size, alpha, beta, log[1L]) } #' @rdname BetaBinom #' @export pbbinom <- function(q, size, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE) { cpp_pbbinom(q, size, alpha, beta, lower.tail[1L], log.p[1L]) } #' @rdname BetaBinom #' @export rbbinom <- function(n, size, alpha = 1, beta = 1) { if (length(n) > 1) n <- length(n) cpp_rbbinom(n, size, alpha, beta) } extraDistr/R/extraDistr-deprecated.R0000755000176200001440000000000014475546572017172 0ustar liggesusersextraDistr/R/extraDistr-package.R0000755000176200001440000000226014532041715016456 0ustar liggesusers#' @keywords internal "_PACKAGE" #' Additional univariate and multivariate distributions #' #' Density, distribution function, quantile function and random #' generation for a number of univariate and multivariate distributions. #' #' @details #' #' This package follows naming convention that is consistent with base R, #' where density (or probability mass) functions, distribution functions, #' quantile functions and random generation functions names are followed by #' \code{d}*, \code{p}*, \code{q}*, and \code{r}* prefixes. #' #' Behaviour of the functions is consistent with base R, where for #' not valid parameters values \code{NaN}'s are returned, while #' for values beyond function support \code{0}'s are returned #' (e.g. for non-integers in discrete distributions, or for #' negative values in functions with non-negative support). #' #' All the functions vectorized and coded in C++ using \pkg{Rcpp}. #' #' @docType package #' @name extraDistr-package #' #' @useDynLib extraDistr, .registration = TRUE #' @importFrom Rcpp sourceCpp #' #' @importFrom stats pgamma qgamma rgamma #' @importFrom stats pnorm qnorm rnorm #' @importFrom stats rpois #' @importFrom stats qchisq rchisq NULL extraDistr/R/categorical-distribution.R0000755000176200001440000001257414475546572017760 0ustar liggesusers #' Categorical distribution #' #' Probability mass function, distribution function, quantile function and random generation #' for the categorical distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param prob,log_prob vector of length \eqn{m}, or \eqn{m}-column matrix #' of non-negative weights (or their logarithms in \code{log_prob}). #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' @param labels if provided, labeled \code{factor} vector is returned. #' Number of labels needs to be the same as #' number of categories (number of columns in prob). #' #' @details #' Probability mass function #' #' \deqn{ #' \Pr(X = k) = \frac{w_k}{\sum_{j=1}^m w_j} #' }{ #' Pr(X = k) = w[k]/sum(w) #' } #' #' Cumulative distribution function #' \deqn{ #' \Pr(X \le k) = \frac{\sum_{i=1}^k w_i}{\sum_{j=1}^m w_j} #' }{ #' Pr(X <= k) = sum(w[1:k])/sum(w) #' } #' #' It is possible to sample from categorical distribution parametrized #' by vector of unnormalized log-probabilities #' \eqn{\alpha_1,\dots,\alpha_m}{\alpha[1],...,\alpha[m]} #' without leaving the log space by employing the Gumbel-max trick (Maddison, Tarlow and Minka, 2014). #' If \eqn{g_1,\dots,g_m}{g[1],...,g[m]} are samples from Gumbel distribution with #' cumulative distribution function \eqn{F(g) = \exp(-\exp(-g))}{F(g) = exp(-exp(-g))}, #' then \eqn{k = \mathrm{arg\,max}_i \{g_i + \alpha_i\}}{k = argmax(g[i]+\alpha[i])} #' is a draw from categorical distribution parametrized by #' vector of probabilities \eqn{p_1,\dots,p_m}{p[1]....,p[m]}, such that #' \eqn{p_i = \exp(\alpha_i) / [\sum_{j=1}^m \exp(\alpha_j)]}{p[i] = exp(\alpha[i])/sum(exp(\alpha))}. #' This is implemented in \code{rcatlp} function parametrized by vector of #' log-probabilities \code{log_prob}. #' #' @references #' Maddison, C. J., Tarlow, D., & Minka, T. (2014). A* sampling. #' [In:] Advances in Neural Information Processing Systems (pp. 3086-3094). #' \url{https://arxiv.org/abs/1411.0030} #' #' @examples #' #' # Generating 10 random draws from categorical distribution #' # with k=3 categories occuring with equal probabilities #' # parametrized using a vector #' #' rcat(10, c(1/3, 1/3, 1/3)) #' #' # or with k=5 categories parametrized using a matrix of probabilities #' # (generated from Dirichlet distribution) #' #' p <- rdirichlet(10, c(1, 1, 1, 1, 1)) #' rcat(10, p) #' #' x <- rcat(1e5, c(0.2, 0.4, 0.3, 0.1)) #' plot(prop.table(table(x)), type = "h") #' lines(0:5, dcat(0:5, c(0.2, 0.4, 0.3, 0.1)), col = "red") #' #' p <- rdirichlet(1, rep(1, 20)) #' x <- rcat(1e5, matrix(rep(p, 2), nrow = 2, byrow = TRUE)) #' xx <- 0:21 #' plot(prop.table(table(x))) #' lines(xx, dcat(xx, p), col = "red") #' #' xx <- seq(0, 21, by = 0.01) #' plot(ecdf(x)) #' lines(xx, pcat(xx, p), col = "red", lwd = 2) #' #' pp <- seq(0, 1, by = 0.001) #' plot(ecdf(x)) #' lines(qcat(pp, p), pp, col = "red", lwd = 2) #' #' @name Categorical #' @aliases Categorical #' @aliases dcat #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export dcat <- function(x, prob, log = FALSE) { if (is.vector(prob)) prob <- matrix(prob, nrow = 1L) else if (!is.matrix(prob)) prob <- as.matrix(prob) cpp_dcat(as.numeric(x), prob, log[1L]) } #' @rdname Categorical #' @export pcat <- function(q, prob, lower.tail = TRUE, log.p = FALSE) { if (is.vector(prob)) prob <- matrix(prob, nrow = 1L) else if (!is.matrix(prob)) prob <- as.matrix(prob) cpp_pcat(as.numeric(q), prob, lower.tail[1L], log.p[1L]) } #' @rdname Categorical #' @export qcat <- function(p, prob, lower.tail = TRUE, log.p = FALSE, labels) { if (is.vector(prob)) prob <- matrix(prob, nrow = 1L) else if (!is.matrix(prob)) prob <- as.matrix(prob) x <- cpp_qcat(p, prob, lower.tail[1L], log.p[1L]) if (!missing(labels)) { if (length(labels) != ncol(prob)) warning("Wrong number of labels.") else return(factor(x, levels = 1:ncol(prob), labels = labels)) } return(x) } #' @rdname Categorical #' @export rcat <- function(n, prob, labels) { if (length(n) > 1) n <- length(n) if (is.vector(prob)) { k <- length(prob) if (anyNA(prob) || any(prob < 0) || length(prob) == 0) { warning("NAs produced") x <- rep(NA, n) } else { x <- sample.int(k, size = n, replace = TRUE, prob = prob) } } else { k <- ncol(prob) x <- cpp_rcat(n, prob) } if (!missing(labels)) { if (length(labels) != k) warning("Wrong number of labels.") else return(factor(x, levels = 1:k, labels = labels)) } return(x) } #' @rdname Categorical #' @export rcatlp <- function(n, log_prob, labels) { if (length(n) > 1) n <- length(n) if (is.vector(log_prob)) log_prob <- matrix(log_prob, nrow = 1L) x <- cpp_rcatlp(n, log_prob) k <- ncol(log_prob) if (!missing(labels)) { if (length(labels) != k) warning("Wrong number of labels.") else return(factor(x, levels = 1:k, labels = labels)) } return(x) } extraDistr/R/RcppExports.R0000644000176200001440000005737314532037664015251 0ustar liggesusers# Generated by using Rcpp::compileAttributes() -> do not edit by hand # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 cpp_dbern <- function(x, prob, log_prob = FALSE) { .Call(`_extraDistr_cpp_dbern`, x, prob, log_prob) } cpp_pbern <- function(x, prob, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pbern`, x, prob, lower_tail, log_prob) } cpp_qbern <- function(p, prob, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qbern`, p, prob, lower_tail, log_prob) } cpp_rbern <- function(n, prob) { .Call(`_extraDistr_cpp_rbern`, n, prob) } cpp_dbbinom <- function(x, size, alpha, beta, log_prob = FALSE) { .Call(`_extraDistr_cpp_dbbinom`, x, size, alpha, beta, log_prob) } cpp_pbbinom <- function(x, size, alpha, beta, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pbbinom`, x, size, alpha, beta, lower_tail, log_prob) } cpp_rbbinom <- function(n, size, alpha, beta) { .Call(`_extraDistr_cpp_rbbinom`, n, size, alpha, beta) } cpp_dbnbinom <- function(x, size, alpha, beta, log_prob = FALSE) { .Call(`_extraDistr_cpp_dbnbinom`, x, size, alpha, beta, log_prob) } cpp_pbnbinom <- function(x, size, alpha, beta, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pbnbinom`, x, size, alpha, beta, lower_tail, log_prob) } cpp_rbnbinom <- function(n, size, alpha, beta) { .Call(`_extraDistr_cpp_rbnbinom`, n, size, alpha, beta) } cpp_dbetapr <- function(x, alpha, beta, sigma, log_prob = FALSE) { .Call(`_extraDistr_cpp_dbetapr`, x, alpha, beta, sigma, log_prob) } cpp_pbetapr <- function(x, alpha, beta, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pbetapr`, x, alpha, beta, sigma, lower_tail, log_prob) } cpp_qbetapr <- function(p, alpha, beta, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qbetapr`, p, alpha, beta, sigma, lower_tail, log_prob) } cpp_rbetapr <- function(n, alpha, beta, sigma) { .Call(`_extraDistr_cpp_rbetapr`, n, alpha, beta, sigma) } cpp_dbhatt <- function(x, mu, sigma, a, log_prob = FALSE) { .Call(`_extraDistr_cpp_dbhatt`, x, mu, sigma, a, log_prob) } cpp_pbhatt <- function(x, mu, sigma, a, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pbhatt`, x, mu, sigma, a, lower_tail, log_prob) } cpp_rbhatt <- function(n, mu, sigma, a) { .Call(`_extraDistr_cpp_rbhatt`, n, mu, sigma, a) } cpp_dfatigue <- function(x, alpha, beta, mu, log_prob = FALSE) { .Call(`_extraDistr_cpp_dfatigue`, x, alpha, beta, mu, log_prob) } cpp_pfatigue <- function(x, alpha, beta, mu, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pfatigue`, x, alpha, beta, mu, lower_tail, log_prob) } cpp_qfatigue <- function(p, alpha, beta, mu, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qfatigue`, p, alpha, beta, mu, lower_tail, log_prob) } cpp_rfatigue <- function(n, alpha, beta, mu) { .Call(`_extraDistr_cpp_rfatigue`, n, alpha, beta, mu) } cpp_dbnorm <- function(x, y, mu1, mu2, sigma1, sigma2, rho, log_prob = FALSE) { .Call(`_extraDistr_cpp_dbnorm`, x, y, mu1, mu2, sigma1, sigma2, rho, log_prob) } cpp_rbnorm <- function(n, mu1, mu2, sigma1, sigma2, rho) { .Call(`_extraDistr_cpp_rbnorm`, n, mu1, mu2, sigma1, sigma2, rho) } cpp_dbpois <- function(x, y, a, b, c, log_prob = FALSE) { .Call(`_extraDistr_cpp_dbpois`, x, y, a, b, c, log_prob) } cpp_rbpois <- function(n, a, b, c) { .Call(`_extraDistr_cpp_rbpois`, n, a, b, c) } cpp_rcatlp <- function(n, log_prob) { .Call(`_extraDistr_cpp_rcatlp`, n, log_prob) } cpp_dcat <- function(x, prob, log_prob = FALSE) { .Call(`_extraDistr_cpp_dcat`, x, prob, log_prob) } cpp_pcat <- function(x, prob, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pcat`, x, prob, lower_tail, log_prob) } cpp_qcat <- function(p, prob, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qcat`, p, prob, lower_tail, log_prob) } cpp_rcat <- function(n, prob) { .Call(`_extraDistr_cpp_rcat`, n, prob) } cpp_ddirichlet <- function(x, alpha, log_prob = FALSE) { .Call(`_extraDistr_cpp_ddirichlet`, x, alpha, log_prob) } cpp_rdirichlet <- function(n, alpha) { .Call(`_extraDistr_cpp_rdirichlet`, n, alpha) } cpp_ddirmnom <- function(x, size, alpha, log_prob = FALSE) { .Call(`_extraDistr_cpp_ddirmnom`, x, size, alpha, log_prob) } cpp_rdirmnom <- function(n, size, alpha) { .Call(`_extraDistr_cpp_rdirmnom`, n, size, alpha) } cpp_ddgamma <- function(x, shape, scale, log_prob = FALSE) { .Call(`_extraDistr_cpp_ddgamma`, x, shape, scale, log_prob) } cpp_ddlaplace <- function(x, location, scale, log_prob = FALSE) { .Call(`_extraDistr_cpp_ddlaplace`, x, location, scale, log_prob) } cpp_pdlaplace <- function(x, location, scale, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pdlaplace`, x, location, scale, lower_tail, log_prob) } cpp_rdlaplace <- function(n, location, scale) { .Call(`_extraDistr_cpp_rdlaplace`, n, location, scale) } cpp_ddnorm <- function(x, mu, sigma, log_prob = FALSE) { .Call(`_extraDistr_cpp_ddnorm`, x, mu, sigma, log_prob) } cpp_ddunif <- function(x, min, max, log_prob = FALSE) { .Call(`_extraDistr_cpp_ddunif`, x, min, max, log_prob) } cpp_pdunif <- function(x, min, max, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pdunif`, x, min, max, lower_tail, log_prob) } cpp_qdunif <- function(p, min, max, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qdunif`, p, min, max, lower_tail, log_prob) } cpp_rdunif <- function(n, min, max) { .Call(`_extraDistr_cpp_rdunif`, n, min, max) } cpp_ddweibull <- function(x, q, beta, log_prob = FALSE) { .Call(`_extraDistr_cpp_ddweibull`, x, q, beta, log_prob) } cpp_pdweibull <- function(x, q, beta, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pdweibull`, x, q, beta, lower_tail, log_prob) } cpp_qdweibull <- function(p, q, beta, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qdweibull`, p, q, beta, lower_tail, log_prob) } cpp_rdweibull <- function(n, q, beta) { .Call(`_extraDistr_cpp_rdweibull`, n, q, beta) } cpp_dfrechet <- function(x, lambda, mu, sigma, log_prob = FALSE) { .Call(`_extraDistr_cpp_dfrechet`, x, lambda, mu, sigma, log_prob) } cpp_pfrechet <- function(x, lambda, mu, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pfrechet`, x, lambda, mu, sigma, lower_tail, log_prob) } cpp_qfrechet <- function(p, lambda, mu, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qfrechet`, p, lambda, mu, sigma, lower_tail, log_prob) } cpp_rfrechet <- function(n, lambda, mu, sigma) { .Call(`_extraDistr_cpp_rfrechet`, n, lambda, mu, sigma) } cpp_dgpois <- function(x, alpha, beta, log_prob = FALSE) { .Call(`_extraDistr_cpp_dgpois`, x, alpha, beta, log_prob) } cpp_pgpois <- function(x, alpha, beta, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pgpois`, x, alpha, beta, lower_tail, log_prob) } cpp_rgpois <- function(n, alpha, beta) { .Call(`_extraDistr_cpp_rgpois`, n, alpha, beta) } cpp_dgev <- function(x, mu, sigma, xi, log_prob = FALSE) { .Call(`_extraDistr_cpp_dgev`, x, mu, sigma, xi, log_prob) } cpp_pgev <- function(x, mu, sigma, xi, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pgev`, x, mu, sigma, xi, lower_tail, log_prob) } cpp_qgev <- function(p, mu, sigma, xi, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qgev`, p, mu, sigma, xi, lower_tail, log_prob) } cpp_rgev <- function(n, mu, sigma, xi) { .Call(`_extraDistr_cpp_rgev`, n, mu, sigma, xi) } cpp_dgompertz <- function(x, a, b, log_prob = FALSE) { .Call(`_extraDistr_cpp_dgompertz`, x, a, b, log_prob) } cpp_pgompertz <- function(x, a, b, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pgompertz`, x, a, b, lower_tail, log_prob) } cpp_qgompertz <- function(p, a, b, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qgompertz`, p, a, b, lower_tail, log_prob) } cpp_rgompertz <- function(n, a, b) { .Call(`_extraDistr_cpp_rgompertz`, n, a, b) } cpp_dgpd <- function(x, mu, sigma, xi, log_prob = FALSE) { .Call(`_extraDistr_cpp_dgpd`, x, mu, sigma, xi, log_prob) } cpp_pgpd <- function(x, mu, sigma, xi, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pgpd`, x, mu, sigma, xi, lower_tail, log_prob) } cpp_qgpd <- function(p, mu, sigma, xi, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qgpd`, p, mu, sigma, xi, lower_tail, log_prob) } cpp_rgpd <- function(n, mu, sigma, xi) { .Call(`_extraDistr_cpp_rgpd`, n, mu, sigma, xi) } cpp_dgumbel <- function(x, mu, sigma, log_prob = FALSE) { .Call(`_extraDistr_cpp_dgumbel`, x, mu, sigma, log_prob) } cpp_pgumbel <- function(x, mu, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pgumbel`, x, mu, sigma, lower_tail, log_prob) } cpp_qgumbel <- function(p, mu, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qgumbel`, p, mu, sigma, lower_tail, log_prob) } cpp_rgumbel <- function(n, mu, sigma) { .Call(`_extraDistr_cpp_rgumbel`, n, mu, sigma) } cpp_dhcauchy <- function(x, sigma, log_prob = FALSE) { .Call(`_extraDistr_cpp_dhcauchy`, x, sigma, log_prob) } cpp_phcauchy <- function(x, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_phcauchy`, x, sigma, lower_tail, log_prob) } cpp_qhcauchy <- function(p, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qhcauchy`, p, sigma, lower_tail, log_prob) } cpp_rhcauchy <- function(n, sigma) { .Call(`_extraDistr_cpp_rhcauchy`, n, sigma) } cpp_dhnorm <- function(x, sigma, log_prob = FALSE) { .Call(`_extraDistr_cpp_dhnorm`, x, sigma, log_prob) } cpp_phnorm <- function(x, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_phnorm`, x, sigma, lower_tail, log_prob) } cpp_qhnorm <- function(p, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qhnorm`, p, sigma, lower_tail, log_prob) } cpp_rhnorm <- function(n, sigma) { .Call(`_extraDistr_cpp_rhnorm`, n, sigma) } cpp_dht <- function(x, nu, sigma, log_prob = FALSE) { .Call(`_extraDistr_cpp_dht`, x, nu, sigma, log_prob) } cpp_pht <- function(x, nu, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pht`, x, nu, sigma, lower_tail, log_prob) } cpp_qht <- function(p, nu, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qht`, p, nu, sigma, lower_tail, log_prob) } cpp_rht <- function(n, nu, sigma) { .Call(`_extraDistr_cpp_rht`, n, nu, sigma) } cpp_dhuber <- function(x, mu, sigma, epsilon, log_prob = FALSE) { .Call(`_extraDistr_cpp_dhuber`, x, mu, sigma, epsilon, log_prob) } cpp_phuber <- function(x, mu, sigma, epsilon, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_phuber`, x, mu, sigma, epsilon, lower_tail, log_prob) } cpp_qhuber <- function(p, mu, sigma, epsilon, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qhuber`, p, mu, sigma, epsilon, lower_tail, log_prob) } cpp_rhuber <- function(n, mu, sigma, epsilon) { .Call(`_extraDistr_cpp_rhuber`, n, mu, sigma, epsilon) } cpp_dinvgamma <- function(x, alpha, beta, log_prob = FALSE) { .Call(`_extraDistr_cpp_dinvgamma`, x, alpha, beta, log_prob) } cpp_pinvgamma <- function(x, alpha, beta, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pinvgamma`, x, alpha, beta, lower_tail, log_prob) } cpp_dkumar <- function(x, a, b, log_prob = FALSE) { .Call(`_extraDistr_cpp_dkumar`, x, a, b, log_prob) } cpp_pkumar <- function(x, a, b, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pkumar`, x, a, b, lower_tail, log_prob) } cpp_qkumar <- function(p, a, b, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qkumar`, p, a, b, lower_tail, log_prob) } cpp_rkumar <- function(n, a, b) { .Call(`_extraDistr_cpp_rkumar`, n, a, b) } cpp_dlaplace <- function(x, mu, sigma, log_prob = FALSE) { .Call(`_extraDistr_cpp_dlaplace`, x, mu, sigma, log_prob) } cpp_plaplace <- function(x, mu, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_plaplace`, x, mu, sigma, lower_tail, log_prob) } cpp_qlaplace <- function(p, mu, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qlaplace`, p, mu, sigma, lower_tail, log_prob) } cpp_rlaplace <- function(n, mu, sigma) { .Call(`_extraDistr_cpp_rlaplace`, n, mu, sigma) } cpp_dlst <- function(x, nu, mu, sigma, log_prob = FALSE) { .Call(`_extraDistr_cpp_dlst`, x, nu, mu, sigma, log_prob) } cpp_plst <- function(x, nu, mu, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_plst`, x, nu, mu, sigma, lower_tail, log_prob) } cpp_qlst <- function(p, nu, mu, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qlst`, p, nu, mu, sigma, lower_tail, log_prob) } cpp_rlst <- function(n, nu, mu, sigma) { .Call(`_extraDistr_cpp_rlst`, n, nu, mu, sigma) } cpp_dlgser <- function(x, theta, log_prob = FALSE) { .Call(`_extraDistr_cpp_dlgser`, x, theta, log_prob) } cpp_plgser <- function(x, theta, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_plgser`, x, theta, lower_tail, log_prob) } cpp_qlgser <- function(p, theta, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qlgser`, p, theta, lower_tail, log_prob) } cpp_rlgser <- function(n, theta) { .Call(`_extraDistr_cpp_rlgser`, n, theta) } cpp_dlomax <- function(x, lambda, kappa, log_prob = FALSE) { .Call(`_extraDistr_cpp_dlomax`, x, lambda, kappa, log_prob) } cpp_plomax <- function(x, lambda, kappa, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_plomax`, x, lambda, kappa, lower_tail, log_prob) } cpp_qlomax <- function(p, lambda, kappa, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qlomax`, p, lambda, kappa, lower_tail, log_prob) } cpp_rlomax <- function(n, lambda, kappa) { .Call(`_extraDistr_cpp_rlomax`, n, lambda, kappa) } cpp_dmixnorm <- function(x, mu, sigma, alpha, log_prob = FALSE) { .Call(`_extraDistr_cpp_dmixnorm`, x, mu, sigma, alpha, log_prob) } cpp_pmixnorm <- function(x, mu, sigma, alpha, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pmixnorm`, x, mu, sigma, alpha, lower_tail, log_prob) } cpp_rmixnorm <- function(n, mu, sigma, alpha) { .Call(`_extraDistr_cpp_rmixnorm`, n, mu, sigma, alpha) } cpp_dmixpois <- function(x, lambda, alpha, log_prob = FALSE) { .Call(`_extraDistr_cpp_dmixpois`, x, lambda, alpha, log_prob) } cpp_pmixpois <- function(x, lambda, alpha, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pmixpois`, x, lambda, alpha, lower_tail, log_prob) } cpp_rmixpois <- function(n, lambda, alpha) { .Call(`_extraDistr_cpp_rmixpois`, n, lambda, alpha) } cpp_dmnom <- function(x, size, prob, log_prob = FALSE) { .Call(`_extraDistr_cpp_dmnom`, x, size, prob, log_prob) } cpp_rmnom <- function(n, size, prob) { .Call(`_extraDistr_cpp_rmnom`, n, size, prob) } cpp_dmvhyper <- function(x, n, k, log_prob = FALSE) { .Call(`_extraDistr_cpp_dmvhyper`, x, n, k, log_prob) } cpp_rmvhyper <- function(nn, n, k) { .Call(`_extraDistr_cpp_rmvhyper`, nn, n, k) } cpp_dnhyper <- function(x, n, m, r, log_prob = FALSE) { .Call(`_extraDistr_cpp_dnhyper`, x, n, m, r, log_prob) } cpp_pnhyper <- function(x, n, m, r, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pnhyper`, x, n, m, r, lower_tail, log_prob) } cpp_qnhyper <- function(p, n, m, r, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qnhyper`, p, n, m, r, lower_tail, log_prob) } cpp_rnhyper <- function(nn, n, m, r) { .Call(`_extraDistr_cpp_rnhyper`, nn, n, m, r) } cpp_dnsbeta <- function(x, alpha, beta, lower, upper, log_prob = FALSE) { .Call(`_extraDistr_cpp_dnsbeta`, x, alpha, beta, lower, upper, log_prob) } cpp_pnsbeta <- function(x, alpha, beta, lower, upper, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pnsbeta`, x, alpha, beta, lower, upper, lower_tail, log_prob) } cpp_qnsbeta <- function(p, alpha, beta, lower, upper, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qnsbeta`, p, alpha, beta, lower, upper, lower_tail, log_prob) } cpp_rnsbeta <- function(n, alpha, beta, lower, upper) { .Call(`_extraDistr_cpp_rnsbeta`, n, alpha, beta, lower, upper) } cpp_dpareto <- function(x, a, b, log_prob = FALSE) { .Call(`_extraDistr_cpp_dpareto`, x, a, b, log_prob) } cpp_ppareto <- function(x, a, b, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_ppareto`, x, a, b, lower_tail, log_prob) } cpp_qpareto <- function(p, a, b, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qpareto`, p, a, b, lower_tail, log_prob) } cpp_rpareto <- function(n, a, b) { .Call(`_extraDistr_cpp_rpareto`, n, a, b) } cpp_dpower <- function(x, alpha, beta, log_prob = FALSE) { .Call(`_extraDistr_cpp_dpower`, x, alpha, beta, log_prob) } cpp_ppower <- function(x, alpha, beta, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_ppower`, x, alpha, beta, lower_tail, log_prob) } cpp_qpower <- function(p, alpha, beta, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qpower`, p, alpha, beta, lower_tail, log_prob) } cpp_rpower <- function(n, alpha, beta) { .Call(`_extraDistr_cpp_rpower`, n, alpha, beta) } cpp_dprop <- function(x, size, mean, prior, log_prob = FALSE) { .Call(`_extraDistr_cpp_dprop`, x, size, mean, prior, log_prob) } cpp_pprop <- function(x, size, mean, prior, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pprop`, x, size, mean, prior, lower_tail, log_prob) } cpp_qprop <- function(p, size, mean, prior, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qprop`, p, size, mean, prior, lower_tail, log_prob) } cpp_rprop <- function(n, size, mean, prior) { .Call(`_extraDistr_cpp_rprop`, n, size, mean, prior) } cpp_rsign <- function(n) { .Call(`_extraDistr_cpp_rsign`, n) } cpp_drayleigh <- function(x, sigma, log_prob = FALSE) { .Call(`_extraDistr_cpp_drayleigh`, x, sigma, log_prob) } cpp_prayleigh <- function(x, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_prayleigh`, x, sigma, lower_tail, log_prob) } cpp_qrayleigh <- function(p, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qrayleigh`, p, sigma, lower_tail, log_prob) } cpp_rrayleigh <- function(n, sigma) { .Call(`_extraDistr_cpp_rrayleigh`, n, sigma) } cpp_dsgomp <- function(x, b, eta, log_prob = FALSE) { .Call(`_extraDistr_cpp_dsgomp`, x, b, eta, log_prob) } cpp_psgomp <- function(x, b, eta, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_psgomp`, x, b, eta, lower_tail, log_prob) } cpp_rsgomp <- function(n, b, eta) { .Call(`_extraDistr_cpp_rsgomp`, n, b, eta) } cpp_dskellam <- function(x, mu1, mu2, log_prob = FALSE) { .Call(`_extraDistr_cpp_dskellam`, x, mu1, mu2, log_prob) } cpp_rskellam <- function(n, mu1, mu2) { .Call(`_extraDistr_cpp_rskellam`, n, mu1, mu2) } cpp_dslash <- function(x, mu, sigma, log_prob = FALSE) { .Call(`_extraDistr_cpp_dslash`, x, mu, sigma, log_prob) } cpp_pslash <- function(x, mu, sigma, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pslash`, x, mu, sigma, lower_tail, log_prob) } cpp_rslash <- function(n, mu, sigma) { .Call(`_extraDistr_cpp_rslash`, n, mu, sigma) } cpp_dtriang <- function(x, a, b, c, log_prob = FALSE) { .Call(`_extraDistr_cpp_dtriang`, x, a, b, c, log_prob) } cpp_ptriang <- function(x, a, b, c, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_ptriang`, x, a, b, c, lower_tail, log_prob) } cpp_qtriang <- function(p, a, b, c, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qtriang`, p, a, b, c, lower_tail, log_prob) } cpp_rtriang <- function(n, a, b, c) { .Call(`_extraDistr_cpp_rtriang`, n, a, b, c) } cpp_dtbinom <- function(x, size, prob, lower, upper, log_prob = FALSE) { .Call(`_extraDistr_cpp_dtbinom`, x, size, prob, lower, upper, log_prob) } cpp_ptbinom <- function(x, size, prob, lower, upper, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_ptbinom`, x, size, prob, lower, upper, lower_tail, log_prob) } cpp_qtbinom <- function(p, size, prob, lower, upper, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qtbinom`, p, size, prob, lower, upper, lower_tail, log_prob) } cpp_rtbinom <- function(n, size, prob, lower, upper) { .Call(`_extraDistr_cpp_rtbinom`, n, size, prob, lower, upper) } cpp_dtnorm <- function(x, mu, sigma, lower, upper, log_prob = FALSE) { .Call(`_extraDistr_cpp_dtnorm`, x, mu, sigma, lower, upper, log_prob) } cpp_ptnorm <- function(x, mu, sigma, lower, upper, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_ptnorm`, x, mu, sigma, lower, upper, lower_tail, log_prob) } cpp_qtnorm <- function(p, mu, sigma, lower, upper, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qtnorm`, p, mu, sigma, lower, upper, lower_tail, log_prob) } cpp_rtnorm <- function(n, mu, sigma, lower, upper) { .Call(`_extraDistr_cpp_rtnorm`, n, mu, sigma, lower, upper) } cpp_dtpois <- function(x, lambda, lower, upper, log_prob = FALSE) { .Call(`_extraDistr_cpp_dtpois`, x, lambda, lower, upper, log_prob) } cpp_ptpois <- function(x, lambda, lower, upper, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_ptpois`, x, lambda, lower, upper, lower_tail, log_prob) } cpp_qtpois <- function(p, lambda, lower, upper, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qtpois`, p, lambda, lower, upper, lower_tail, log_prob) } cpp_rtpois <- function(n, lambda, lower, upper) { .Call(`_extraDistr_cpp_rtpois`, n, lambda, lower, upper) } cpp_qtlambda <- function(p, lambda, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qtlambda`, p, lambda, lower_tail, log_prob) } cpp_rtlambda <- function(n, lambda) { .Call(`_extraDistr_cpp_rtlambda`, n, lambda) } cpp_dwald <- function(x, mu, lambda, log_prob = FALSE) { .Call(`_extraDistr_cpp_dwald`, x, mu, lambda, log_prob) } cpp_pwald <- function(x, mu, lambda, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pwald`, x, mu, lambda, lower_tail, log_prob) } cpp_rwald <- function(n, mu, lambda) { .Call(`_extraDistr_cpp_rwald`, n, mu, lambda) } cpp_dzib <- function(x, size, prob, pi, log_prob = FALSE) { .Call(`_extraDistr_cpp_dzib`, x, size, prob, pi, log_prob) } cpp_pzib <- function(x, size, prob, pi, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pzib`, x, size, prob, pi, lower_tail, log_prob) } cpp_qzib <- function(p, size, prob, pi, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qzib`, p, size, prob, pi, lower_tail, log_prob) } cpp_rzib <- function(n, size, prob, pi) { .Call(`_extraDistr_cpp_rzib`, n, size, prob, pi) } cpp_dzinb <- function(x, size, prob, pi, log_prob = FALSE) { .Call(`_extraDistr_cpp_dzinb`, x, size, prob, pi, log_prob) } cpp_pzinb <- function(x, size, prob, pi, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pzinb`, x, size, prob, pi, lower_tail, log_prob) } cpp_qzinb <- function(p, size, prob, pi, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qzinb`, p, size, prob, pi, lower_tail, log_prob) } cpp_rzinb <- function(n, size, prob, pi) { .Call(`_extraDistr_cpp_rzinb`, n, size, prob, pi) } cpp_dzip <- function(x, lambda, pi, log_prob = FALSE) { .Call(`_extraDistr_cpp_dzip`, x, lambda, pi, log_prob) } cpp_pzip <- function(x, lambda, pi, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_pzip`, x, lambda, pi, lower_tail, log_prob) } cpp_qzip <- function(p, lambda, pi, lower_tail = TRUE, log_prob = FALSE) { .Call(`_extraDistr_cpp_qzip`, p, lambda, pi, lower_tail, log_prob) } cpp_rzip <- function(n, lambda, pi) { .Call(`_extraDistr_cpp_rzip`, n, lambda, pi) } # Register entry points for exported C++ functions methods::setLoadAction(function(ns) { .Call(`_extraDistr_RcppExport_registerCCallable`) }) extraDistr/R/proportion-distribution.R0000755000176200001440000001041314475546572017704 0ustar liggesusers #' Beta distribution of proportions #' #' Probability mass function, distribution function and random generation #' for the reparametrized beta distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param size non-negative real number; precision or number of binomial trials. #' @param mean mean proportion or probability of success on each trial; #' \code{0 < mean < 1}. #' @param prior (see below) with \code{prior = 0} (default) #' the distribution corresponds to re-parametrized beta #' distribution used in beta regression. This parameter needs #' to be non-negative. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Beta can be understood as a distribution of \eqn{x = k/\phi} proportions in #' \eqn{\phi} trials where the average proportion is denoted as \eqn{\mu}, #' so it's parameters become \eqn{\alpha = \phi\mu} and #' \eqn{\beta = \phi(1-\mu)} and it's density function becomes #' #' \deqn{ #' f(x) = \frac{x^{\phi\mu+\pi-1} (1-x)^{\phi(1-\mu)+\pi-1}}{\mathrm{B}(\phi\mu+\pi, \phi(1-\mu)+\pi)} #' }{ #' f(x) = (x^(\phi\mu+\pi-1) * (1-x)^(\phi(1-\mu)+\pi-1))/B(\phi\mu+\pi, \phi(1-\mu)+\pi) #' } #' #' where \eqn{\pi} is a \emph{prior} parameter, so the distribution is a #' \emph{posterior} distribution after observing \eqn{\phi\mu} successes and #' \eqn{\phi(1-\mu)} failures in \eqn{\phi} trials with binomial likelihood #' and symmetric \eqn{\mathrm{Beta}(\pi, \pi)}{Beta(\pi, \pi)} prior for #' probability of success. Parameter value \eqn{\pi = 1} corresponds to #' uniform prior; \eqn{\pi = 1/2} corresponds to Jeffreys prior; \eqn{\pi = 0} #' corresponds to "uninformative" Haldane prior, this is also the re-parametrized #' distribution used in beta regression. With \eqn{\pi = 0} the distribution #' can be understood as a continuous analog to binomial distribution dealing #' with proportions rather then counts. Alternatively \eqn{\phi} may be #' understood as precision parameter (as in beta regression). #' #' Notice that in pre-1.8.4 versions of this package, \code{prior} was not settable #' and by default fixed to one, instead of zero. To obtain the same results as in #' the previous versions, use \code{prior = 1} in each of the functions. #' #' @seealso #' \code{\link{beta}}, \code{\link{binomial}} #' #' @references #' Ferrari, S., & Cribari-Neto, F. (2004). Beta regression for modelling rates and proportions. #' Journal of Applied Statistics, 31(7), 799-815. #' #' @references #' Smithson, M., & Verkuilen, J. (2006). A better lemon squeezer? Maximum-likelihood regression #' with beta-distributed dependent variables. #' Psychological Methods, 11(1), 54-71. #' #' @examples #' #' x <- rprop(1e5, 100, 0.33) #' hist(x, 100, freq = FALSE) #' curve(dprop(x, 100, 0.33), 0, 1, col = "red", add = TRUE) #' hist(pprop(x, 100, 0.33)) #' plot(ecdf(x)) #' curve(pprop(x, 100, 0.33), 0, 1, col = "red", lwd = 2, add = TRUE) #' #' n <- 500 #' p <- 0.23 #' k <- rbinom(1e5, n, p) #' hist(k/n, freq = FALSE, 100) #' curve(dprop(x, n, p), 0, 1, col = "red", add = TRUE, n = 500) #' #' @name PropBeta #' @aliases PropBeta #' @aliases dprop #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dprop <- function(x, size, mean, prior = 0, log = FALSE) { cpp_dprop(x, size, mean, prior, log[1L]) } #' @rdname PropBeta #' @export pprop <- function(q, size, mean, prior = 0, lower.tail = TRUE, log.p = FALSE) { cpp_pprop(q, size, mean, prior, lower.tail[1L], log.p[1L]) } #' @rdname PropBeta #' @export qprop <- function(p, size, mean, prior = 0, lower.tail = TRUE, log.p = FALSE) { cpp_qprop(p, size, mean, prior, lower.tail[1L], log.p[1L]) } #' @rdname PropBeta #' @export rprop <- function(n, size, mean, prior = 0) { if (length(n) > 1) n <- length(n) cpp_rprop(n, size, mean, prior) } extraDistr/R/beta-negative-binomial-distribution.R0000755000176200001440000000665314475546572022007 0ustar liggesusers #' Beta-negative binomial distribution #' #' Probability mass function and random generation #' for the beta-negative binomial distribution. #' #' @param x,q vector of quantiles. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param alpha,beta non-negative parameters of the beta distribution. #' @param size number of trials (zero or more). Must be strictly positive, need not be integer. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' If \eqn{p \sim \mathrm{Beta}(\alpha, \beta)}{p ~ Beta(\alpha, \beta)} and #' \eqn{X \sim \mathrm{NegBinomial}(r, p)}{X ~ NegBinomial(r, p)}, then #' \eqn{X \sim \mathrm{BetaNegBinomial}(r, \alpha, \beta)}{X ~ BetaNegBinomial(r, \alpha, \beta)}. #' #' Probability mass function #' \deqn{ #' f(x) = \frac{\Gamma(r+x)}{x! \,\Gamma(r)} #' \frac{\mathrm{B}(\alpha+r, \beta+x)}{\mathrm{B}(\alpha, \beta)} #' }{ #' f(x) = \Gamma(r+x)/(x! \Gamma(r)) * B(\alpha+r, \beta+x) / B(\alpha, \beta) #' } #' #' Cumulative distribution function is calculated using recursive algorithm that employs the fact that #' \eqn{\Gamma(x) = (x - 1)!} and #' \eqn{ #' \mathrm{B}(x, y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)} #' }{ #' B(x, y) = (\Gamma(x)\Gamma(y))/\Gamma(x+y) #' }. This enables re-writing probability mass function as #' #' \deqn{ #' f(x) = \frac{(r+x-1)!}{x! \, \Gamma(r)} \frac{\frac{(\alpha+r-1)!\,(\beta+x-1)!}{(\alpha+\beta+r+x-1)!}}{\mathrm{B}(\alpha,\beta)} #' }{ #' f(x) = ((r+x-1)!)/(x!*\Gamma(r))*(((\alpha+r-1)!*(\beta+x-1)!)/((\alpha+\beta+r+x-1)!))/B(\alpha,\beta) #' } #' #' what makes recursive updating from \eqn{x} to \eqn{x+1} easy using the properties of factorials #' #' \deqn{ #' f(x+1) = \frac{(r+x-1)!\,(r+x)}{x!\,(x+1) \, \Gamma(r)} \frac{\frac{(\alpha+r-1)!\,(\beta+x-1)!\,(\beta+x)}{(\alpha+\beta+r+x-1)!\,(\alpha+\beta+r+x)}}{\mathrm{B}(\alpha,\beta)} #' }{ #' f(x+1) = ((r+x-1)!*(r+x))/(x!*(x+1)*\Gamma(r))*(((\alpha+r-1)!*(\beta+x-1)!*(\beta+x))/((\alpha+\beta+r+x-1)!*(\alpha+\beta+r+x)))/B(\alpha,\beta) #' } #' #' and let's us efficiently calculate cumulative distribution function as a sum of probability mass functions #' #' \deqn{F(x) = \sum_{k=0}^x f(k)}{F(x) = f(0)+...+f(x)} #' #' #' @seealso \code{\link[stats]{Beta}}, \code{\link[stats]{NegBinomial}} #' #' @examples #' #' x <- rbnbinom(1e5, 1000, 5, 13) #' xx <- 0:1e5 #' hist(x, 100, freq = FALSE) #' lines(xx-0.5, dbnbinom(xx, 1000, 5, 13), col = "red") #' hist(pbnbinom(x, 1000, 5, 13)) #' xx <- seq(0, 1e5, by = 0.1) #' plot(ecdf(x)) #' lines(xx, pbnbinom(xx, 1000, 5, 13), col = "red", lwd = 2) #' #' @name BetaNegBinom #' @aliases BetaNegBinom #' @aliases dbnbinom #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export dbnbinom <- function(x, size, alpha = 1, beta = 1, log = FALSE) { cpp_dbnbinom(x, size, alpha, beta, log[1L]) } #' @rdname BetaNegBinom #' @export pbnbinom <- function(q, size, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE) { cpp_pbnbinom(q, size, alpha, beta, lower.tail[1L], log.p[1L]) } #' @rdname BetaNegBinom #' @export rbnbinom <- function(n, size, alpha = 1, beta = 1) { if (length(n) > 1) n <- length(n) cpp_rbnbinom(n, size, alpha, beta) } extraDistr/R/skellam-distribution.R0000755000176200001440000000344514475546572017130 0ustar liggesusers #' Skellam distribution #' #' Probability mass function and random generation #' for the Skellam distribution. #' #' @param x vector of quantiles. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param mu1,mu2 positive valued parameters. #' @param log logical; if TRUE, probabilities p are given as log(p). #' #' @details #' #' If \eqn{X} and \eqn{Y} follow Poisson distributions with means #' \eqn{\mu_1}{\mu[1]} and \eqn{\mu_2}{\mu[2]}, than \eqn{X-Y} follows #' Skellam distribution parametrized by \eqn{\mu_1}{\mu[1]} and \eqn{\mu_2}{\mu[2]}. #' #' Probability mass function #' \deqn{ #' f(x) = e^{-(\mu_1\!+\!\mu_2)} \left(\frac{\mu_1}{\mu_2}\right)^{k/2}\!\!I_{k}(2\sqrt{\mu_1\mu_2}) #' }{ #' f(x) = exp(-(\mu1+\mu2)) * (\mu1/\mu2)^(x/2) * besselI(2*sqrt(\mu1*\mu2), x) #' } #' #' @references #' Karlis, D., & Ntzoufras, I. (2006). Bayesian analysis of the differences of count data. #' Statistics in medicine, 25(11), 1885-1905. #' #' @references #' Skellam, J.G. (1946). The frequency distribution of the difference between #' two Poisson variates belonging to different populations. #' Journal of the Royal Statistical Society, series A, 109(3), 26. #' #' @examples #' #' x <- rskellam(1e5, 5, 13) #' xx <- -40:40 #' plot(prop.table(table(x)), type = "h") #' lines(xx, dskellam(xx, 5, 13), col = "red") #' #' @name Skellam #' @aliases Skellam #' @aliases dskellam #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export dskellam <- function(x, mu1, mu2, log = FALSE) { cpp_dskellam(x, mu1, mu2, log[1L]) } #' @rdname Skellam #' @export rskellam <- function(n, mu1, mu2) { if (length(n) > 1) n <- length(n) cpp_rskellam(n, mu1, mu2) } extraDistr/R/bivariate-normal-distribution.R0000755000176200001440000000472414475546572020735 0ustar liggesusers #' Bivariate normal distribution #' #' Density, distribution function and random generation #' for the bivariate normal distribution. #' #' @param x,y vectors of quantiles; alternatively x may be a two-column #' matrix (or data.frame) and y may be omitted. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param mean1,mean2 vectors of means. #' @param sd1,sd2 vectors of standard deviations. #' @param cor vector of correlations (\code{-1 < cor < 1}). #' @param log logical; if TRUE, probabilities p are given as log(p). #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \frac{1}{2\pi\sqrt{1-\rho^2}\sigma_1\sigma_2} #' \exp\left\{-\frac{1}{2(1-\rho^2)} \left[\left(\frac{x_1 - \mu_1}{\sigma_1}\right)^2 - #' 2\rho \left(\frac{x_1 - \mu_1}{\sigma_1}\right) \left(\frac{x_2 - \mu_2}{\sigma_2}\right) + #' \left(\frac{x_2 - \mu_2}{\sigma_2}\right)^2\right]\right\} #' }{ #' f(x) = 1/(2*\pi*sqrt(1-\rho^2)*\sigma1*\sigma2) * exp(-(1/(2*(1-\rho^2)* #' (((x1-\mu1)/\sigma1)^2 - 2*\rho*((x1-\mu1)/\sigma2)*((x2-\mu2)/\sigma2) * #' ((x2-\mu2)/\sigma2)^2)))) #' } #' #' @references #' Krishnamoorthy, K. (2006). Handbook of Statistical Distributions #' with Applications. Chapman & Hall/CRC #' #' @references #' Mukhopadhyay, N. (2000). Probability and statistical inference. #' Chapman & Hall/CRC #' #' @examples #' #' y <- x <- seq(-4, 4, by = 0.25) #' z <- outer(x, y, function(x, y) dbvnorm(x, y, cor = -0.75)) #' persp(x, y, z) #' #' y <- x <- seq(-4, 4, by = 0.25) #' z <- outer(x, y, function(x, y) dbvnorm(x, y, cor = -0.25)) #' persp(x, y, z) #' #' @seealso \code{\link[stats]{Normal}} #' #' @name BivNormal #' @aliases BivNormal #' @aliases dbvnorm #' #' @keywords distribution #' @concept Multivariate #' @concept Continuous #' #' @export dbvnorm <- function(x, y = NULL, mean1 = 0, mean2 = mean1, sd1 = 1, sd2 = sd1, cor = 0, log = FALSE) { if (is.null(y)) { if ((is.matrix(x) || is.data.frame(x)) && ncol(x) == 2) { y <- x[, 2] x <- x[, 1] } else { stop("y is not provided while x is not a two-column matrix") } } cpp_dbnorm(x, y, mean1, mean2, sd1, sd2, cor, log[1L]) } #' @rdname BivNormal #' @export rbvnorm <- function(n, mean1 = 0, mean2 = mean1, sd1 = 1, sd2 = sd1, cor = 0) { if (length(n) > 1) n <- length(n) cpp_rbnorm(n, mean1, mean2, sd1, sd2, cor) } extraDistr/R/gamma-poisson-distribution.R0000755000176200001440000000662714475546572020257 0ustar liggesusers #' Gamma-Poisson distribution #' #' Probability mass function and random generation #' for the gamma-Poisson distribution. #' #' @param x,q vector of quantiles. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param rate an alternative way to specify the scale. #' @param shape,scale shape and scale parameters. Must be positive, #' scale strictly. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' Gamma-Poisson distribution arises as a continuous mixture of #' Poisson distributions, where the mixing distribution #' of the Poisson rate \eqn{\lambda} is a gamma distribution. #' When \eqn{X \sim \mathrm{Poisson}(\lambda)}{X ~ Poisson(\lambda)} #' and \eqn{\lambda \sim \mathrm{Gamma}(\alpha, \beta)}{\lambda ~ Gamma(\alpha, \beta)}, then \eqn{X \sim \mathrm{GammaPoisson}(\alpha, \beta)}{X ~ Gamma-Poisson(\alpha, \beta)}. #' #' Probability mass function #' \deqn{ #' f(x) = \frac{\Gamma(\alpha+x)}{x! \, \Gamma(\alpha)} \left(\frac{\beta}{1+\beta}\right)^x \left(1-\frac{\beta}{1+\beta}\right)^\alpha #' }{ #' f(x) = \Gamma(\alpha+x) / (x!*\Gamma(\alpha)) * (\beta/(1+\beta))^x * (1-\beta/(1+\beta))^\alpha #' } #' #' Cumulative distribution function is calculated using recursive algorithm that employs the fact that #' \eqn{\Gamma(x) = (x - 1)!}. This enables re-writing probability mass function as #' #' \deqn{ #' f(x) = \frac{(\alpha+x-1)!}{x! \, \Gamma(\alpha)} \left( \frac{\beta}{1+\beta} \right)^x \left( 1- \frac{\beta}{1+\beta} \right)^\alpha #' }{ #' f(x) = ((\alpha+x-1)!)/(x!*\Gamma(\alpha))*(\beta/(1+\beta))^x*(1-\beta/(1+\beta))^\alpha #' } #' #' what makes recursive updating from \eqn{x} to \eqn{x+1} easy using the properties of factorials #' #' \deqn{ #' f(x+1) = \frac{(\alpha+x-1)! \, (\alpha+x)}{x! \,(x+1) \, \Gamma(\alpha)} \left( \frac{\beta}{1+\beta} \right)^x \left( \frac{\beta}{1+\beta} \right) \left( 1- \frac{\beta}{1+\beta} \right)^\alpha #' }{ #' f(x+1) = ((\alpha+x-1)!*(\alpha+x))/(x!*(x+1)*\Gamma(\alpha))*(\beta/(1+\beta))^x*(\beta/(1+\beta))*(1-\beta/(1+\beta))^\alpha #' } #' #' and let's us efficiently calculate cumulative distribution function as a sum of probability mass functions #' #' \deqn{F(x) = \sum_{k=0}^x f(k)}{F(x) = f(0)+...+f(x)} #' #' #' @seealso \code{\link[stats]{Gamma}}, \code{\link[stats]{Poisson}} #' #' @examples #' #' x <- rgpois(1e5, 7, 0.002) #' xx <- seq(0, 12000, by = 1) #' hist(x, 100, freq = FALSE) #' lines(xx, dgpois(xx, 7, 0.002), col = "red") #' hist(pgpois(x, 7, 0.002)) #' xx <- seq(0, 12000, by = 0.1) #' plot(ecdf(x)) #' lines(xx, pgpois(xx, 7, 0.002), col = "red", lwd = 2) #' #' @name GammaPoiss #' @aliases GammaPoiss #' @aliases dgpois #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export dgpois <- function(x, shape, rate, scale = 1/rate, log = FALSE) { cpp_dgpois(x, shape, scale, log[1L]) } #' @rdname GammaPoiss #' @export pgpois <- function(q, shape, rate, scale = 1/rate, lower.tail = TRUE, log.p = FALSE) { cpp_pgpois(q, shape, scale, lower.tail[1L], log.p[1L]) } #' @rdname GammaPoiss #' @export rgpois <- function(n, shape, rate, scale = 1/rate) { cpp_rgpois(n, shape, scale) } extraDistr/R/huber-distribution.R0000755000176200001440000000513114475546572016577 0ustar liggesusers #' "Huber density" distribution #' #' Density, distribution function, quantile function and random generation #' for the "Huber density" distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param mu,sigma,epsilon location, and scale, and shape parameters. #' Scale and shape must be positive. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Huber density is connected to Huber loss and can be defined as: #' #' \deqn{ #' f(x) = \frac{1}{2 \sqrt{2\pi} \left( \Phi(k) + \phi(k)/k - \frac{1}{2} \right)} e^{-\rho_k(x)} #' }{ #' f(x) = 1/(2 * sqrt(2\pi) * (\Phi(k) + \phi(k)/k - 1/2)) * exp(-\rho(x, k)) #' } #' #' where #' #' \deqn{ #' \rho_k(x) = #' \left\{\begin{array}{ll} #' \frac{1}{2} x^2 & |x|\le k \\ #' k|x|- \frac{1}{2} k^2 & |x|>k #' \end{array}\right. #' }{ #' \rho(x, k) = [if abs(x) <= k:] (x^2)/2 [else:] k*abs(x) - (k^2)/2 #' } #' #' #' @references #' Huber, P.J. (1964). Robust Estimation of a Location Parameter. #' Annals of Statistics, 53(1), 73-101. #' #' @references #' Huber, P.J. (1981). Robust Statistics. Wiley. #' #' @references #' Schumann, D. (2009). Robust Variable Selection. ProQuest. #' #' @examples #' #' x <- rhuber(1e5, 5, 2, 3) #' hist(x, 100, freq = FALSE) #' curve(dhuber(x, 5, 2, 3), -20, 20, col = "red", add = TRUE, n = 5000) #' hist(phuber(x, 5, 2, 3)) #' plot(ecdf(x)) #' curve(phuber(x, 5, 2, 3), -20, 20, col = "red", lwd = 2, add = TRUE) #' #' @name Huber #' @aliases Huber #' @aliases dhuber #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dhuber <- function(x, mu = 0, sigma = 1, epsilon = 1.345, log = FALSE) { cpp_dhuber(x, mu, sigma, epsilon, log[1L]) } #' @rdname Huber #' @export phuber <- function(q, mu = 0, sigma = 1, epsilon = 1.345, lower.tail = TRUE, log.p = FALSE) { cpp_phuber(q, mu, sigma, epsilon, lower.tail[1L], log.p[1L]) } #' @rdname Huber #' @export qhuber <- function(p, mu = 0, sigma = 1, epsilon = 1.345, lower.tail = TRUE, log.p = FALSE) { cpp_qhuber(p, mu, sigma, epsilon, lower.tail[1L], log.p[1L]) } #' @rdname Huber #' @export rhuber <- function(n, mu = 0, sigma = 1, epsilon = 1.345) { if (length(n) > 1) n <- length(n) cpp_rhuber(n, mu, sigma, epsilon) } extraDistr/R/discrete-weibull-distribution.R0000755000176200001440000000565414475546572020747 0ustar liggesusers #' Discrete Weibull distribution (type I) #' #' Density, distribution function, quantile function and random generation #' for the discrete Weibull (type I) distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param shape1,shape2 parameters (named q, \eqn{\beta}). Values of \code{shape2} #' need to be positive and \code{0 < shape1 < 1}. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability mass function #' \deqn{ #' f(x) = q^{x^\beta} - q^{(x+1)^\beta} #' }{ #' f(x) = q^x^\beta - q^(x+1)^\beta #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = 1-q^{(x+1)^\beta} #' }{ #' F(x) = 1-q^(x+1)^\beta #' } #' #' Quantile function #' \deqn{ #' F^{-1}(p) = \left \lceil{\left(\frac{\log(1-p)}{\log(q)}\right)^{1/\beta} - 1}\right \rceil #' }{ #' F^-1(p) = ceiling((log(1-p)/log(q))^(1/\beta) - 1) #' } #' #' @references #' Nakagawa, T. and Osaki, S. (1975). The Discrete Weibull Distribution. #' IEEE Transactions on Reliability, R-24, 300-301. #' #' @references #' Kulasekera, K.B. (1994). #' Approximate MLE's of the parameters of a discrete Weibull distribution #' with type I censored data. #' Microelectronics Reliability, 34(7), 1185-1188. #' #' @references #' Khan, M.A., Khalique, A. and Abouammoh, A.M. (1989). #' On estimating parameters in a discrete Weibull distribution. #' IEEE Transactions on Reliability, 38(3), 348-350. #' #' @seealso \code{\link[stats]{Weibull}} #' #' @examples #' #' x <- rdweibull(1e5, 0.32, 1) #' xx <- seq(-2, 100, by = 1) #' plot(prop.table(table(x)), type = "h") #' lines(xx, ddweibull(xx, .32, 1), col = "red") #' #' # Notice: distribution of F(X) is far from uniform: #' hist(pdweibull(x, .32, 1), 50) #' #' plot(ecdf(x)) #' lines(xx, pdweibull(xx, .32, 1), col = "red", lwd = 2, type = "s") #' #' @name DiscreteWeibull #' @aliases DiscreteWeibull #' @aliases ddweibull #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export ddweibull <- function(x, shape1, shape2, log = FALSE) { cpp_ddweibull(x, shape1, shape2, log[1L]) } #' @rdname DiscreteWeibull #' @export pdweibull <- function(q, shape1, shape2, lower.tail = TRUE, log.p = FALSE) { cpp_pdweibull(q, shape1, shape2, lower.tail[1L], log.p[1L]) } #' @rdname DiscreteWeibull #' @export qdweibull <- function(p, shape1, shape2, lower.tail = TRUE, log.p = FALSE) { cpp_qdweibull(p, shape1, shape2, lower.tail[1L], log.p[1L]) } #' @rdname DiscreteWeibull #' @export rdweibull <- function(n, shape1, shape2) { if (length(n) > 1) n <- length(n) cpp_rdweibull(n, shape1, shape2) } extraDistr/R/discrete-gamma-distribution.R0000755000176200001440000000464014475546572020360 0ustar liggesusers #' Discrete gamma distribution #' #' Probability mass function, distribution function and random generation #' for discrete gamma distribution. #' #' @param x,q vector of quantiles. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param rate an alternative way to specify the scale. #' @param shape,scale shape and scale parameters. Must be positive, scale strictly. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability mass function of discrete gamma distribution \eqn{f_Y(y)}{f} #' is defined by discretization of continuous gamma distribution #' \eqn{f_Y(y) = S_X(y) - S_X(y+1)}{f(y) = S(x) - S(x+1)} #' where \eqn{S_X}{S} is a survival function of continuous gamma distribution. #' #' @references #' Chakraborty, S. and Chakravarty, D. (2012). #' Discrete Gamma distributions: Properties and parameter estimations. #' Communications in Statistics-Theory and Methods, 41(18), 3301-3324. #' #' @seealso \code{\link[stats]{GammaDist}}, \code{\link{DiscreteNormal}} #' #' @examples #' #' x <- rdgamma(1e5, 9, 1) #' xx <- 0:50 #' plot(prop.table(table(x))) #' lines(xx, ddgamma(xx, 9, 1), col = "red") #' hist(pdgamma(x, 9, 1)) #' plot(ecdf(x)) #' xx <- seq(0, 50, 0.1) #' lines(xx, pdgamma(xx, 9, 1), col = "red", lwd = 2, type = "s") #' #' @name DiscreteGamma #' @aliases DiscreteGamma #' @aliases ddgamma #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export ddgamma <- function(x, shape, rate = 1, scale = 1/rate, log = FALSE) { if (!missing(rate) && !missing(scale)) { if (abs(rate * scale - 1) < 1e-15) warning("specify 'rate' or 'scale' but not both") else stop("specify 'rate' or 'scale' but not both") } cpp_ddgamma(x, shape, scale, log[1L]) } #' @rdname DiscreteGamma #' @export pdgamma <- function(q, shape, rate = 1, scale = 1/rate, lower.tail = TRUE, log.p = FALSE) { pgamma(floor(q)+1, shape, scale = scale, lower.tail = lower.tail[1L], log.p = log.p[1L]) } #' @rdname DiscreteGamma #' @export rdgamma <- function(n, shape, rate = 1, scale = 1/rate) { floor(rgamma(n, shape, scale = scale)) } extraDistr/R/discrete-uniform-distribution.R0000755000176200001440000000351714475546572020757 0ustar liggesusers #' Discrete uniform distribution #' #' Probability mass function, distribution function, quantile function and random generation #' for the discrete uniform distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param min,max lower and upper limits of the distribution. Must be finite. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' If \code{min == max}, then discrete uniform distribution is a degenerate distribution. #' #' @examples #' #' x <- rdunif(1e5, 1, 10) #' xx <- -1:11 #' plot(prop.table(table(x)), type = "h") #' lines(xx, ddunif(xx, 1, 10), col = "red") #' hist(pdunif(x, 1, 10)) #' xx <- seq(-1, 11, by = 0.01) #' plot(ecdf(x)) #' lines(xx, pdunif(xx, 1, 10), col = "red") #' #' @name DiscreteUniform #' @aliases DiscreteUniform #' @aliases ddunif #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export ddunif <- function(x, min, max, log = FALSE) { cpp_ddunif(x, min, max, log[1L]) } #' @rdname DiscreteUniform #' @export pdunif <- function(q, min, max, lower.tail = TRUE, log.p = FALSE) { cpp_pdunif(q, min, max, lower.tail[1L], log.p[1L]) } #' @rdname DiscreteUniform #' @export qdunif <- function(p, min, max, lower.tail = TRUE, log.p = FALSE) { cpp_qdunif(p, min, max, lower.tail[1L], log.p[1L]) } #' @rdname DiscreteUniform #' @export rdunif <- function(n, min, max) { if (length(n) > 1) n <- length(n) cpp_rdunif(n, min, max) } extraDistr/R/negative-hypergeometric-distribution.R0000755000176200001440000000773714524411730022314 0ustar liggesusers#' Negative hypergeometric distribution #' #' Probability mass function, distribution function, quantile function and random generation #' for the negative hypergeometric distribution. #' #' @param x,q vector of quantiles representing the number of balls drawn without #' replacement from an urn which contains both black and white balls. #' @param p vector of probabilities. #' @param nn number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param m the number of white balls in the urn. #' @param n the number of black balls in the urn. #' @param r the number of white balls that needs to be drawn for the sampling #' to be stopped. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' #' @details #' #' Negative hypergeometric distribution describes number of balls \eqn{x} observed #' until drawing without replacement to obtain \eqn{r} white balls #' from the urn containing \eqn{m} white balls and \eqn{n} black balls, #' and is defined as #' #' \deqn{ #' f(x) = \frac{{x-1 \choose r-1}{m+n-x \choose m-r}}{{m+n \choose n}} #' }{ #' f(x) = choose(x-1, r-1)*choose(m+n-x, m-r)/choose(m+n, n) #' } #' #' The algorithm used for calculating probability mass function, #' cumulative distribution function and quantile function is based #' on Fortran program NHYPERG created by Berry and Mielke (1996, 1998). #' Random generation is done by inverse transform sampling. #' #' @references #' Berry, K. J., & Mielke, P. W. (1998). #' The negative hypergeometric probability distribution: #' Sampling without replacement from a finite population. #' Perceptual and motor skills, 86(1), 207-210. #' \url{https://journals.sagepub.com/doi/10.2466/pms.1998.86.1.207} #' #' @references #' Berry, K. J., & Mielke, P. W. (1996). #' Exact confidence limits for population proportions based on the negative #' hypergeometric probability distribution. #' Perceptual and motor skills, 83(3 suppl), 1216-1218. #' \url{https://journals.sagepub.com/doi/10.2466/pms.1996.83.3f.1216} #' #' @references #' Schuster, E. F., & Sype, W. R. (1987). #' On the negative hypergeometric distribution. #' International Journal of Mathematical Education in Science and Technology, 18(3), 453-459. #' #' @references #' Chae, K. C. (1993). #' Presenting the negative hypergeometric distribution to the introductory statistics courses. #' International Journal of Mathematical Education in Science and Technology, 24(4), 523-526. #' #' @references #' Jones, S.N. (2013). A Gaming Application of the Negative Hypergeometric Distribution. #' UNLV Theses, Dissertations, Professional Papers, and Capstones. Paper 1846. #' \url{https://digitalscholarship.unlv.edu/cgi/viewcontent.cgi?referer=&httpsredir=1&article=2847&context=thesesdissertations} #' #' @seealso \code{\link[stats]{Hypergeometric}} #' #' @examples #' #' x <- rnhyper(1e5, 60, 35, 15) #' xx <- 15:95 #' plot(prop.table(table(x))) #' lines(xx, dnhyper(xx, 60, 35, 15), col = "red") #' hist(pnhyper(x, 60, 35, 15)) #' #' xx <- seq(0, 100, by = 0.01) #' plot(ecdf(x)) #' lines(xx, pnhyper(xx, 60, 35, 15), col = "red", lwd = 2) #' #' @name NegHyper #' @aliases NegHyper #' @aliases dnhyper #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export dnhyper <- function(x, n, m, r, log = FALSE) { cpp_dnhyper(x, n, m, r, log[1L]) } #' @rdname NegHyper #' @export pnhyper <- function(q, n, m, r, lower.tail = TRUE, log.p = FALSE) { cpp_pnhyper(q, n, m, r, lower.tail[1L], log.p[1L]) } #' @rdname NegHyper #' @export qnhyper <- function(p, n, m, r, lower.tail = TRUE, log.p = FALSE) { cpp_qnhyper(p, n, m, r, lower.tail[1L], log.p[1L]) } #' @rdname NegHyper #' @export rnhyper <- function(nn, n, m, r) { if (length(nn) > 1) { nn <- length(nn) } cpp_rnhyper(nn, n, m, r) } extraDistr/R/beta-prime-distribution.R0000755000176200001440000000473714475546572017532 0ustar liggesusers #' Beta prime distribution #' #' Density, distribution function, quantile function and random generation #' for the beta prime distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param shape1,shape2 non-negative parameters. #' @param scale positive valued scale parameter. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' If \eqn{X \sim \mathrm{Beta}(\alpha, \beta)}{X ~ Beta(\alpha, \beta)}, then #' \eqn{\frac{X}{1-X} \sim \mathrm{BetaPrime}(\alpha, \beta)}{X/(1-X) ~ BetaPrime(\alpha, \beta)}. #' #' Probability density function #' #' \deqn{ #' f(x) = \frac{(x/\sigma)^{\alpha-1} (1+x/\sigma)^{-\alpha -\beta}}{\mathrm{B}(\alpha,\beta)\sigma} #' }{ #' f(x) = ((x/\sigma)^(\alpha-1) * (1 + x/\sigma)^(-\alpha-\beta)) / (B(\alpha,\beta) * \sigma) #' } #' #' Cumulative distribution function #' #' \deqn{ #' F(x) = I_{\frac{x/\sigma}{1+x/\sigma}}(\alpha, \beta) #' }{ #' F(x) = pbeta((x/\sigma)/(1+(x/\sigma)), \alpha, \beta) #' } #' #' @seealso \code{\link[stats]{Beta}} #' #' @examples #' #' x <- rbetapr(1e5, 5, 3, 2) #' hist(x, 350, freq = FALSE, xlim = c(0, 100)) #' curve(dbetapr(x, 5, 3, 2), 0, 100, col = "red", add = TRUE, n = 500) #' hist(pbetapr(x, 5, 3, 2)) #' plot(ecdf(x), xlim = c(0, 100)) #' curve(pbetapr(x, 5, 3, 2), 0, 100, col = "red", add = TRUE, n = 500) #' #' @name BetaPrime #' @aliases BetaPrime #' @aliases dbetapr #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dbetapr <- function(x, shape1, shape2, scale = 1, log = FALSE) { cpp_dbetapr(x, shape1, shape2, scale, log[1L]) } #' @rdname BetaPrime #' @export pbetapr <- function(q, shape1, shape2, scale = 1, lower.tail = TRUE, log.p = FALSE) { cpp_pbetapr(q, shape1, shape2, scale, lower.tail[1L], log.p[1L]) } #' @rdname BetaPrime #' @export qbetapr <- function(p, shape1, shape2, scale = 1, lower.tail = TRUE, log.p = FALSE) { cpp_qbetapr(p, shape1, shape2, scale, lower.tail[1L], log.p[1L]) } #' @rdname BetaPrime #' @export rbetapr <- function(n, shape1, shape2, scale = 1) { if (length(n) > 1) n <- length(n) cpp_rbetapr(n, shape1, shape2, scale) } extraDistr/R/multinomial-distribution.R0000755000176200001440000000362414475546572020031 0ustar liggesusers #' Multinomial distribution #' #' Probability mass function and random generation #' for the multinomial distribution. #' #' @param x \eqn{k}-column matrix of quantiles. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param size numeric vector; number of trials (zero or more). #' @param prob \eqn{k}-column numeric matrix; probability of success on each trial. #' @param log logical; if TRUE, probabilities p are given as log(p). #' #' @details #' #' Probability mass function #' \deqn{ #' f(x) = \frac{n!}{\prod_{i=1}^k x_i} \prod_{i=1}^k p_i^{x_i} #' }{ #' f(x) = n!/prod(x[i]!) * prod(p[i]^x[i]) #' } #' #' @references #' Gentle, J.E. (2006). Random number generation and Monte Carlo methods. Springer. #' #' @seealso \code{\link[stats]{Binomial}}, \code{\link[stats]{Multinomial}} #' #' @examples #' #' # Generating 10 random draws from multinomial distribution #' # parametrized using a vector #' #' (x <- rmnom(10, 3, c(1/3, 1/3, 1/3))) #' #' # Results are consistent with dmultinom() from stats: #' #' all.equal(dmultinom(x[1,], 3, c(1/3, 1/3, 1/3)), #' dmnom(x[1, , drop = FALSE], 3, c(1/3, 1/3, 1/3))) #' #' @name Multinomial #' @aliases Multinomial #' @aliases dmnom #' #' @keywords distribution #' @concept Multivariate #' @concept Discrete #' #' @export dmnom <- function(x, size, prob, log = FALSE) { if (is.vector(prob)) prob <- matrix(prob, nrow = 1) else if (!is.matrix(prob)) prob <- as.matrix(prob) if (is.vector(x)) x <- matrix(x, nrow = 1) else if (!is.matrix(x)) x <- as.matrix(x) cpp_dmnom(x, size, prob, log[1L]) } #' @rdname Multinomial #' @export rmnom <- function(n, size, prob) { if (length(n) > 1) n <- length(n) if (is.vector(prob)) prob <- matrix(prob, nrow = 1) else if (!is.matrix(prob)) prob <- as.matrix(prob) cpp_rmnom(n, size, prob) } extraDistr/R/tukey-lambda-distribution.R0000755000176200001440000000557214475546572020062 0ustar liggesusers #' Tukey lambda distribution #' #' Quantile function, and random generation for the Tukey lambda #' distribution. #' #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param lambda shape parameter. #' @param log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Tukey lambda distribution is a continuous probability distribution defined in terms #' of its quantile function. It is typically used to identify other distributions. #' #' Quantile function: #' #' \deqn{F^{-1}(p) = \left\{\begin{array}{ll} #' \frac{1}{\lambda} [p^\lambda - (1-p)^\lambda] & \lambda \ne 0 \\ #' \log(\frac{p}{1-p}) & \lambda = 0 #' \end{array}\right. #' }{ #' F^-1(p) = [if \lambda != 0:] (p^\lambda - (1-p)^\lambda)/\lambda #' [if \lambda = 0:] log(p/(1-p)) #' } #' #' @references #' #' Joiner, B.L., & Rosenblatt, J.R. (1971). #' Some properties of the range in samples from Tukey's symmetric lambda distributions. #' Journal of the American Statistical Association, 66(334), 394-399. #' #' @references #' #' Hastings Jr, C., Mosteller, F., Tukey, J.W., & Winsor, C.P. (1947). #' Low moments for small samples: a comparative study of order statistics. #' The Annals of Mathematical Statistics, 413-426. #' #' @examples #' #' pp = seq(0, 1, by = 0.001) #' partmp <- par(mfrow = c(2,3)) #' plot(qtlambda(pp, -1), pp, type = "l", main = "lambda = -1 (Cauchy)") #' plot(qtlambda(pp, 0), pp, type = "l", main = "lambda = 0 (logistic)") #' plot(qtlambda(pp, 0.14), pp, type = "l", main = "lambda = 0.14 (normal)") #' plot(qtlambda(pp, 0.5), pp, type = "l", main = "lambda = 0.5 (concave)") #' plot(qtlambda(pp, 1), pp, type = "l", main = "lambda = 1 (uniform)") #' plot(qtlambda(pp, 2), pp, type = "l", main = "lambda = 2 (uniform)") #' #' hist(rtlambda(1e5, -1), freq = FALSE, main = "lambda = -1 (Cauchy)") #' hist(rtlambda(1e5, 0), freq = FALSE, main = "lambda = 0 (logistic)") #' hist(rtlambda(1e5, 0.14), freq = FALSE, main = "lambda = 0.14 (normal)") #' hist(rtlambda(1e5, 0.5), freq = FALSE, main = "lambda = 0.5 (concave)") #' hist(rtlambda(1e5, 1), freq = FALSE, main = "lambda = 1 (uniform)") #' hist(rtlambda(1e5, 2), freq = FALSE, main = "lambda = 2 (uniform)") #' par(partmp) #' #' @name TukeyLambda #' @aliases TukeyLambda #' @aliases qtlambda #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export qtlambda <- function(p, lambda, lower.tail = TRUE, log.p = FALSE) { cpp_qtlambda(p, lambda, lower.tail[1L], log.p[1L]) } #' @rdname TukeyLambda #' @export rtlambda <- function(n, lambda) { if (length(n) > 1) n <- length(n) cpp_rtlambda(n, lambda) } extraDistr/R/power-distribution.R0000755000176200001440000000374714475546572016641 0ustar liggesusers #' Power distribution #' #' Density, distribution function, quantile function and random generation #' for the power distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param alpha,beta parameters. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \frac{\beta x^{\beta-1}}{\alpha^\beta} #' }{ #' f(x) = (\beta*x^(\beta-1)) / (\alpha^\beta) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = \frac{x^\beta}{\alpha^\beta} #' }{ #' F(x) = x^\beta / \alpha^\beta #' } #' #' Quantile function #' \deqn{ #' F^{-1}(p) = \alpha p^{1/\beta} #' }{ #' F^-1(p) = \alpha * p^(1/\beta) #' } #' #' @examples #' #' x <- rpower(1e5, 5, 16) #' hist(x, 100, freq = FALSE) #' curve(dpower(x, 5, 16), 2, 6, col = "red", add = TRUE, n = 5000) #' hist(ppower(x, 5, 16)) #' plot(ecdf(x)) #' curve(ppower(x, 5, 16), 2, 6, col = "red", lwd = 2, add = TRUE) #' #' @name PowerDist #' @aliases PowerDist #' @aliases dpower #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dpower <- function(x, alpha, beta, log = FALSE) { cpp_dpower(x, alpha, beta, log[1L]) } #' @rdname PowerDist #' @export ppower <- function(q, alpha, beta, lower.tail = TRUE, log.p = FALSE) { cpp_ppower(q, alpha, beta, lower.tail[1L], log.p[1L]) } #' @rdname PowerDist #' @export qpower <- function(p, alpha, beta, lower.tail = TRUE, log.p = FALSE) { cpp_qpower(p, alpha, beta, lower.tail[1L], log.p[1L]) } #' @rdname PowerDist #' @export rpower <- function(n, alpha, beta) { if (length(n) > 1) n <- length(n) cpp_rpower(n, alpha, beta) } extraDistr/R/truncated-binomial-distribution.R0000755000176200001440000000403614475546572021256 0ustar liggesusers #' Truncated binomial distribution #' #' Density, distribution function, quantile function and random generation #' for the truncated binomial distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param size number of trials (zero or more). #' @param prob probability of success on each trial. #' @param a,b lower and upper truncation points (\code{a < x <= b}). #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @examples #' #' x <- rtbinom(1e5, 100, 0.83, 76, 86) #' xx <- seq(0, 100) #' plot(prop.table(table(x))) #' lines(xx, dtbinom(xx, 100, 0.83, 76, 86), col = "red") #' hist(ptbinom(x, 100, 0.83, 76, 86)) #' #' xx <- seq(0, 100, by = 0.01) #' plot(ecdf(x)) #' lines(xx, ptbinom(xx, 100, 0.83, 76, 86), col = "red", lwd = 2) #' uu <- seq(0, 1, by = 0.001) #' lines(qtbinom(uu, 100, 0.83, 76, 86), uu, col = "blue", lty = 2) #' #' @name TruncBinom #' @aliases TruncBinom #' @aliases dtbinom #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export dtbinom <- function(x, size, prob, a = -Inf, b = Inf, log = FALSE) { cpp_dtbinom(x, size, prob, a, b, log[1L]) } #' @rdname TruncBinom #' @export ptbinom <- function(q, size, prob, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) { cpp_ptbinom(q, size, prob, a, b, lower.tail[1L], log.p[1L]) } #' @rdname TruncBinom #' @export qtbinom <- function(p, size, prob, a = -Inf, b = Inf, lower.tail = TRUE, log.p = FALSE) { cpp_qtbinom(p, size, prob, a, b, lower.tail[1L], log.p[1L]) } #' @rdname TruncBinom #' @export rtbinom <- function(n, size, prob, a = -Inf, b = Inf) { if (length(n) > 1) n <- length(n) cpp_rtbinom(n, size, prob, a, b) } extraDistr/R/frechet-distribution.R0000755000176200001440000000500214475546572017107 0ustar liggesusers #' Frechet distribution #' #' Density, distribution function, quantile function and random generation #' for the Frechet distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param lambda,sigma,mu shape, scale, and location parameters. #' Scale and shape must be positive. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \frac{\lambda}{\sigma} \left(\frac{x-\mu}{\sigma}\right)^{-1-\lambda} \exp\left(-\left(\frac{x-\mu}{\sigma}\right)^{-\lambda}\right) #' }{ #' f(x) = \lambda/\sigma * ((x-\mu)/\sigma)^(-1-\lambda) * exp(-((x-\mu)/\sigma)^-\lambda) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = \exp\left(-\left(\frac{x-\mu}{\sigma}\right)^{-\lambda}\right) #' }{ #' F(x) = exp(-((x-\mu)/\sigma)^-\lambda) #' } #' #' Quantile function #' \deqn{ #' F^{-1}(p) = \mu + \sigma -\log(p)^{-1/\lambda} #' }{ #' F^-1(p) = \mu + \sigma * -log(p)^{-1/\lambda} #' } #' #' @references #' Bury, K. (1999). Statistical Distributions in Engineering. #' Cambridge University Press. #' #' @examples #' #' x <- rfrechet(1e5, 5, 2, 1.5) #' xx <- seq(0, 1000, by = 0.1) #' hist(x, 200, freq = FALSE) #' lines(xx, dfrechet(xx, 5, 2, 1.5), col = "red") #' hist(pfrechet(x, 5, 2, 1.5)) #' plot(ecdf(x)) #' lines(xx, pfrechet(xx, 5, 2, 1.5), col = "red", lwd = 2) #' #' @name Frechet #' @aliases Frechet #' @aliases dfrechet #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dfrechet <- function(x, lambda = 1, mu = 0, sigma = 1, log = FALSE) { cpp_dfrechet(x, lambda, mu, sigma, log[1L]) } #' @rdname Frechet #' @export pfrechet <- function(q, lambda = 1, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_pfrechet(q, lambda, mu, sigma, lower.tail[1L], log.p[1L]) } #' @rdname Frechet #' @export qfrechet <- function(p, lambda = 1, mu = 0, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_qfrechet(p, lambda, mu, sigma, lower.tail[1L], log.p[1L]) } #' @rdname Frechet #' @export rfrechet <- function(n, lambda = 1, mu = 0, sigma = 1) { if (length(n) > 1) n <- length(n) cpp_rfrechet(n, lambda, mu, sigma) } extraDistr/R/mixture-of-normal-distributions.R0000755000176200001440000000666014475546572021252 0ustar liggesusers #' Mixture of normal distributions #' #' Density, distribution function and random generation #' for the mixture of normal distributions. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param mean matrix (or vector) of means. #' @param sd matrix (or vector) of standard deviations. #' @param alpha matrix (or vector) of mixing proportions; #' mixing proportions need to sum up to 1. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \alpha_1 f_1(x; \mu_1, \sigma_1) + \dots + \alpha_k f_k(x; \mu_k, \sigma_k) #' }{ #' f(x) = \alpha[1] * f1(x; \mu[1], \sigma[1]) + \dots + \alpha[k] * fk(x; \mu[k], \sigma[k]) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = \alpha_1 F_1(x; \mu_1, \sigma_1) + \dots + \alpha_k F_k(x; \mu_k, \sigma_k) #' }{ #' F(x) = \alpha[1] * F1(x; \mu[1], \sigma[1]) + \dots + \alpha[k] * Fk(x; \mu[k], \sigma[k]) #' } #' #' where \eqn{\sum_i \alpha_i = 1}{sum(\alpha[i]) == 1}. #' #' @examples #' #' x <- rmixnorm(1e5, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)) #' hist(x, 100, freq = FALSE) #' curve(dmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)), #' -20, 20, n = 500, col = "red", add = TRUE) #' hist(pmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3))) #' plot(ecdf(x)) #' curve(pmixnorm(x, c(0.5, 3, 6), c(3, 1, 1), c(1/3, 1/3, 1/3)), #' -20, 20, n = 500, col = "red", lwd = 2, add = TRUE) #' #' @name NormalMix #' @aliases NormalMix #' @aliases dmixnorm #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dmixnorm <- function(x, mean, sd, alpha, log = FALSE) { if (is.vector(mean)) mean <- matrix(mean, nrow = 1) else if (!is.matrix(mean)) mean <- as.matrix(mean) if (is.vector(sd)) sd <- matrix(sd, nrow = 1) else if (!is.matrix(sd)) sd <- as.matrix(sd) if (is.vector(alpha)) alpha <- matrix(alpha, nrow = 1) else if (!is.matrix(alpha)) alpha <- as.matrix(alpha) cpp_dmixnorm(x, mean, sd, alpha, log[1L]) } #' @rdname NormalMix #' @export pmixnorm <- function(q, mean, sd, alpha, lower.tail = TRUE, log.p = FALSE) { if (is.vector(mean)) mean <- matrix(mean, nrow = 1) else if (!is.matrix(mean)) mean <- as.matrix(mean) if (is.vector(sd)) sd <- matrix(sd, nrow = 1) else if (!is.matrix(sd)) sd <- as.matrix(sd) if (is.vector(alpha)) alpha <- matrix(alpha, nrow = 1) else if (!is.matrix(alpha)) alpha <- as.matrix(alpha) cpp_pmixnorm(q, mean, sd, alpha, lower.tail[1L], log.p[1L]) } #' @rdname NormalMix #' @export rmixnorm <- function(n, mean, sd, alpha) { if (length(n) > 1) n <- length(n) if (is.vector(mean)) mean <- matrix(mean, nrow = 1) else if (!is.matrix(mean)) mean <- as.matrix(mean) if (is.vector(sd)) sd <- matrix(sd, nrow = 1) else if (!is.matrix(sd)) sd <- as.matrix(sd) if (is.vector(alpha)) alpha <- matrix(alpha, nrow = 1) else if (!is.matrix(alpha)) alpha <- as.matrix(alpha) cpp_rmixnorm(n, mean, sd, alpha) } extraDistr/R/bernoulli-distribution.R0000755000176200001440000000273514475546572017474 0ustar liggesusers #' Bernoulli distribution #' #' Probability mass function, distribution function, quantile function and random generation #' for the Bernoulli distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param prob probability of success; (\code{0 < prob < 1}). #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @seealso \code{\link[stats]{Binomial}} #' #' @examples #' #' prop.table(table(rbern(1e5, 0.5))) #' #' @name Bernoulli #' @aliases Bernoulli #' @aliases dbern #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export dbern <- function(x, prob = 0.5, log = FALSE) { cpp_dbern(x, prob, log[1L]) } #' @rdname Bernoulli #' @export pbern <- function(q, prob = 0.5, lower.tail = TRUE, log.p = FALSE) { cpp_pbern(q, prob, lower.tail[1L], log.p[1L]) } #' @rdname Bernoulli #' @export qbern <- function(p, prob = 0.5, lower.tail = TRUE, log.p = FALSE) { cpp_qbern(p, prob, lower.tail[1L], log.p[1L]) } #' @rdname Bernoulli #' @export rbern <- function(n, prob = 0.5) { if (length(n) > 1) n <- length(n) cpp_rbern(n, prob) } extraDistr/R/logarithmic-series-distribution.R0000755000176200001440000000461314475546572021270 0ustar liggesusers #' Logarithmic series distribution #' #' Density, distribution function, quantile function and random generation #' for the logarithmic series distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param theta vector; concentration parameter; (\code{0 < theta < 1}). #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability mass function #' \deqn{ #' f(x) = \frac{-1}{\log(1-\theta)} \frac{\theta^x}{x} #' }{ #' f(x) = (-1/log(1-\theta)*\theta^x) / x #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = \frac{-1}{\log(1-\theta)} \sum_{k=1}^x \frac{\theta^x}{x} #' }{ #' F(x) = -1/log(1-\theta) * sum((\theta^x)/x) #' } #' #' Quantile function and random generation are computed using #' algorithm described in Krishnamoorthy (2006). #' #' @references #' Krishnamoorthy, K. (2006). Handbook of Statistical Distributions #' with Applications. Chapman & Hall/CRC #' #' @references #' Forbes, C., Evans, M. Hastings, N., & Peacock, B. (2011). #' Statistical Distributions. John Wiley & Sons. #' #' @examples #' #' x <- rlgser(1e5, 0.66) #' xx <- seq(0, 100, by = 1) #' plot(prop.table(table(x)), type = "h") #' lines(xx, dlgser(xx, 0.66), col = "red") #' #' # Notice: distribution of F(X) is far from uniform: #' hist(plgser(x, 0.66), 50) #' #' xx <- seq(0, 100, by = 0.01) #' plot(ecdf(x)) #' lines(xx, plgser(xx, 0.66), col = "red", lwd = 2) #' #' @name LogSeries #' @aliases LogSeries #' @aliases dlgser #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export dlgser <- function(x, theta, log = FALSE) { cpp_dlgser(x, theta, log[1L]) } #' @rdname LogSeries #' @export plgser <- function(q, theta, lower.tail = TRUE, log.p = FALSE) { cpp_plgser(q, theta, lower.tail[1L], log.p[1L]) } #' @rdname LogSeries #' @export qlgser <- function(p, theta, lower.tail = TRUE, log.p = FALSE) { cpp_qlgser(p, theta, lower.tail[1L], log.p[1L]) } #' @rdname LogSeries #' @export rlgser <- function (n, theta) { if (length(n) > 1) n <- length(n) cpp_rlgser(n, theta) } extraDistr/R/mixture-of-poisson-distributions.R0000755000176200001440000000575014475546572021453 0ustar liggesusers #' Mixture of Poisson distributions #' #' Density, distribution function and random generation #' for the mixture of Poisson distributions. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param lambda matrix (or vector) of (non-negative) means. #' @param alpha matrix (or vector) of mixing proportions; #' mixing proportions need to sum up to 1. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \alpha_1 f_1(x; \lambda_1) + \dots + \alpha_k f_k(x; \lambda_k) #' }{ #' f(x) = \alpha[1] * f1(x; \lambda[1]) + \dots + \alpha[k] * fk(x; \lambda[k]) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = \alpha_1 F_1(x; \lambda_1) + \dots + \alpha_k F_k(x; \lambda_k) #' }{ #' F(x) = \alpha[1] * F1(x; \lambda[1]) + \dots + \alpha[k] * Fk(x; \lambda[k]) #' } #' #' where \eqn{\sum_i \alpha_i = 1}{sum(\alpha[i]) == 1}. #' #' @examples #' #' x <- rmixpois(1e5, c(5, 12, 19), c(1/3, 1/3, 1/3)) #' xx <- seq(-1, 50) #' plot(prop.table(table(x))) #' lines(xx, dmixpois(xx, c(5, 12, 19), c(1/3, 1/3, 1/3)), col = "red") #' hist(pmixpois(x, c(5, 12, 19), c(1/3, 1/3, 1/3))) #' #' xx <- seq(0, 50, by = 0.01) #' plot(ecdf(x)) #' lines(xx, pmixpois(xx, c(5, 12, 19), c(1/3, 1/3, 1/3)), col = "red", lwd = 2) #' #' @name PoissonMix #' @aliases PoissonMix #' @aliases dmixpois #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export dmixpois <- function(x, lambda, alpha, log = FALSE) { if (is.vector(lambda)) lambda <- matrix(lambda, nrow = 1) else if (!is.matrix(lambda)) lambda <- as.matrix(lambda) if (is.vector(alpha)) alpha <- matrix(alpha, nrow = 1) else if (!is.matrix(alpha)) alpha <- as.matrix(alpha) cpp_dmixpois(x, lambda, alpha, log[1L]) } #' @rdname PoissonMix #' @export pmixpois <- function(q, lambda, alpha, lower.tail = TRUE, log.p = FALSE) { if (is.vector(lambda)) lambda <- matrix(lambda, nrow = 1) else if (!is.matrix(lambda)) lambda <- as.matrix(lambda) if (is.vector(alpha)) alpha <- matrix(alpha, nrow = 1) else if (!is.matrix(alpha)) alpha <- as.matrix(alpha) cpp_pmixpois(q, lambda, alpha, lower.tail[1L], log.p[1L]) } #' @rdname PoissonMix #' @export rmixpois <- function(n, lambda, alpha) { if (length(n) > 1) n <- length(n) if (is.vector(lambda)) lambda <- matrix(lambda, nrow = 1) else if (!is.matrix(lambda)) lambda <- as.matrix(lambda) if (is.vector(alpha)) alpha <- matrix(alpha, nrow = 1) else if (!is.matrix(alpha)) alpha <- as.matrix(alpha) cpp_rmixpois(n, lambda, alpha) } extraDistr/R/half-t-distribution.R0000755000176200001440000000444414475546572016653 0ustar liggesusers #' Half-t distribution #' #' Density, distribution function, quantile function and random generation #' for the half-t distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param nu,sigma positive valued degrees of freedom and scale parameters. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' If \eqn{X} follows t distribution parametrized by degrees of freedom \eqn{\nu} #' and scale \eqn{\sigma}, then \eqn{|X|} follows half-t distribution parametrized #' by degrees of freedom \eqn{\nu} and scale \eqn{\sigma}. #' #' @references #' Gelman, A. (2006). Prior distributions for variance parameters in hierarchical #' models (comment on article by Browne and Draper). #' Bayesian analysis, 1(3), 515-534. #' #' @references #' Jacob, E. and Jayakumar, K. (2012). #' On Half-Cauchy Distribution and Process. #' International Journal of Statistika and Mathematika, 3(2), 77-81. #' #' @seealso \code{\link{HalfNormal}}, \code{\link{HalfCauchy}} #' #' @examples #' #' x <- rht(1e5, 2, 2) #' hist(x, 500, freq = FALSE, xlim = c(0, 100)) #' curve(dht(x, 2, 2), 0, 100, col = "red", add = TRUE) #' hist(pht(x, 2, 2)) #' plot(ecdf(x), xlim = c(0, 100)) #' curve(pht(x, 2, 2), 0, 100, col = "red", lwd = 2, add = TRUE) #' #' @name HalfT #' @aliases HalfT #' @aliases dht #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dht <- function(x, nu, sigma = 1, log = FALSE) { cpp_dht(x, nu, sigma, log[1L]) } #' @rdname HalfT #' @export pht <- function(q, nu, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_pht(q, nu, sigma, lower.tail[1L], log.p[1L]) } #' @rdname HalfT #' @export qht <- function(p, nu, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_qht(p, nu, sigma, lower.tail[1L], log.p[1L]) } #' @rdname HalfT #' @export rht <- function(n, nu, sigma = 1) { if (length(n) > 1) n <- length(n) cpp_rht(n, nu, sigma) } extraDistr/R/gev-distribution.R0000755000176200001440000000670714475546572016265 0ustar liggesusers #' Generalized extreme value distribution #' #' Density, distribution function, quantile function and random generation #' for the generalized extreme value distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param mu,sigma,xi location, scale, and shape parameters. Scale must be positive. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ f(x) = \left\{\begin{array}{ll} #' \frac{1}{\sigma} \left(1+\xi \frac{x-\mu}{\sigma}\right)^{-1/\xi-1} \exp\left(-\left(1+\xi \frac{x-\mu}{\sigma}\right)^{-1/\xi}\right) & \xi \neq 0 \\ #' \frac{1}{\sigma} \exp\left(- \frac{x-\mu}{\sigma}\right) \exp\left(-\exp\left(- \frac{x-\mu}{\sigma}\right)\right) & \xi = 0 #' \end{array}\right. #' }{ #' f(x) = [if \xi != 0:] 1/\sigma * (1+\xi*(x-\mu)/\sigma)^{-1/\xi-1} * exp(-(1+\xi*(x-\mu)/\sigma)^{-1/\xi}) #' [else:] 1/\sigma * exp(-(x-\mu)/\sigma) * exp(-exp(-(x-\mu)/\sigma)) #' } #' #' Cumulative distribution function #' \deqn{ F(x) = \left\{\begin{array}{ll} #' \exp\left(-\left(1+\xi \frac{x-\mu}{\sigma}\right)^{1/\xi}\right) & \xi \neq 0 \\ #' \exp\left(-\exp\left(- \frac{x-\mu}{\sigma}\right)\right) & \xi = 0 #' \end{array}\right. #' }{ #' F(x) = [if \xi != 0:] exp(-(1+\xi*(x-\mu)/\sigma)^{1/\xi}) #' [else:] exp(-exp(-(x-\mu)/\sigma)) #' } #' #' Quantile function #' \deqn{ F^{-1}(p) = \left\{\begin{array}{ll} #' \mu - \frac{\sigma}{\xi} (1 - (-\log(p))^\xi) & \xi \neq 0 \\ #' \mu - \sigma \log(-\log(p)) & \xi = 0 #' \end{array}\right. #' }{ #' F^-1(p) = [if \xi != 0:] \mu - \sigma/\xi * (1 - (-log(p))^\xi) #' [else:] \mu - \sigma * log(-log(p)) #' } #' #' @references #' Coles, S. (2001). An Introduction to Statistical Modeling of Extreme Values. #' Springer. #' #' @examples #' #' curve(dgev(x, xi = -1/2), -4, 4, col = "green", ylab = "") #' curve(dgev(x, xi = 0), -4, 4, col = "red", add = TRUE) #' curve(dgev(x, xi = 1/2), -4, 4, col = "blue", add = TRUE) #' legend("topleft", col = c("green", "red", "blue"), lty = 1, #' legend = expression(xi == -1/2, xi == 0, xi == 1/2), bty = "n") #' #' x <- rgev(1e5, 5, 2, .5) #' hist(x, 1000, freq = FALSE, xlim = c(0, 50)) #' curve(dgev(x, 5, 2, .5), 0, 50, col = "red", add = TRUE, n = 5000) #' hist(pgev(x, 5, 2, .5)) #' plot(ecdf(x), xlim = c(0, 50)) #' curve(pgev(x, 5, 2, .5), 0, 50, col = "red", lwd = 2, add = TRUE) #' #' @name GEV #' @aliases GEV #' @aliases dgev #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dgev <- function(x, mu = 0, sigma = 1, xi = 0, log = FALSE) { cpp_dgev(x, mu, sigma, xi, log[1L]) } #' @rdname GEV #' @export pgev <- function(q, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) { cpp_pgev(q, mu, sigma, xi, lower.tail[1L], log.p[1L]) } #' @rdname GEV #' @export qgev <- function(p, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) { cpp_qgev(p, mu, sigma, xi, lower.tail[1L], log.p[1L]) } #' @rdname GEV #' @export rgev <- function(n, mu = 0, sigma = 1, xi = 0) { if (length(n) > 1) n <- length(n) cpp_rgev(n, mu, sigma, xi) } extraDistr/R/shifted-gompertz-distribution.R0000755000176200001440000000603214475546572020766 0ustar liggesusers #' Shifted Gompertz distribution #' #' Density, distribution function, and random generation #' for the shifted Gompertz distribution. #' #' @param x,q vector of quantiles. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param b,eta positive valued scale and shape parameters; #' both need to be positive. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' If \eqn{X} follows exponential distribution parametrized by scale \eqn{b} and #' \eqn{Y} follows reparametrized Gumbel distribution with cumulative distribution function #' \eqn{F(x) = \exp(-\eta e^{-bx})}{F(x) = exp(-\eta*exp(-b*x))} parametrized by #' scale \eqn{b} and shape \eqn{\eta}, then \eqn{\max(X,Y)}{max(X,Y)} follows shifted #' Gompertz distribution parametrized by scale \eqn{b>0} and shape \eqn{\eta>0}. #' The above relation is used by \code{rsgomp} function for random generation from #' shifted Gompertz distribution. #' #' Probability density function #' \deqn{ #' f(x) = b e^{-bx} \exp(-\eta e^{-bx}) \left[1 + \eta(1 - e^{-bx})\right] #' }{ #' f(x) = b*exp(-b*x) * exp(-\eta*exp(-b*x)) * (1 + \eta*(1 - exp(-b*x))) #' } #' #' Cumulative distribution function #' \deqn{ #' F(x) = (1-e^{-bx}) \exp(-\eta e^{-bx}) #' }{ #' F(x) = (1-exp(-b*x)) * exp(-\eta*exp(-b*x)) #' } #' #' @references #' Bemmaor, A.C. (1994). #' Modeling the Diffusion of New Durable Goods: Word-of-Mouth Effect Versus Consumer Heterogeneity. #' [In:] G. Laurent, G.L. Lilien & B. Pras. Research Traditions in Marketing. #' Boston: Kluwer Academic Publishers. pp. 201-223. #' #' @references #' Jimenez, T.F. and Jodra, P. (2009). #' A Note on the Moments and Computer Generation of the Shifted Gompertz Distribution. #' Communications in Statistics - Theory and Methods, 38(1), 78-89. #' #' @references #' Jimenez T.F. (2014). #' Estimation of the Parameters of the Shifted Gompertz Distribution, #' Using Least Squares, Maximum Likelihood and Moments Methods. #' Journal of Computational and Applied Mathematics, 255(1), 867-877. #' #' @examples #' #' x <- rsgomp(1e5, 0.4, 1) #' hist(x, 50, freq = FALSE) #' curve(dsgomp(x, 0.4, 1), 0, 30, col = "red", add = TRUE) #' hist(psgomp(x, 0.4, 1)) #' plot(ecdf(x)) #' curve(psgomp(x, 0.4, 1), 0, 30, col = "red", lwd = 2, add = TRUE) #' #' @name ShiftGomp #' @aliases ShiftGomp #' @aliases dsgomp #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dsgomp <- function(x, b, eta, log = FALSE) { cpp_dsgomp(x, b, eta, log[1L]) } #' @rdname ShiftGomp #' @export psgomp <- function(q, b, eta, lower.tail = TRUE, log.p = FALSE) { cpp_psgomp(q, b, eta, lower.tail[1L], log.p[1L]) } #' @rdname ShiftGomp #' @export rsgomp <- function(n, b, eta) { if (length(n) > 1) n <- length(n) cpp_rsgomp(n, b, eta) } extraDistr/R/half-cauchy-distribution.R0000755000176200001440000000452514475546572017664 0ustar liggesusers #' Half-Cauchy distribution #' #' Density, distribution function, quantile function and random generation #' for the half-Cauchy distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param sigma positive valued scale parameter. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' If \eqn{X} follows Cauchy centered at 0 and parametrized by scale \eqn{\sigma}, #' then \eqn{|X|} follows half-Cauchy distribution parametrized by #' scale \eqn{\sigma}. Half-Cauchy distribution is a special case of half-t #' distribution with \eqn{\nu=1} degrees of freedom. #' #' @references #' Gelman, A. (2006). Prior distributions for variance parameters in hierarchical #' models (comment on article by Browne and Draper). #' Bayesian analysis, 1(3), 515-534. #' #' @references #' Jacob, E. and Jayakumar, K. (2012). #' On Half-Cauchy Distribution and Process. #' International Journal of Statistika and Mathematika, 3(2), 77-81. #' #' @seealso \code{\link{HalfT}} #' #' @examples #' #' x <- rhcauchy(1e5, 2) #' hist(x, 2e5, freq = FALSE, xlim = c(0, 100)) #' curve(dhcauchy(x, 2), 0, 100, col = "red", add = TRUE) #' hist(phcauchy(x, 2)) #' plot(ecdf(x), xlim = c(0, 100)) #' curve(phcauchy(x, 2), col = "red", lwd = 2, add = TRUE) #' #' @name HalfCauchy #' @aliases HalfCauchy #' @aliases dhcauchy #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dhcauchy <- function(x, sigma = 1, log = FALSE) { cpp_dhcauchy(x, sigma, log[1L]) } #' @rdname HalfCauchy #' @export phcauchy <- function(q, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_phcauchy(q, sigma, lower.tail[1L], log.p[1L]) } #' @rdname HalfCauchy #' @export qhcauchy <- function(p, sigma = 1, lower.tail = TRUE, log.p = FALSE) { cpp_qhcauchy(p, sigma, lower.tail[1L], log.p[1L]) } #' @rdname HalfCauchy #' @export rhcauchy <- function(n, sigma = 1) { if (length(n) > 1) n <- length(n) cpp_rhcauchy(n, sigma) } extraDistr/R/gpd-distribution.R0000755000176200001440000000556014475546572016252 0ustar liggesusers #' Generalized Pareto distribution #' #' Density, distribution function, quantile function and random generation #' for the generalized Pareto distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param mu,sigma,xi location, scale, and shape parameters. Scale must be positive. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ f(x) = \left\{\begin{array}{ll} #' \frac{1}{\sigma} \left(1+\xi \frac{x-\mu}{\sigma}\right)^{-(\xi+1)/\xi} & \xi \neq 0 \\ #' \frac{1}{\sigma} \exp\left(-\frac{x-\mu}{\sigma}\right) & \xi = 0 #' \end{array}\right. #' }{ #' f(x) = [if \xi != 0:] (1+\xi*(x-\mu)/\sigma)^{-(\xi+1)/\xi}/\sigma #' [else:] exp(-(x-\mu)/\sigma)/\sigma #' } #' #' Cumulative distribution function #' \deqn{ F(x) = \left\{\begin{array}{ll} #' 1-\left(1+\xi \frac{x-\mu}{\sigma}\right)^{-1/\xi} & \xi \neq 0 \\ #' 1-\exp\left(-\frac{x-\mu}{\sigma}\right) & \xi = 0 #' \end{array}\right. #' }{ #' F(x) = [if \xi != 0:] 1-(1+\xi*(x-\mu)/\sigma)^{-1/\xi} #' [else:] 1-exp(-(x-\mu)/\sigma) #' } #' #' Quantile function #' \deqn{ F^{-1}(x) = \left\{\begin{array}{ll} #' \mu + \sigma \frac{(1-p)^{-\xi}-1}{\xi} & \xi \neq 0 \\ #' \mu - \sigma \log(1-p) & \xi = 0 #' \end{array}\right. #' }{ #' F^-1(x) = [if \xi != 0:] \mu + \sigma * ((1-p)^{-\xi}-1)/\xi #' [else:] \mu - \sigma * log(1-p) #' } #' #' @references #' Coles, S. (2001). An Introduction to Statistical Modeling of Extreme Values. #' Springer. #' #' @examples #' #' x <- rgpd(1e5, 5, 2, .1) #' hist(x, 100, freq = FALSE, xlim = c(0, 50)) #' curve(dgpd(x, 5, 2, .1), 0, 50, col = "red", add = TRUE, n = 5000) #' hist(pgpd(x, 5, 2, .1)) #' plot(ecdf(x)) #' curve(pgpd(x, 5, 2, .1), 0, 50, col = "red", lwd = 2, add = TRUE) #' #' @name GPD #' @aliases GPD #' @aliases dgpd #' #' @keywords distribution #' @concept Univariate #' @concept Continuous #' #' @export dgpd <- function(x, mu = 0, sigma = 1, xi = 0, log = FALSE) { cpp_dgpd(x, mu, sigma, xi, log[1L]) } #' @rdname GPD #' @export pgpd <- function(q, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) { cpp_pgpd(q, mu, sigma, xi, lower.tail[1L], log.p[1L]) } #' @rdname GPD #' @export qgpd <- function(p, mu = 0, sigma = 1, xi = 0, lower.tail = TRUE, log.p = FALSE) { cpp_qgpd(p, mu, sigma, xi, lower.tail[1L], log.p[1L]) } #' @rdname GPD #' @export rgpd <- function(n, mu = 0, sigma = 1, xi = 0) { if (length(n) > 1) n <- length(n) cpp_rgpd(n, mu, sigma, xi) } extraDistr/R/bivariate-poisson-distribution.R0000755000176200001440000000443514475546572021136 0ustar liggesusers #' Bivariate Poisson distribution #' #' Probability mass function and random generation for the bivariate Poisson distribution. #' #' @param x,y vectors of quantiles; alternatively x may be a two-column #' matrix (or data.frame) and y may be omitted. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param a,b,c positive valued parameters. #' @param log logical; if TRUE, probabilities p are given as log(p). #' #' @details #' #' Probability mass function #' \deqn{ #' f(x) = \exp \{-(a+b+c)\} \frac{a^x}{x!} \frac{b^y}{y!} \sum_{k=0}^{\min(x,y)} #' {x \choose k} {y \choose k} k! \left( \frac{c}{ab} \right)^k #' }{ #' f(x) = exp(-(a+b+c)) * (a^x)/x! * (b^y)/y! * #' sum(choose(x,k)*choose(y,k)*k!*(c/(a*b))^k) #' } #' #' @references #' Karlis, D. and Ntzoufras, I. (2003). Analysis of sports data by using bivariate Poisson models. #' Journal of the Royal Statistical Society: Series D (The Statistician), 52(3), 381-393. #' #' @references #' Kocherlakota, S. and Kocherlakota, K. (1992) Bivariate Discrete Distributions. #' New York: Dekker. #' #' @references #' Johnson, N., Kotz, S. and Balakrishnan, N. (1997). Discrete Multivariate Distributions. #' New York: Wiley. #' #' @references #' Holgate, P. (1964). Estimation for the bivariate Poisson distribution. #' Biometrika, 51(1-2), 241-287. #' #' @references #' Kawamura, K. (1984). Direct calculation of maximum likelihood estimator for the bivariate #' Poisson distribution. Kodai mathematical journal, 7(2), 211-221. #' #' @examples #' #' x <- rbvpois(5000, 7, 8, 5) #' image(prop.table(table(x[,1], x[,2]))) #' colMeans(x) #' #' @seealso \code{\link[stats]{Poisson}} #' #' @name BivPoiss #' @aliases BivPoiss #' @aliases dbvpois #' #' @keywords distribution #' @concept Multivariate #' @concept Discrete #' #' @export dbvpois <- function(x, y = NULL, a, b, c, log = FALSE) { if (is.null(y)) { if ((is.matrix(x) || is.data.frame(x)) && ncol(x) == 2) { y <- x[, 2] x <- x[, 1] } else { stop("y is not provided while x is not a two-column matrix") } } cpp_dbpois(x, y, a, b, c, log[1L]) } #' @rdname BivPoiss #' @export rbvpois <- function(n, a, b, c) { if (length(n) > 1) n <- length(n) cpp_rbpois(n, a, b, c) } extraDistr/R/zero-inflated-poisson-distribution.R0000755000176200001440000000370514475546572021732 0ustar liggesusers #' Zero-inflated Poisson distribution #' #' Probability mass function and random generation #' for the zero-inflated Poisson distribution. #' #' @param x,q vector of quantiles. #' @param p vector of probabilities. #' @param n number of observations. If \code{length(n) > 1}, #' the length is taken to be the number required. #' @param lambda vector of (non-negative) means. #' @param pi probability of extra zeros. #' @param log,log.p logical; if TRUE, probabilities p are given as log(p). #' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \le x]} #' otherwise, \eqn{P[X > x]}. #' #' @details #' #' Probability density function #' \deqn{ #' f(x) = \left\{\begin{array}{ll} #' \pi + (1 - \pi) e^{-\lambda} & x = 0 \\ #' (1 - \pi) \frac{\lambda^{x} e^{-\lambda}} {x!} & x > 0 \\ #' \end{array}\right. #' }{ #' f(x) = [if x = 0:] \pi + (1-\pi) * exp(-\lambda) [else:] (1-\pi) * dpois(x, lambda) #' } #' #' @seealso \code{\link[stats]{Poisson}} #' #' @examples #' #' x <- rzip(1e5, 6, 0.33) #' xx <- -2:20 #' plot(prop.table(table(x)), type = "h") #' lines(xx, dzip(xx, 6, 0.33), col = "red") #' #' xx <- seq(0, 20, by = 0.01) #' plot(ecdf(x)) #' lines(xx, pzip(xx, 6, 0.33), col = "red") #' #' @name ZIP #' @aliases ZIP #' @aliases dzip #' #' @keywords distribution #' @concept Univariate #' @concept Discrete #' #' @export dzip <- function(x, lambda, pi, log = FALSE) { cpp_dzip(x, lambda, pi, log[1L]) } #' @rdname ZIP #' @export pzip <- function(q, lambda, pi, lower.tail = TRUE, log.p = FALSE) { cpp_pzip(q, lambda, pi, lower.tail[1L], log.p[1L]) } #' @rdname ZIP #' @export qzip <- function(p, lambda, pi, lower.tail = TRUE, log.p = FALSE) { cpp_qzip(p, lambda, pi, lower.tail[1L], log.p[1L]) } #' @rdname ZIP #' @export rzip <- function(n, lambda, pi) { if (length(n) > 1) n <- length(n) cpp_rzip(n, lambda, pi) } extraDistr/NEWS.md0000755000176200001440000002033314532036574013516 0ustar liggesusers### 1.10.0 * Fixed bug in `rgpd` which produced negative samples. * The RcppExports.cpp was fixed by reformatting it thanks to Dirk Eddelbuettel. ### 1.9.1 * Generated header file, `inst/include/extraDistr.h`, to make C++ code callable from C++ code in other R packages (#23, contribution from Jon Fintzi, @fintzij). ### 1.8.11 * Fixed bugs in Frechet distribution implementations (`pfrechet`). ### 1.8.10 * Now zero-inflated negative-binomial (#12) and beta negative-binomial distributions (#14) do not have integer-only constraint on `size` parameter. * Fixed mistakes in the zero-inflated Poisson distribution documentation (#15) and negative hypergeometric distribution documentation. * Minor changes towards future Rcpp STRICT_R_HEADERS compatibility. * Fixed bug in vectorization code for `pbbinom` (#16). Additionally, this should make `pbbinom` and `pbnbinom` faster when working with large vectors. ### 1.8.9 * Fixed bug in `dinvgamma` function * Updated the DESCRIPTION file by mentioning the packages used in optional unit tests for CRAN compatibility ### 1.8.8 * Deprecated functions: `dnst`, `pnst`, `qnst` and `rnst` were removed * Fixed typos in documentation (thanks to #8 by philchalmers) * Converted a number of pdf and cdf functions to more numerically stable versions using logs (see #9 and #10) * Fixed bug in `ppower`: with `lower.tail = FALSE` it returned wrong values * Fixed bug in `dgpd` and `pgpd`: they assumed slightly wrong support * Improved the `rgev` and `rgpd`, now they give better random values since relying on exponential distribution random generator if possible * Documentation was improved and corrected in several places * Power distribution functions now check if `alpha > 0` and `beta > 0` ### 1.8.7 * Fixed bug in `pinvgamma` (`lower.tail` and `log.p` didn't work) * Fixed underflow issues with `rmnom` and `rdirmnom` (#7) * The `*nst` functions are now deprecated and renamed to more informative abbrevation `*lst` ### 1.8.6 * Now consistently with base R only the first elements of the logical arguments are used (thanks to #5) * Fixed bug in `rtnorm` (sampling from lower bound returned incorrect values) * When computation becomes slow, now `pbnbinom`, `pbbinom`, `pgpois` functions are easier to brake * Automatically registering native routines via Rcpp * Fixed bug in `pinvgamma` (it returned non-zero probabilities for q < 0) ### 1.8.5 * Now `rmnom` and `rdirmnom` (issue #3) do not return `NaN`'s due to underflow issues * Fixed bug (issue #4) that resulted in hanging R if zero-length vectors were provided as input ### 1.8.4 * Random generation from categorical distribution parametrized by log-probabilities `rcatlp` * Re-parametrized beta distribution is now more flexible since "prior" parameter was introduced (see documentation); this change is connected to switching to different prior equal to zero (instead of one as previously). Such parametrization is more commonly used in the literature. This change is documented in the `?PropBeta` documentation * Improvements in documentation and examples * Fixed bugs in `pbbinom`, `pbnbinom`, `pgpois`, `*nhyper` that prevented compiling on RedHat Linux (#2) ### 1.8.3 * Switched to C++11, underlying code was simplified and improved * Using memoization techniques for `pbbinom`, `pbnbinom`, `pgpois` and negative hypergeometric distribution that lead to major speed improvements * Improved and simplified code for beta-binomial, beta negative-binomial, and gamma-Poisson cdf; now recursive algorithm employing memoization techniques is used what noticeably improves performance * Discrete gamma, shifted Gompertz (d,p,r), negative hypergeometric and truncated binomial distributions (d,p,q,r) were added * Now `lower.tail` and `log.p` options for `pbetapr` work properly * Simplified code for multivariate hypergeometric, multinomial, Dirichlet-multinomial and categorical distributions * Truncated poisson distribution is now parametrized by lower and upper truncation points * Fixed bugs in `dbvpois` (it returned underestimated probabilities), `dslash` (there was discontinuity at x=0), `pcat` (randomly it broke if x was greater then the upper limit), and `pdnorm`. * Random generation functions throw warnings and produce `NA`'s on `NA`'s in parameters or incorrect parameters - as in base R * Order of parameters in discrete Laplace distribution was changed to location and scale (vs scale and location) for consistency with other distributions (e.g. continous Laplace) * Improved exception handling ### 1.8.1-2 * Corrected and simplified documentation for `*prop` distribution * Categorical, multinomial, mixture of normals and mixture of Poisson distributions are now *less restrictive* about probability parameters and accept any non-negative values. Probability parameter vectors are normalized to sum to one (i.e. `c(1,1,1)` becomes `c(1,1,1)/3`) * `NA`'s and `NaN`'s in input now always lead to `NA`'s in output * Fixed bugs in `rtnorm`, now it properly handles sampling from extreme tails * Tests for multivariate distribution now done with tolerance `1e-2` ### 1.8.0 * Bug fixes in `qtnorm` - now it works properly for non-standard truncated normal * Bug fixes for `rmnom` and `rdirmnom` - now they correctly use the `prob` parameter values * Minor improvements in `dmvhyper` and `dbvpois` * Cleaned-up the documentation * Added discrete Laplace distribution * Faster RNG generator for Laplace distribution * Changes to using lower level RNG functions (`unif_rand`, `norm_rand`) when possible * More tests ### 1.7.2 * Documentation clean-up * Minor improvements and simplifications in C++ code * For `min == max` discrete uniform distribution behaves now as degenerate distribution ### 1.7.1 * Added Dirichlet-multinomial and beta prime distributions * Code clean-up for categorical distribution * Improvements in documentation and examples (e.g. bivariate Poisson, bivariate normal) * Other minor improvements in the code ### 1.7.0 * Cleaning namespace - now mathematical functions are explicitly called from std library * "using namespace Rcpp" was removed from all the files * All the numerical values are now explicitly ``'s, or casted to ``; or ``'s (for indexing) * Improvements in algorithms for discrete uniform, categorical, mixture of normal, mixture of Poisson distributions * Improvements in discrete uniform; now it accepts only integer valued parameters * Major C++ code clean-up ### 1.6.10-14 * Removed `erf`, `erfc`, `inv_erf` that are not used at this moment and caused problems when compiling on Fedora and Solaris * Minor improvements in documentation * Added mixtures of normal and of Poisson distributions * Added truncated Poisson distribution ### 1.6.7-9 * Minor changes and improvements in documention * Truncated normal returns normal for infinite truncation points * Added half-t, half-normal and half-Cauchy distributions * Changed naming of data-variable from `x` to `q` for CDF's * Added inverse-CDF for discrete normal distribution, fixed random generation * Added tests * Multiple minor bug fixes (e.g. functions returning `NaN` instead of `0` for `Inf` values) * Added Birnbaum-Saunders (fatigue life) distribution * New algorithm for `rtriang` * Added quantile functions for: zero-inflated Poisson, zero-inflated binomial zero-inflated negative binomial, inverse gamma, inverse chi-squared distributions * Added Huber density ### 1.6.1 * Exception handling in discrete uniform distribution functions * Bug fixes in `rdunif` * Clean-up in documentation and examples * Now `dbvnorm` and `dbvpois` work with matrixes * Renaming of parameters in bivariate normal to be consistent with base R normal distribution ### 1.6.0 * Warning messages for non-integer values in discrete distributions * Warning when returning NANs * Code clean-up in `pbbinom` and `pbnbinom` * Clean-up in documentation ### 1.5.15-19 * Ranamed zero-inflated distributions to `*zip` and `*zinb` * Added zero-inflated binomial `*zib` * Code clean-up * Added `pzipois` and `pzibinom` * Added `qlgser`; changes in `plgser` and `rlgser` * Fixed bug in `rlgser` * Examples for most of the functions * Exception handling for `dmvhyper` and `rmvhyper`: values of `x`, `n`, and `k` are checked against being non-integers extraDistr/MD50000644000176200001440000003021714532054172012721 0ustar liggesusers695d40c216790a6fd36e18750b61b35d *DESCRIPTION 15b9fdd4387687f3dc67aa844a473d33 *NAMESPACE d620aa97e02ed7f4999246a7a946858d *NEWS.md c36b962aa2a35048052ac76c622b94d0 *R/RcppExports.R a513d5279b2d2e45f20a849b6321cc70 *R/bernoulli-distribution.R 04970773722479d2b4cfbf2097650b1f *R/beta-binomial-distribution.R 10986eeb037dba0adf745280685991f0 *R/beta-negative-binomial-distribution.R 15c1ed461652d73edcb0bf418486d5fc *R/beta-prime-distribution.R 14097e62dd229aae5e3772851039eb11 *R/bhattacharjee-distribution.R 96b5c5273c82495588bc38e1ff1e5de7 *R/birnbaum-saunders-distribution.R 18da67cc20340fc0e94781fd6fac9da5 *R/bivariate-normal-distribution.R 9883637db0d529c609fcaaad1e3b3348 *R/bivariate-poisson-distribution.R d814edba8b64d5b2f547c786e867157d *R/categorical-distribution.R e1db812ca4327615ed4822e75b1d40f0 *R/dirichlet-distribution.R 44b37e6ab611a537f7e0779f957b37b0 *R/dirichlet-multinomial-distribution.R d17ded874bd8d01e2bd547fa7862c775 *R/discrete-gamma-distribution.R c3092be4b139ae7dadcaba4d17e3c07e *R/discrete-laplace-distribution.R d93299768ff5495c7f3f27fa32aeefcf *R/discrete-normal-distribution.R 0dc71fca0dae95476fd3da2b593c792b *R/discrete-uniform-distribution.R 0341e8c29c629b406d3a596f5fc4bfa5 *R/discrete-weibull-distribution.R d41d8cd98f00b204e9800998ecf8427e *R/extraDistr-deprecated.R ccf86924948a6fa0b3821d196b14e603 *R/extraDistr-package.R c0975788a5386435ed869bc4a6905878 *R/frechet-distribution.R bbb87724f3e0514093b7eb165c7bd92c *R/gamma-poisson-distribution.R e45fe9c80150e2e9d14219be4a093841 *R/gev-distribution.R 9cfce9598a4bb5d4d0ea24fe3269a467 *R/gompertz-distribution.R 2f6841ea23b35440acfcf69d3c5db16d *R/gpd-distribution.R 50ac996ab7d9b812c95ce7aee4479c4b *R/gumbel-distribution.R 1b51062626d3b1a9c5f97a1e1750c209 *R/half-cauchy-distribution.R 586f9680c0f3691ad9cecca4631c6e72 *R/half-normal-distribution.R fa16f7efa6f3815580e5561039e12d9a *R/half-t-distribution.R 285352f87fafdee9f503ec7d5b1806ae *R/huber-distribution.R 02eed15c496446cfee265508193a8a75 *R/inverse-chi-squared-distribution.R 7ecf8c10641304c9f7f82a1870889563 *R/inverse-gamma-distribution.R 0e221376c86815050eaa291cb6497656 *R/kumaraswamy-distribution.R 8fc26a7bd877c2b77ddee3d0cdf84309 *R/laplace-distribution.R d2dbdb536053f3a35d6c6f9e2cfb1ca7 *R/location-scale-t-distribution.R ba1323ce76e2e6e408233441f85141ef *R/logarithmic-series-distribution.R 6ab5666d2b356f1b11b6880159275baa *R/lomax-distribution.R 2ebeee0b1f545ff207a853050e4ba316 *R/mixture-of-normal-distributions.R 9f6db5081617201db31f0bcfec59f03c *R/mixture-of-poisson-distributions.R 2334815bd6c1ed04ae801b2f495027fa *R/multinomial-distribution.R c966e3aab63f906408eb20d6eeccb2c6 *R/multivariate-hypergeometric-distribution.R bbf0a524cc57a30eb5cee0d454829095 *R/negative-hypergeometric-distribution.R 850300b0daee4d944ed4c71060e2313f *R/non-standard-beta-distribution.R 5fcb4cbd1434ccde5ea2785073515b49 *R/pareto-distribution.R cf3b3d3d7c9ca738539270191f4508a4 *R/power-distribution.R fac03f8bfc580c83887eb39e5ed00aa4 *R/proportion-distribution.R ee6ff1174071047e912a1b7a21f85232 *R/rademacher-distribution.R ef229d780641b78ed0bd408594f106bb *R/rayleigh-distribution.R 4407faf80a5812711db40be2f7b3a16c *R/shifted-gompertz-distribution.R afaf9c7a6196f4890f9c3a0217354738 *R/skellam-distribution.R c85666f6d4256bf760715dca87607bff *R/slash-distribution.R 1afde0ab5925a1dd17900c936be2f1a2 *R/triangular-distribution.R e6a66e694cb0cdc8b335aa43feca3425 *R/truncated-binomial-distribution.R fb2ae1fb4cdeb5291649c31d1edd49dc *R/truncated-normal-distribution.R 53cb3787fff55349dfde516bf2341dc3 *R/truncated-poisson-distributtion.R d6aa1582ebb25889ba7adf1c918e7c11 *R/tukey-lambda-distribution.R 972bb9d9eb96ce8bdaadf3805ed29699 *R/wald-distribution.R 953bceba2ae55ecb072c8242407a76b5 *R/zero-inflated-binomial-distribution.R f22aa3532ed571b7a8ba78e4100bab16 *R/zero-inflated-negative-binomial-distribution.R f2821cce9ca7d903dc58b69a95a6acd5 *R/zero-inflated-poisson-distribution.R f8a1131d5543f811236801d969522c94 *R/zzz.R ea2f206dd6ca3b418f70f86ad022edfa *inst/include/extraDistr.h ca43e29781bb4354e1a8a8ec92b49bd9 *inst/include/extraDistr_RcppExports.h 6e9ca27ae4527aed015e0f33abd33e76 *man/Bernoulli.Rd 6557e500dd54e776daa583a593ff9c52 *man/BetaBinom.Rd 6e97ca2697383f48ec24b2cebfe0ffad *man/BetaNegBinom.Rd 4006c15a760a6c1b81909814d42e329b *man/BetaPrime.Rd be5f2d3d4f4c0f8598a0935f6a4ede91 *man/Bhattacharjee.Rd 82e05e96c91e9ff5043fe3e5df5102cc *man/BirnbaumSaunders.Rd b60940d45c9323d1e0c117e4fdb4da3f *man/BivNormal.Rd 726e4b2c748c936c105a95801a859b48 *man/BivPoiss.Rd 26d56110aeb2468e2246028323f8c702 *man/Categorical.Rd 81665d455295cf329502183640d390ec *man/DirMnom.Rd a38d121574383b4e595021b2b417463f *man/Dirichlet.Rd 4d892f05d6a2ee3b1fda2c711754b73d *man/DiscreteGamma.Rd f7c82acb914372f6a2e191ab15405f3a *man/DiscreteLaplace.Rd a969a57939726ec410cd335477e2642e *man/DiscreteNormal.Rd 3b57d3cd7d77bdf15251cfda5d8c9603 *man/DiscreteUniform.Rd 28122561d4243be46d8821816b0a0b27 *man/DiscreteWeibull.Rd fa42c49b33ed1c4e86c98e011cadb5b1 *man/Frechet.Rd 020afca6ce97d633e6dfa9f92e64ce2f *man/GEV.Rd c02ae4c814a6f082cf2d4b94675ea177 *man/GPD.Rd e938a514e2a3be98dbd694a2fc75e8cf *man/GammaPoiss.Rd d3bb6f9af17abe8da34c41c8c3188bff *man/Gompertz.Rd cb384cff0e17b6729e3d4c3c6d56d9aa *man/Gumbel.Rd dc14a107a22daf96c6f0f027c556519a *man/HalfCauchy.Rd 6c9ad10bcaadd0a95c47253301b0f0c9 *man/HalfNormal.Rd 284730b486e0715fefa6011be5a69860 *man/HalfT.Rd fb7a0fb1e96dcd51f92a5f41e53de65c *man/Huber.Rd 5378c4fa21a54440d892332d15cff509 *man/InvChiSq.Rd df666fbc0c41d8e4b0e74f3208d9c512 *man/InvGamma.Rd 0b48e4bcd2ca2780637004ef0fa29d71 *man/Kumaraswamy.Rd cda4ffa746c6bcd0903e1dc681bf0afa *man/Laplace.Rd c45d6fd4e3aae13d8079d665ad0d0995 *man/LocationScaleT.Rd f29796a343fb5ae33425249288b20991 *man/LogSeries.Rd 5993ce73909c8f1458f74a80d8f4eb8c *man/Lomax.Rd a6c98f2e4eb7d788c80b19eebf20ea79 *man/MultiHypergeometric.Rd 9ede8c4a64e4d597d01e6285151c990b *man/Multinomial.Rd fdb298a7a1de5e5113f22c4e1572688b *man/NSBeta.Rd 19613caba82a092b0e38990d3506d87b *man/NegHyper.Rd 0951a686b2df3fe0e4a671692cdc6cba *man/NormalMix.Rd 31a0d2b471192be7a236858d1ffc7d26 *man/Pareto.Rd 9b1ade4a160c16bfae0a16efa5517eda *man/PoissonMix.Rd 1569ea0fbb0710d9baebe209bb0aea30 *man/PowerDist.Rd b38d1cbc82cf925f35f31a1140ff48cf *man/PropBeta.Rd 1a0cb17cd63b29ffb43bf6c708dc7360 *man/Rademacher.Rd c7e9172bce096e6c92d362128c88fd5f *man/Rayleigh.Rd 76d731f935adf0a40db1f241904b764c *man/ShiftGomp.Rd 73021051d22cf7f118a80c8b2de7b5da *man/Skellam.Rd fee2da3d6f45ed84aefc3cf79718a2b7 *man/Slash.Rd f9a012a1f3e4ed7eb2c9ad1522f4cb8c *man/Triangular.Rd 489c9bffe954e777cb36e8dfd020af0e *man/TruncBinom.Rd b82b0da9767c401585ea477bd244179c *man/TruncNormal.Rd 2942ee809c452353746b4d9c948525b9 *man/TruncPoisson.Rd fccdb2144aeff42c0c88066eb6e8d130 *man/TukeyLambda.Rd 7f240bda0dbf9e4509d66c23a46913b1 *man/Wald.Rd e8a465910cfc7db2c34c625765dd259e *man/ZIB.Rd edc31120a70b2e1b3bb9dc28388ddc26 *man/ZINB.Rd 8438113bea17ef0b9083b057dcc3f563 *man/ZIP.Rd 64fba0c34e4827295472ec0a1d3b3e2c *man/extraDistr-package.Rd 34c82048b4154dc1d4efe16cc8240bbd *src/RcppExports.cpp d82f661ad2377f2abff74f7d790a8253 *src/bernoulli-distribution.cpp 7c088d786e0fa633e476f40fc965315f *src/beta-binomial-distribution.cpp 39714e42c7cfe75f86b27e7276336da7 *src/beta-negative-binomial-distribution.cpp 1aa5caf45db8da601a443c97fea831eb *src/beta-prime-distribution.cpp c1036cc68cd8aa339e548cda540e8a7b *src/bhattacharjee-distribution.cpp c5f31ff8d203a4eb04e4bec86c47b0a1 *src/birnbaum-saunders-distribution.cpp 55ce4c26282856c75b93cab250973753 *src/bivariate-normal-distribution.cpp 485347f7dd8151f77739bc7287f1e55b *src/bivariate-poisson-distribution.cpp fbaa13b2c9199f9232dd51554e761cbc *src/categorical-distribution-lp.cpp 0c48b726ce7f005e5bc689d8d820ad78 *src/categorical-distribution.cpp ce4135f61c9eeaaf0099ef522a4c1d10 *src/dirichlet-distribution.cpp 5add921e962b23b3ea9be2446b097327 *src/dirichlet-multinomial-distribution.cpp 4507c4e890ea88d594c7ae3f1bb6c0a7 *src/discrete-gamma-distribution.cpp 2fe1e00963931cac8e5ba231fb64e041 *src/discrete-laplace-distribution.cpp 64f24a25b1f67349617275b07397e765 *src/discrete-normal-distribution.cpp ce26d87249281eaef4d288f22b366cd1 *src/discrete-uniform-distribution.cpp 18105b93f9fac03488166515f5c4fc89 *src/discrete-weibull-distribution.cpp a0533c8bf8c94f3cb68abd6efd07b96b *src/frechet-distribution.cpp 63b7735342854697106301225df0e8d0 *src/gamma-poisson-distribution.cpp ca4d8bd3bbec2e8b143d22da3c431091 *src/gev-distribution.cpp 86feb2f8cf42bf24e9a5c0c4f77b186d *src/gompertz-distribution.cpp 6d29f03760d6b7210b1ef6eac153432e *src/gpd-distribution.cpp 15ffe2357de85fab71e7427713cbfc8b *src/gumbel-distribution.cpp 358ea9cbe55cdbcfcb952a3396001f41 *src/half-cauchy-distribution.cpp e7c74ce16142b6e71e12b20b440be8e9 *src/half-normal-distribution.cpp 93daedd643e234bcef270c3f9806e764 *src/half-t-distribution.cpp 269fb53ca71838c2be17f371b7887b61 *src/huber-distribution.cpp 6b798559ef53e6f04e05c4c31da4ea5a *src/inverse-gamma-distribution.cpp a282afcac602252ada5f7330e4bf6773 *src/kumaraswamy-distribution.cpp f5553c71de10b22d624385372a61cc7b *src/laplace-distribution.cpp 9f4400fff666accad6dbd82887f999ea *src/location-scale-t-distribution.cpp 8d60e410363ff850350cdf4299d7487b *src/logarithmic-series-distribution.cpp 3726939a3a0139776972b342d822a429 *src/lomax-distribution.cpp 039bdc7ff696a29dce6f47dcefaa306d *src/mixture-of-normal-distributions.cpp 67f9610d8a8924122c01e0b1834fa244 *src/mixture-of-poisson-distributions.cpp eba5905595efe8f30462d508b4ce1188 *src/multinomial-distribution.cpp b8e6548e337215c53383b84e7a2d0547 *src/multivariate-hypergeometric-distribution.cpp 42e913ebf4999251a4e41da4eb2f9f61 *src/negative-hypergeometric-distribution.cpp 24a400ca3aa8bc7ce76e5a358632b837 *src/non-standart-beta-distribution.cpp 62e71a321f6c126238fbd0b4612f0bb3 *src/pareto-distribution.cpp 6f1088def1bfaa67e043c77ddb15b859 *src/power-distribution.cpp 2b5e8d11ea655f687f943d6036641caf *src/proportion-distribution.cpp 1e342660ffc75f9fdafefc2d616d57da *src/rademacher-distribution.cpp 9cdfd025d8907048e2407937e95a503e *src/rayleigh-distribution.cpp e6029b021c9d28f19bcdbc44eebd6c17 *src/shared.cpp 530be4314b94b34e6d0664776a34d23a *src/shared.h e1f7021a532efbe932fd8e95394f75b8 *src/shared_inline.h ed6bec947098dc5667289bf8a92ccf02 *src/shifted-gompertz-distribution.cpp 4285e328f546074a427a5019d2bd9659 *src/skellam-distribution.cpp abe46ce6cb73b27aef769840e692937c *src/slash-distribution.cpp 6029397235cc6cfdc63b2d36e068580a *src/triangular-distribution.cpp d7096cae1432a32bfac5f4e75704e254 *src/truncated-binomial-distribution.cpp caa9b3b099359985aee9a6604c3e941c *src/truncated-normal-distribution.cpp 5e2b2a353dcec76456b82efca34d37ec *src/truncated-poisson-distribution.cpp 5415cf506d6e5d96e6b7b5aae2825a0f *src/tuckey-lambda-distribution.cpp 407052e356679a62510e409f945fb0f9 *src/wald-distribution.cpp 11029dae0786a970273094b654b15083 *src/zero-inflated-binomial-distribution.cpp a4cfef7d07e5c09e36c8a910c2947faf *src/zero-inflated-negative-binomial-distribution.cpp 9977bff612e83b23639a50ab271e6049 *src/zero-inflated-poisson-distribution.cpp 6ec0cf1399e39821aa7d89b516514eac *tests/testthat.R a80083dc5d3797f3f14a48000703b30d *tests/testthat/helper_pure_r_implementations.R e54cb3ca7647ee48de32145db7ce530d *tests/testthat/test-NAs.R 8444bd9fd5953ee5944bf259b037c605 *tests/testthat/test-discrete-sum-to-unity.R f4bb951577dd9aeb391821b8a8147e1f *tests/testthat/test-discrete.R 14f9913e2e9034cd26fc2859a12d6162 *tests/testthat/test-inappropriate-parameters.R eacba71357a53757fb0867dca170a5cc *tests/testthat/test-infinity.R ecc333a75820190259a6871657663f88 *tests/testthat/test-log-probs.R cff0a287feff0643b3d7c370eba114eb *tests/testthat/test-misc.R 879932557d7e6a14a00710bad21dc204 *tests/testthat/test-multivariate-distributions.R 1bb462cff3513a6e538b1def40f07124 *tests/testthat/test-non-negative.R eac8881f31fb03b23073b034b95489d4 *tests/testthat/test-p-r-random-tests.R cafc9febdad756959c0b17653f72690a *tests/testthat/test-probabilities.R 1949d9583a21ee2a2eb4ce18d814734f *tests/testthat/test-pure-r-benchmarks.R dc614194e1ab92c34940bd14399608ee *tests/testthat/test-quantile-functions.R bda720e1eb8480e73b3eeba1b96e8a48 *tests/testthat/test-rng-coverge.R eca05f0ed4dba9d0e78bb3ffe7f27a4c *tests/testthat/test-rtnorm-in-bounds.R e5cbe4c5a4ee93587e1ef6b3736bf4cb *tests/testthat/test-zero-length.R f131be473f90ba475668f41a63f0f2ea *tests/testthat/test_vectorization.R extraDistr/inst/0000755000176200001440000000000014475546572013403 5ustar liggesusersextraDistr/inst/include/0000755000176200001440000000000014475546572015026 5ustar liggesusersextraDistr/inst/include/extraDistr_RcppExports.h0000644000176200001440000071771414475546572021722 0ustar liggesusers// Generated by using Rcpp::compileAttributes() -> do not edit by hand // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 #ifndef RCPP_extraDistr_RCPPEXPORTS_H_GEN_ #define RCPP_extraDistr_RCPPEXPORTS_H_GEN_ #include namespace extraDistr { using namespace Rcpp; namespace { void validateSignature(const char* sig) { Rcpp::Function require = Rcpp::Environment::base_env()["require"]; require("extraDistr", Rcpp::Named("quietly") = true); typedef int(*Ptr_validate)(const char*); static Ptr_validate p_validate = (Ptr_validate) R_GetCCallable("extraDistr", "_extraDistr_RcppExport_validate"); if (!p_validate(sig)) { throw Rcpp::function_not_exported( "C++ function with signature '" + std::string(sig) + "' not found in extraDistr"); } } } inline NumericVector cpp_dbern(const NumericVector& x, const NumericVector& prob, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dbern)(SEXP,SEXP,SEXP); static Ptr_cpp_dbern p_cpp_dbern = NULL; if (p_cpp_dbern == NULL) { validateSignature("NumericVector(*cpp_dbern)(const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dbern = (Ptr_cpp_dbern)R_GetCCallable("extraDistr", "_extraDistr_cpp_dbern"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dbern(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pbern(const NumericVector& x, const NumericVector& prob, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pbern)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pbern p_cpp_pbern = NULL; if (p_cpp_pbern == NULL) { validateSignature("NumericVector(*cpp_pbern)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pbern = (Ptr_cpp_pbern)R_GetCCallable("extraDistr", "_extraDistr_cpp_pbern"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pbern(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qbern(const NumericVector& p, const NumericVector& prob, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qbern)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qbern p_cpp_qbern = NULL; if (p_cpp_qbern == NULL) { validateSignature("NumericVector(*cpp_qbern)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qbern = (Ptr_cpp_qbern)R_GetCCallable("extraDistr", "_extraDistr_cpp_qbern"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qbern(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rbern(const int& n, const NumericVector& prob) { typedef SEXP(*Ptr_cpp_rbern)(SEXP,SEXP); static Ptr_cpp_rbern p_cpp_rbern = NULL; if (p_cpp_rbern == NULL) { validateSignature("NumericVector(*cpp_rbern)(const int&,const NumericVector&)"); p_cpp_rbern = (Ptr_cpp_rbern)R_GetCCallable("extraDistr", "_extraDistr_cpp_rbern"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rbern(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dbbinom(const NumericVector& x, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dbbinom)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dbbinom p_cpp_dbbinom = NULL; if (p_cpp_dbbinom == NULL) { validateSignature("NumericVector(*cpp_dbbinom)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dbbinom = (Ptr_cpp_dbbinom)R_GetCCallable("extraDistr", "_extraDistr_cpp_dbbinom"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dbbinom(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pbbinom(const NumericVector& x, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pbbinom)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pbbinom p_cpp_pbbinom = NULL; if (p_cpp_pbbinom == NULL) { validateSignature("NumericVector(*cpp_pbbinom)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pbbinom = (Ptr_cpp_pbbinom)R_GetCCallable("extraDistr", "_extraDistr_cpp_pbbinom"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pbbinom(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rbbinom(const int& n, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta) { typedef SEXP(*Ptr_cpp_rbbinom)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rbbinom p_cpp_rbbinom = NULL; if (p_cpp_rbbinom == NULL) { validateSignature("NumericVector(*cpp_rbbinom)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rbbinom = (Ptr_cpp_rbbinom)R_GetCCallable("extraDistr", "_extraDistr_cpp_rbbinom"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rbbinom(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dbnbinom(const NumericVector& x, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dbnbinom)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dbnbinom p_cpp_dbnbinom = NULL; if (p_cpp_dbnbinom == NULL) { validateSignature("NumericVector(*cpp_dbnbinom)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dbnbinom = (Ptr_cpp_dbnbinom)R_GetCCallable("extraDistr", "_extraDistr_cpp_dbnbinom"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dbnbinom(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pbnbinom(const NumericVector& x, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pbnbinom)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pbnbinom p_cpp_pbnbinom = NULL; if (p_cpp_pbnbinom == NULL) { validateSignature("NumericVector(*cpp_pbnbinom)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pbnbinom = (Ptr_cpp_pbnbinom)R_GetCCallable("extraDistr", "_extraDistr_cpp_pbnbinom"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pbnbinom(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rbnbinom(const int& n, const NumericVector& size, const NumericVector& alpha, const NumericVector& beta) { typedef SEXP(*Ptr_cpp_rbnbinom)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rbnbinom p_cpp_rbnbinom = NULL; if (p_cpp_rbnbinom == NULL) { validateSignature("NumericVector(*cpp_rbnbinom)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rbnbinom = (Ptr_cpp_rbnbinom)R_GetCCallable("extraDistr", "_extraDistr_cpp_rbnbinom"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rbnbinom(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dbetapr(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& sigma, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dbetapr)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dbetapr p_cpp_dbetapr = NULL; if (p_cpp_dbetapr == NULL) { validateSignature("NumericVector(*cpp_dbetapr)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dbetapr = (Ptr_cpp_dbetapr)R_GetCCallable("extraDistr", "_extraDistr_cpp_dbetapr"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dbetapr(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pbetapr(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pbetapr)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pbetapr p_cpp_pbetapr = NULL; if (p_cpp_pbetapr == NULL) { validateSignature("NumericVector(*cpp_pbetapr)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pbetapr = (Ptr_cpp_pbetapr)R_GetCCallable("extraDistr", "_extraDistr_cpp_pbetapr"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pbetapr(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qbetapr(const NumericVector& p, const NumericVector& alpha, const NumericVector& beta, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qbetapr)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qbetapr p_cpp_qbetapr = NULL; if (p_cpp_qbetapr == NULL) { validateSignature("NumericVector(*cpp_qbetapr)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qbetapr = (Ptr_cpp_qbetapr)R_GetCCallable("extraDistr", "_extraDistr_cpp_qbetapr"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qbetapr(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rbetapr(const int& n, const NumericVector& alpha, const NumericVector& beta, const NumericVector& sigma) { typedef SEXP(*Ptr_cpp_rbetapr)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rbetapr p_cpp_rbetapr = NULL; if (p_cpp_rbetapr == NULL) { validateSignature("NumericVector(*cpp_rbetapr)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rbetapr = (Ptr_cpp_rbetapr)R_GetCCallable("extraDistr", "_extraDistr_cpp_rbetapr"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rbetapr(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(sigma))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dbhatt(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& a, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dbhatt)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dbhatt p_cpp_dbhatt = NULL; if (p_cpp_dbhatt == NULL) { validateSignature("NumericVector(*cpp_dbhatt)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dbhatt = (Ptr_cpp_dbhatt)R_GetCCallable("extraDistr", "_extraDistr_cpp_dbhatt"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dbhatt(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pbhatt(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& a, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pbhatt)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pbhatt p_cpp_pbhatt = NULL; if (p_cpp_pbhatt == NULL) { validateSignature("NumericVector(*cpp_pbhatt)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pbhatt = (Ptr_cpp_pbhatt)R_GetCCallable("extraDistr", "_extraDistr_cpp_pbhatt"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pbhatt(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rbhatt(const int& n, const NumericVector& mu, const NumericVector& sigma, const NumericVector& a) { typedef SEXP(*Ptr_cpp_rbhatt)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rbhatt p_cpp_rbhatt = NULL; if (p_cpp_rbhatt == NULL) { validateSignature("NumericVector(*cpp_rbhatt)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rbhatt = (Ptr_cpp_rbhatt)R_GetCCallable("extraDistr", "_extraDistr_cpp_rbhatt"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rbhatt(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(a))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dfatigue(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& mu, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dfatigue)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dfatigue p_cpp_dfatigue = NULL; if (p_cpp_dfatigue == NULL) { validateSignature("NumericVector(*cpp_dfatigue)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dfatigue = (Ptr_cpp_dfatigue)R_GetCCallable("extraDistr", "_extraDistr_cpp_dfatigue"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dfatigue(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pfatigue(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& mu, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pfatigue)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pfatigue p_cpp_pfatigue = NULL; if (p_cpp_pfatigue == NULL) { validateSignature("NumericVector(*cpp_pfatigue)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pfatigue = (Ptr_cpp_pfatigue)R_GetCCallable("extraDistr", "_extraDistr_cpp_pfatigue"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pfatigue(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qfatigue(const NumericVector& p, const NumericVector& alpha, const NumericVector& beta, const NumericVector& mu, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qfatigue)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qfatigue p_cpp_qfatigue = NULL; if (p_cpp_qfatigue == NULL) { validateSignature("NumericVector(*cpp_qfatigue)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qfatigue = (Ptr_cpp_qfatigue)R_GetCCallable("extraDistr", "_extraDistr_cpp_qfatigue"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qfatigue(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rfatigue(const int& n, const NumericVector& alpha, const NumericVector& beta, const NumericVector& mu) { typedef SEXP(*Ptr_cpp_rfatigue)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rfatigue p_cpp_rfatigue = NULL; if (p_cpp_rfatigue == NULL) { validateSignature("NumericVector(*cpp_rfatigue)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rfatigue = (Ptr_cpp_rfatigue)R_GetCCallable("extraDistr", "_extraDistr_cpp_rfatigue"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rfatigue(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(mu))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dbnorm(const NumericVector& x, const NumericVector& y, const NumericVector& mu1, const NumericVector& mu2, const NumericVector& sigma1, const NumericVector& sigma2, const NumericVector& rho, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dbnorm)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dbnorm p_cpp_dbnorm = NULL; if (p_cpp_dbnorm == NULL) { validateSignature("NumericVector(*cpp_dbnorm)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dbnorm = (Ptr_cpp_dbnorm)R_GetCCallable("extraDistr", "_extraDistr_cpp_dbnorm"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dbnorm(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(y)), Shield(Rcpp::wrap(mu1)), Shield(Rcpp::wrap(mu2)), Shield(Rcpp::wrap(sigma1)), Shield(Rcpp::wrap(sigma2)), Shield(Rcpp::wrap(rho)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericMatrix cpp_rbnorm(const int& n, const NumericVector& mu1, const NumericVector& mu2, const NumericVector& sigma1, const NumericVector& sigma2, const NumericVector& rho) { typedef SEXP(*Ptr_cpp_rbnorm)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rbnorm p_cpp_rbnorm = NULL; if (p_cpp_rbnorm == NULL) { validateSignature("NumericMatrix(*cpp_rbnorm)(const int&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rbnorm = (Ptr_cpp_rbnorm)R_GetCCallable("extraDistr", "_extraDistr_cpp_rbnorm"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rbnorm(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(mu1)), Shield(Rcpp::wrap(mu2)), Shield(Rcpp::wrap(sigma1)), Shield(Rcpp::wrap(sigma2)), Shield(Rcpp::wrap(rho))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dbpois(const NumericVector& x, const NumericVector& y, const NumericVector& a, const NumericVector& b, const NumericVector& c, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dbpois)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dbpois p_cpp_dbpois = NULL; if (p_cpp_dbpois == NULL) { validateSignature("NumericVector(*cpp_dbpois)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dbpois = (Ptr_cpp_dbpois)R_GetCCallable("extraDistr", "_extraDistr_cpp_dbpois"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dbpois(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(y)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(c)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericMatrix cpp_rbpois(const int& n, const NumericVector& a, const NumericVector& b, const NumericVector& c) { typedef SEXP(*Ptr_cpp_rbpois)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rbpois p_cpp_rbpois = NULL; if (p_cpp_rbpois == NULL) { validateSignature("NumericMatrix(*cpp_rbpois)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rbpois = (Ptr_cpp_rbpois)R_GetCCallable("extraDistr", "_extraDistr_cpp_rbpois"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rbpois(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(c))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rcatlp(const int& n, const NumericMatrix& log_prob) { typedef SEXP(*Ptr_cpp_rcatlp)(SEXP,SEXP); static Ptr_cpp_rcatlp p_cpp_rcatlp = NULL; if (p_cpp_rcatlp == NULL) { validateSignature("NumericVector(*cpp_rcatlp)(const int&,const NumericMatrix&)"); p_cpp_rcatlp = (Ptr_cpp_rcatlp)R_GetCCallable("extraDistr", "_extraDistr_cpp_rcatlp"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rcatlp(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dcat(const NumericVector& x, const NumericMatrix& prob, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dcat)(SEXP,SEXP,SEXP); static Ptr_cpp_dcat p_cpp_dcat = NULL; if (p_cpp_dcat == NULL) { validateSignature("NumericVector(*cpp_dcat)(const NumericVector&,const NumericMatrix&,const bool&)"); p_cpp_dcat = (Ptr_cpp_dcat)R_GetCCallable("extraDistr", "_extraDistr_cpp_dcat"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dcat(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pcat(const NumericVector& x, const NumericMatrix& prob, bool lower_tail = true, bool log_prob = false) { typedef SEXP(*Ptr_cpp_pcat)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pcat p_cpp_pcat = NULL; if (p_cpp_pcat == NULL) { validateSignature("NumericVector(*cpp_pcat)(const NumericVector&,const NumericMatrix&,bool,bool)"); p_cpp_pcat = (Ptr_cpp_pcat)R_GetCCallable("extraDistr", "_extraDistr_cpp_pcat"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pcat(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qcat(const NumericVector& p, const NumericMatrix& prob, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qcat)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qcat p_cpp_qcat = NULL; if (p_cpp_qcat == NULL) { validateSignature("NumericVector(*cpp_qcat)(const NumericVector&,const NumericMatrix&,const bool&,const bool&)"); p_cpp_qcat = (Ptr_cpp_qcat)R_GetCCallable("extraDistr", "_extraDistr_cpp_qcat"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qcat(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rcat(const int& n, const NumericMatrix& prob) { typedef SEXP(*Ptr_cpp_rcat)(SEXP,SEXP); static Ptr_cpp_rcat p_cpp_rcat = NULL; if (p_cpp_rcat == NULL) { validateSignature("NumericVector(*cpp_rcat)(const int&,const NumericMatrix&)"); p_cpp_rcat = (Ptr_cpp_rcat)R_GetCCallable("extraDistr", "_extraDistr_cpp_rcat"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rcat(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_ddirichlet(const NumericMatrix& x, const NumericMatrix& alpha, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_ddirichlet)(SEXP,SEXP,SEXP); static Ptr_cpp_ddirichlet p_cpp_ddirichlet = NULL; if (p_cpp_ddirichlet == NULL) { validateSignature("NumericVector(*cpp_ddirichlet)(const NumericMatrix&,const NumericMatrix&,const bool&)"); p_cpp_ddirichlet = (Ptr_cpp_ddirichlet)R_GetCCallable("extraDistr", "_extraDistr_cpp_ddirichlet"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_ddirichlet(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericMatrix cpp_rdirichlet(const int& n, const NumericMatrix& alpha) { typedef SEXP(*Ptr_cpp_rdirichlet)(SEXP,SEXP); static Ptr_cpp_rdirichlet p_cpp_rdirichlet = NULL; if (p_cpp_rdirichlet == NULL) { validateSignature("NumericMatrix(*cpp_rdirichlet)(const int&,const NumericMatrix&)"); p_cpp_rdirichlet = (Ptr_cpp_rdirichlet)R_GetCCallable("extraDistr", "_extraDistr_cpp_rdirichlet"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rdirichlet(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(alpha))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_ddirmnom(const NumericMatrix& x, const NumericVector& size, const NumericMatrix& alpha, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_ddirmnom)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_ddirmnom p_cpp_ddirmnom = NULL; if (p_cpp_ddirmnom == NULL) { validateSignature("NumericVector(*cpp_ddirmnom)(const NumericMatrix&,const NumericVector&,const NumericMatrix&,const bool&)"); p_cpp_ddirmnom = (Ptr_cpp_ddirmnom)R_GetCCallable("extraDistr", "_extraDistr_cpp_ddirmnom"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_ddirmnom(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericMatrix cpp_rdirmnom(const int& n, const NumericVector& size, const NumericMatrix& alpha) { typedef SEXP(*Ptr_cpp_rdirmnom)(SEXP,SEXP,SEXP); static Ptr_cpp_rdirmnom p_cpp_rdirmnom = NULL; if (p_cpp_rdirmnom == NULL) { validateSignature("NumericMatrix(*cpp_rdirmnom)(const int&,const NumericVector&,const NumericMatrix&)"); p_cpp_rdirmnom = (Ptr_cpp_rdirmnom)R_GetCCallable("extraDistr", "_extraDistr_cpp_rdirmnom"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rdirmnom(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(alpha))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_ddgamma(const NumericVector& x, const NumericVector& shape, const NumericVector& scale, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_ddgamma)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_ddgamma p_cpp_ddgamma = NULL; if (p_cpp_ddgamma == NULL) { validateSignature("NumericVector(*cpp_ddgamma)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_ddgamma = (Ptr_cpp_ddgamma)R_GetCCallable("extraDistr", "_extraDistr_cpp_ddgamma"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_ddgamma(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(shape)), Shield(Rcpp::wrap(scale)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_ddlaplace(const NumericVector& x, const NumericVector& location, const NumericVector& scale, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_ddlaplace)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_ddlaplace p_cpp_ddlaplace = NULL; if (p_cpp_ddlaplace == NULL) { validateSignature("NumericVector(*cpp_ddlaplace)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_ddlaplace = (Ptr_cpp_ddlaplace)R_GetCCallable("extraDistr", "_extraDistr_cpp_ddlaplace"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_ddlaplace(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(location)), Shield(Rcpp::wrap(scale)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pdlaplace(const NumericVector& x, const NumericVector& location, const NumericVector& scale, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pdlaplace)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pdlaplace p_cpp_pdlaplace = NULL; if (p_cpp_pdlaplace == NULL) { validateSignature("NumericVector(*cpp_pdlaplace)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pdlaplace = (Ptr_cpp_pdlaplace)R_GetCCallable("extraDistr", "_extraDistr_cpp_pdlaplace"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pdlaplace(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(location)), Shield(Rcpp::wrap(scale)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rdlaplace(const int& n, const NumericVector& location, const NumericVector& scale) { typedef SEXP(*Ptr_cpp_rdlaplace)(SEXP,SEXP,SEXP); static Ptr_cpp_rdlaplace p_cpp_rdlaplace = NULL; if (p_cpp_rdlaplace == NULL) { validateSignature("NumericVector(*cpp_rdlaplace)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rdlaplace = (Ptr_cpp_rdlaplace)R_GetCCallable("extraDistr", "_extraDistr_cpp_rdlaplace"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rdlaplace(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(location)), Shield(Rcpp::wrap(scale))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_ddnorm(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_ddnorm)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_ddnorm p_cpp_ddnorm = NULL; if (p_cpp_ddnorm == NULL) { validateSignature("NumericVector(*cpp_ddnorm)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_ddnorm = (Ptr_cpp_ddnorm)R_GetCCallable("extraDistr", "_extraDistr_cpp_ddnorm"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_ddnorm(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_ddunif(const NumericVector& x, const NumericVector& min, const NumericVector& max, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_ddunif)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_ddunif p_cpp_ddunif = NULL; if (p_cpp_ddunif == NULL) { validateSignature("NumericVector(*cpp_ddunif)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_ddunif = (Ptr_cpp_ddunif)R_GetCCallable("extraDistr", "_extraDistr_cpp_ddunif"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_ddunif(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(min)), Shield(Rcpp::wrap(max)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pdunif(const NumericVector& x, const NumericVector& min, const NumericVector& max, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pdunif)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pdunif p_cpp_pdunif = NULL; if (p_cpp_pdunif == NULL) { validateSignature("NumericVector(*cpp_pdunif)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pdunif = (Ptr_cpp_pdunif)R_GetCCallable("extraDistr", "_extraDistr_cpp_pdunif"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pdunif(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(min)), Shield(Rcpp::wrap(max)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qdunif(const NumericVector& p, const NumericVector& min, const NumericVector& max, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qdunif)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qdunif p_cpp_qdunif = NULL; if (p_cpp_qdunif == NULL) { validateSignature("NumericVector(*cpp_qdunif)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qdunif = (Ptr_cpp_qdunif)R_GetCCallable("extraDistr", "_extraDistr_cpp_qdunif"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qdunif(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(min)), Shield(Rcpp::wrap(max)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rdunif(const int& n, const NumericVector& min, const NumericVector& max) { typedef SEXP(*Ptr_cpp_rdunif)(SEXP,SEXP,SEXP); static Ptr_cpp_rdunif p_cpp_rdunif = NULL; if (p_cpp_rdunif == NULL) { validateSignature("NumericVector(*cpp_rdunif)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rdunif = (Ptr_cpp_rdunif)R_GetCCallable("extraDistr", "_extraDistr_cpp_rdunif"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rdunif(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(min)), Shield(Rcpp::wrap(max))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_ddweibull(const NumericVector& x, const NumericVector& q, const NumericVector& beta, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_ddweibull)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_ddweibull p_cpp_ddweibull = NULL; if (p_cpp_ddweibull == NULL) { validateSignature("NumericVector(*cpp_ddweibull)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_ddweibull = (Ptr_cpp_ddweibull)R_GetCCallable("extraDistr", "_extraDistr_cpp_ddweibull"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_ddweibull(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(q)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pdweibull(const NumericVector& x, const NumericVector& q, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pdweibull)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pdweibull p_cpp_pdweibull = NULL; if (p_cpp_pdweibull == NULL) { validateSignature("NumericVector(*cpp_pdweibull)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pdweibull = (Ptr_cpp_pdweibull)R_GetCCallable("extraDistr", "_extraDistr_cpp_pdweibull"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pdweibull(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(q)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qdweibull(const NumericVector& p, const NumericVector& q, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qdweibull)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qdweibull p_cpp_qdweibull = NULL; if (p_cpp_qdweibull == NULL) { validateSignature("NumericVector(*cpp_qdweibull)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qdweibull = (Ptr_cpp_qdweibull)R_GetCCallable("extraDistr", "_extraDistr_cpp_qdweibull"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qdweibull(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(q)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rdweibull(const int& n, const NumericVector& q, const NumericVector& beta) { typedef SEXP(*Ptr_cpp_rdweibull)(SEXP,SEXP,SEXP); static Ptr_cpp_rdweibull p_cpp_rdweibull = NULL; if (p_cpp_rdweibull == NULL) { validateSignature("NumericVector(*cpp_rdweibull)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rdweibull = (Ptr_cpp_rdweibull)R_GetCCallable("extraDistr", "_extraDistr_cpp_rdweibull"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rdweibull(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(q)), Shield(Rcpp::wrap(beta))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dfrechet(const NumericVector& x, const NumericVector& lambda, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dfrechet)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dfrechet p_cpp_dfrechet = NULL; if (p_cpp_dfrechet == NULL) { validateSignature("NumericVector(*cpp_dfrechet)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dfrechet = (Ptr_cpp_dfrechet)R_GetCCallable("extraDistr", "_extraDistr_cpp_dfrechet"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dfrechet(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pfrechet(const NumericVector& x, const NumericVector& lambda, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pfrechet)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pfrechet p_cpp_pfrechet = NULL; if (p_cpp_pfrechet == NULL) { validateSignature("NumericVector(*cpp_pfrechet)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pfrechet = (Ptr_cpp_pfrechet)R_GetCCallable("extraDistr", "_extraDistr_cpp_pfrechet"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pfrechet(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qfrechet(const NumericVector& p, const NumericVector& lambda, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qfrechet)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qfrechet p_cpp_qfrechet = NULL; if (p_cpp_qfrechet == NULL) { validateSignature("NumericVector(*cpp_qfrechet)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qfrechet = (Ptr_cpp_qfrechet)R_GetCCallable("extraDistr", "_extraDistr_cpp_qfrechet"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qfrechet(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rfrechet(const int& n, const NumericVector& lambda, const NumericVector& mu, const NumericVector& sigma) { typedef SEXP(*Ptr_cpp_rfrechet)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rfrechet p_cpp_rfrechet = NULL; if (p_cpp_rfrechet == NULL) { validateSignature("NumericVector(*cpp_rfrechet)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rfrechet = (Ptr_cpp_rfrechet)R_GetCCallable("extraDistr", "_extraDistr_cpp_rfrechet"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rfrechet(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dgpois(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dgpois)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dgpois p_cpp_dgpois = NULL; if (p_cpp_dgpois == NULL) { validateSignature("NumericVector(*cpp_dgpois)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dgpois = (Ptr_cpp_dgpois)R_GetCCallable("extraDistr", "_extraDistr_cpp_dgpois"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dgpois(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pgpois(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pgpois)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pgpois p_cpp_pgpois = NULL; if (p_cpp_pgpois == NULL) { validateSignature("NumericVector(*cpp_pgpois)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pgpois = (Ptr_cpp_pgpois)R_GetCCallable("extraDistr", "_extraDistr_cpp_pgpois"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pgpois(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rgpois(const int& n, const NumericVector& alpha, const NumericVector& beta) { typedef SEXP(*Ptr_cpp_rgpois)(SEXP,SEXP,SEXP); static Ptr_cpp_rgpois p_cpp_rgpois = NULL; if (p_cpp_rgpois == NULL) { validateSignature("NumericVector(*cpp_rgpois)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rgpois = (Ptr_cpp_rgpois)R_GetCCallable("extraDistr", "_extraDistr_cpp_rgpois"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rgpois(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dgev(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dgev)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dgev p_cpp_dgev = NULL; if (p_cpp_dgev == NULL) { validateSignature("NumericVector(*cpp_dgev)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dgev = (Ptr_cpp_dgev)R_GetCCallable("extraDistr", "_extraDistr_cpp_dgev"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dgev(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(xi)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pgev(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi, bool lower_tail = true, bool log_prob = false) { typedef SEXP(*Ptr_cpp_pgev)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pgev p_cpp_pgev = NULL; if (p_cpp_pgev == NULL) { validateSignature("NumericVector(*cpp_pgev)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,bool,bool)"); p_cpp_pgev = (Ptr_cpp_pgev)R_GetCCallable("extraDistr", "_extraDistr_cpp_pgev"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pgev(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(xi)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qgev(const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi, bool lower_tail = true, bool log_prob = false) { typedef SEXP(*Ptr_cpp_qgev)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qgev p_cpp_qgev = NULL; if (p_cpp_qgev == NULL) { validateSignature("NumericVector(*cpp_qgev)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,bool,bool)"); p_cpp_qgev = (Ptr_cpp_qgev)R_GetCCallable("extraDistr", "_extraDistr_cpp_qgev"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qgev(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(xi)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rgev(const int& n, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi) { typedef SEXP(*Ptr_cpp_rgev)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rgev p_cpp_rgev = NULL; if (p_cpp_rgev == NULL) { validateSignature("NumericVector(*cpp_rgev)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rgev = (Ptr_cpp_rgev)R_GetCCallable("extraDistr", "_extraDistr_cpp_rgev"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rgev(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(xi))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dgompertz(const NumericVector& x, const NumericVector& a, const NumericVector& b, bool log_prob = false) { typedef SEXP(*Ptr_cpp_dgompertz)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dgompertz p_cpp_dgompertz = NULL; if (p_cpp_dgompertz == NULL) { validateSignature("NumericVector(*cpp_dgompertz)(const NumericVector&,const NumericVector&,const NumericVector&,bool)"); p_cpp_dgompertz = (Ptr_cpp_dgompertz)R_GetCCallable("extraDistr", "_extraDistr_cpp_dgompertz"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dgompertz(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pgompertz(const NumericVector& x, const NumericVector& a, const NumericVector& b, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pgompertz)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pgompertz p_cpp_pgompertz = NULL; if (p_cpp_pgompertz == NULL) { validateSignature("NumericVector(*cpp_pgompertz)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pgompertz = (Ptr_cpp_pgompertz)R_GetCCallable("extraDistr", "_extraDistr_cpp_pgompertz"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pgompertz(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qgompertz(const NumericVector& p, const NumericVector& a, const NumericVector& b, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qgompertz)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qgompertz p_cpp_qgompertz = NULL; if (p_cpp_qgompertz == NULL) { validateSignature("NumericVector(*cpp_qgompertz)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qgompertz = (Ptr_cpp_qgompertz)R_GetCCallable("extraDistr", "_extraDistr_cpp_qgompertz"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qgompertz(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rgompertz(const int& n, const NumericVector& a, const NumericVector& b) { typedef SEXP(*Ptr_cpp_rgompertz)(SEXP,SEXP,SEXP); static Ptr_cpp_rgompertz p_cpp_rgompertz = NULL; if (p_cpp_rgompertz == NULL) { validateSignature("NumericVector(*cpp_rgompertz)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rgompertz = (Ptr_cpp_rgompertz)R_GetCCallable("extraDistr", "_extraDistr_cpp_rgompertz"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rgompertz(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dgpd(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dgpd)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dgpd p_cpp_dgpd = NULL; if (p_cpp_dgpd == NULL) { validateSignature("NumericVector(*cpp_dgpd)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dgpd = (Ptr_cpp_dgpd)R_GetCCallable("extraDistr", "_extraDistr_cpp_dgpd"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dgpd(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(xi)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pgpd(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pgpd)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pgpd p_cpp_pgpd = NULL; if (p_cpp_pgpd == NULL) { validateSignature("NumericVector(*cpp_pgpd)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pgpd = (Ptr_cpp_pgpd)R_GetCCallable("extraDistr", "_extraDistr_cpp_pgpd"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pgpd(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(xi)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qgpd(const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qgpd)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qgpd p_cpp_qgpd = NULL; if (p_cpp_qgpd == NULL) { validateSignature("NumericVector(*cpp_qgpd)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qgpd = (Ptr_cpp_qgpd)R_GetCCallable("extraDistr", "_extraDistr_cpp_qgpd"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qgpd(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(xi)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rgpd(const int& n, const NumericVector& mu, const NumericVector& sigma, const NumericVector& xi) { typedef SEXP(*Ptr_cpp_rgpd)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rgpd p_cpp_rgpd = NULL; if (p_cpp_rgpd == NULL) { validateSignature("NumericVector(*cpp_rgpd)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rgpd = (Ptr_cpp_rgpd)R_GetCCallable("extraDistr", "_extraDistr_cpp_rgpd"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rgpd(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(xi))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dgumbel(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dgumbel)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dgumbel p_cpp_dgumbel = NULL; if (p_cpp_dgumbel == NULL) { validateSignature("NumericVector(*cpp_dgumbel)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dgumbel = (Ptr_cpp_dgumbel)R_GetCCallable("extraDistr", "_extraDistr_cpp_dgumbel"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dgumbel(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pgumbel(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pgumbel)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pgumbel p_cpp_pgumbel = NULL; if (p_cpp_pgumbel == NULL) { validateSignature("NumericVector(*cpp_pgumbel)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pgumbel = (Ptr_cpp_pgumbel)R_GetCCallable("extraDistr", "_extraDistr_cpp_pgumbel"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pgumbel(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qgumbel(const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qgumbel)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qgumbel p_cpp_qgumbel = NULL; if (p_cpp_qgumbel == NULL) { validateSignature("NumericVector(*cpp_qgumbel)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qgumbel = (Ptr_cpp_qgumbel)R_GetCCallable("extraDistr", "_extraDistr_cpp_qgumbel"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qgumbel(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rgumbel(const int& n, const NumericVector& mu, const NumericVector& sigma) { typedef SEXP(*Ptr_cpp_rgumbel)(SEXP,SEXP,SEXP); static Ptr_cpp_rgumbel p_cpp_rgumbel = NULL; if (p_cpp_rgumbel == NULL) { validateSignature("NumericVector(*cpp_rgumbel)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rgumbel = (Ptr_cpp_rgumbel)R_GetCCallable("extraDistr", "_extraDistr_cpp_rgumbel"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rgumbel(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dhcauchy(const NumericVector& x, const NumericVector& sigma, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dhcauchy)(SEXP,SEXP,SEXP); static Ptr_cpp_dhcauchy p_cpp_dhcauchy = NULL; if (p_cpp_dhcauchy == NULL) { validateSignature("NumericVector(*cpp_dhcauchy)(const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dhcauchy = (Ptr_cpp_dhcauchy)R_GetCCallable("extraDistr", "_extraDistr_cpp_dhcauchy"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dhcauchy(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_phcauchy(const NumericVector& x, const NumericVector& sigma, bool lower_tail = true, bool log_prob = false) { typedef SEXP(*Ptr_cpp_phcauchy)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_phcauchy p_cpp_phcauchy = NULL; if (p_cpp_phcauchy == NULL) { validateSignature("NumericVector(*cpp_phcauchy)(const NumericVector&,const NumericVector&,bool,bool)"); p_cpp_phcauchy = (Ptr_cpp_phcauchy)R_GetCCallable("extraDistr", "_extraDistr_cpp_phcauchy"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_phcauchy(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qhcauchy(const NumericVector& p, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qhcauchy)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qhcauchy p_cpp_qhcauchy = NULL; if (p_cpp_qhcauchy == NULL) { validateSignature("NumericVector(*cpp_qhcauchy)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qhcauchy = (Ptr_cpp_qhcauchy)R_GetCCallable("extraDistr", "_extraDistr_cpp_qhcauchy"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qhcauchy(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rhcauchy(const int& n, const NumericVector& sigma) { typedef SEXP(*Ptr_cpp_rhcauchy)(SEXP,SEXP); static Ptr_cpp_rhcauchy p_cpp_rhcauchy = NULL; if (p_cpp_rhcauchy == NULL) { validateSignature("NumericVector(*cpp_rhcauchy)(const int&,const NumericVector&)"); p_cpp_rhcauchy = (Ptr_cpp_rhcauchy)R_GetCCallable("extraDistr", "_extraDistr_cpp_rhcauchy"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rhcauchy(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(sigma))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dhnorm(const NumericVector& x, const NumericVector& sigma, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dhnorm)(SEXP,SEXP,SEXP); static Ptr_cpp_dhnorm p_cpp_dhnorm = NULL; if (p_cpp_dhnorm == NULL) { validateSignature("NumericVector(*cpp_dhnorm)(const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dhnorm = (Ptr_cpp_dhnorm)R_GetCCallable("extraDistr", "_extraDistr_cpp_dhnorm"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dhnorm(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_phnorm(const NumericVector& x, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_phnorm)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_phnorm p_cpp_phnorm = NULL; if (p_cpp_phnorm == NULL) { validateSignature("NumericVector(*cpp_phnorm)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_phnorm = (Ptr_cpp_phnorm)R_GetCCallable("extraDistr", "_extraDistr_cpp_phnorm"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_phnorm(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qhnorm(const NumericVector& p, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qhnorm)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qhnorm p_cpp_qhnorm = NULL; if (p_cpp_qhnorm == NULL) { validateSignature("NumericVector(*cpp_qhnorm)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qhnorm = (Ptr_cpp_qhnorm)R_GetCCallable("extraDistr", "_extraDistr_cpp_qhnorm"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qhnorm(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rhnorm(const int& n, const NumericVector& sigma) { typedef SEXP(*Ptr_cpp_rhnorm)(SEXP,SEXP); static Ptr_cpp_rhnorm p_cpp_rhnorm = NULL; if (p_cpp_rhnorm == NULL) { validateSignature("NumericVector(*cpp_rhnorm)(const int&,const NumericVector&)"); p_cpp_rhnorm = (Ptr_cpp_rhnorm)R_GetCCallable("extraDistr", "_extraDistr_cpp_rhnorm"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rhnorm(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(sigma))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dht(const NumericVector& x, const NumericVector& nu, const NumericVector& sigma, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dht)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dht p_cpp_dht = NULL; if (p_cpp_dht == NULL) { validateSignature("NumericVector(*cpp_dht)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dht = (Ptr_cpp_dht)R_GetCCallable("extraDistr", "_extraDistr_cpp_dht"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dht(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(nu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pht(const NumericVector& x, const NumericVector& nu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pht)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pht p_cpp_pht = NULL; if (p_cpp_pht == NULL) { validateSignature("NumericVector(*cpp_pht)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pht = (Ptr_cpp_pht)R_GetCCallable("extraDistr", "_extraDistr_cpp_pht"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pht(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(nu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qht(const NumericVector& p, const NumericVector& nu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qht)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qht p_cpp_qht = NULL; if (p_cpp_qht == NULL) { validateSignature("NumericVector(*cpp_qht)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qht = (Ptr_cpp_qht)R_GetCCallable("extraDistr", "_extraDistr_cpp_qht"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qht(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(nu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rht(const int& n, const NumericVector& nu, const NumericVector& sigma) { typedef SEXP(*Ptr_cpp_rht)(SEXP,SEXP,SEXP); static Ptr_cpp_rht p_cpp_rht = NULL; if (p_cpp_rht == NULL) { validateSignature("NumericVector(*cpp_rht)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rht = (Ptr_cpp_rht)R_GetCCallable("extraDistr", "_extraDistr_cpp_rht"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rht(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(nu)), Shield(Rcpp::wrap(sigma))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dhuber(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& epsilon, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dhuber)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dhuber p_cpp_dhuber = NULL; if (p_cpp_dhuber == NULL) { validateSignature("NumericVector(*cpp_dhuber)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dhuber = (Ptr_cpp_dhuber)R_GetCCallable("extraDistr", "_extraDistr_cpp_dhuber"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dhuber(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(epsilon)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_phuber(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& epsilon, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_phuber)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_phuber p_cpp_phuber = NULL; if (p_cpp_phuber == NULL) { validateSignature("NumericVector(*cpp_phuber)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_phuber = (Ptr_cpp_phuber)R_GetCCallable("extraDistr", "_extraDistr_cpp_phuber"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_phuber(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(epsilon)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qhuber(const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const NumericVector& epsilon, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qhuber)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qhuber p_cpp_qhuber = NULL; if (p_cpp_qhuber == NULL) { validateSignature("NumericVector(*cpp_qhuber)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qhuber = (Ptr_cpp_qhuber)R_GetCCallable("extraDistr", "_extraDistr_cpp_qhuber"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qhuber(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(epsilon)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rhuber(const int& n, const NumericVector& mu, const NumericVector& sigma, const NumericVector& epsilon) { typedef SEXP(*Ptr_cpp_rhuber)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rhuber p_cpp_rhuber = NULL; if (p_cpp_rhuber == NULL) { validateSignature("NumericVector(*cpp_rhuber)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rhuber = (Ptr_cpp_rhuber)R_GetCCallable("extraDistr", "_extraDistr_cpp_rhuber"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rhuber(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(epsilon))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dinvgamma(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dinvgamma)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dinvgamma p_cpp_dinvgamma = NULL; if (p_cpp_dinvgamma == NULL) { validateSignature("NumericVector(*cpp_dinvgamma)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dinvgamma = (Ptr_cpp_dinvgamma)R_GetCCallable("extraDistr", "_extraDistr_cpp_dinvgamma"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dinvgamma(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pinvgamma(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pinvgamma)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pinvgamma p_cpp_pinvgamma = NULL; if (p_cpp_pinvgamma == NULL) { validateSignature("NumericVector(*cpp_pinvgamma)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pinvgamma = (Ptr_cpp_pinvgamma)R_GetCCallable("extraDistr", "_extraDistr_cpp_pinvgamma"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pinvgamma(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dkumar(const NumericVector& x, const NumericVector& a, const NumericVector& b, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dkumar)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dkumar p_cpp_dkumar = NULL; if (p_cpp_dkumar == NULL) { validateSignature("NumericVector(*cpp_dkumar)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dkumar = (Ptr_cpp_dkumar)R_GetCCallable("extraDistr", "_extraDistr_cpp_dkumar"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dkumar(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pkumar(const NumericVector& x, const NumericVector& a, const NumericVector& b, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pkumar)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pkumar p_cpp_pkumar = NULL; if (p_cpp_pkumar == NULL) { validateSignature("NumericVector(*cpp_pkumar)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pkumar = (Ptr_cpp_pkumar)R_GetCCallable("extraDistr", "_extraDistr_cpp_pkumar"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pkumar(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qkumar(const NumericVector& p, const NumericVector& a, const NumericVector& b, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qkumar)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qkumar p_cpp_qkumar = NULL; if (p_cpp_qkumar == NULL) { validateSignature("NumericVector(*cpp_qkumar)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qkumar = (Ptr_cpp_qkumar)R_GetCCallable("extraDistr", "_extraDistr_cpp_qkumar"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qkumar(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rkumar(const int& n, const NumericVector& a, const NumericVector& b) { typedef SEXP(*Ptr_cpp_rkumar)(SEXP,SEXP,SEXP); static Ptr_cpp_rkumar p_cpp_rkumar = NULL; if (p_cpp_rkumar == NULL) { validateSignature("NumericVector(*cpp_rkumar)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rkumar = (Ptr_cpp_rkumar)R_GetCCallable("extraDistr", "_extraDistr_cpp_rkumar"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rkumar(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dlaplace(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dlaplace)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dlaplace p_cpp_dlaplace = NULL; if (p_cpp_dlaplace == NULL) { validateSignature("NumericVector(*cpp_dlaplace)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dlaplace = (Ptr_cpp_dlaplace)R_GetCCallable("extraDistr", "_extraDistr_cpp_dlaplace"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dlaplace(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_plaplace(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_plaplace)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_plaplace p_cpp_plaplace = NULL; if (p_cpp_plaplace == NULL) { validateSignature("NumericVector(*cpp_plaplace)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_plaplace = (Ptr_cpp_plaplace)R_GetCCallable("extraDistr", "_extraDistr_cpp_plaplace"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_plaplace(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qlaplace(const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qlaplace)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qlaplace p_cpp_qlaplace = NULL; if (p_cpp_qlaplace == NULL) { validateSignature("NumericVector(*cpp_qlaplace)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qlaplace = (Ptr_cpp_qlaplace)R_GetCCallable("extraDistr", "_extraDistr_cpp_qlaplace"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qlaplace(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rlaplace(const int& n, const NumericVector& mu, const NumericVector& sigma) { typedef SEXP(*Ptr_cpp_rlaplace)(SEXP,SEXP,SEXP); static Ptr_cpp_rlaplace p_cpp_rlaplace = NULL; if (p_cpp_rlaplace == NULL) { validateSignature("NumericVector(*cpp_rlaplace)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rlaplace = (Ptr_cpp_rlaplace)R_GetCCallable("extraDistr", "_extraDistr_cpp_rlaplace"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rlaplace(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dlst(const NumericVector& x, const NumericVector& nu, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dlst)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dlst p_cpp_dlst = NULL; if (p_cpp_dlst == NULL) { validateSignature("NumericVector(*cpp_dlst)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dlst = (Ptr_cpp_dlst)R_GetCCallable("extraDistr", "_extraDistr_cpp_dlst"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dlst(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(nu)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_plst(const NumericVector& x, const NumericVector& nu, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_plst)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_plst p_cpp_plst = NULL; if (p_cpp_plst == NULL) { validateSignature("NumericVector(*cpp_plst)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_plst = (Ptr_cpp_plst)R_GetCCallable("extraDistr", "_extraDistr_cpp_plst"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_plst(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(nu)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qlst(const NumericVector& p, const NumericVector& nu, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qlst)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qlst p_cpp_qlst = NULL; if (p_cpp_qlst == NULL) { validateSignature("NumericVector(*cpp_qlst)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qlst = (Ptr_cpp_qlst)R_GetCCallable("extraDistr", "_extraDistr_cpp_qlst"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qlst(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(nu)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rlst(const int& n, const NumericVector& nu, const NumericVector& mu, const NumericVector& sigma) { typedef SEXP(*Ptr_cpp_rlst)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rlst p_cpp_rlst = NULL; if (p_cpp_rlst == NULL) { validateSignature("NumericVector(*cpp_rlst)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rlst = (Ptr_cpp_rlst)R_GetCCallable("extraDistr", "_extraDistr_cpp_rlst"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rlst(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(nu)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dlgser(const NumericVector& x, const NumericVector& theta, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dlgser)(SEXP,SEXP,SEXP); static Ptr_cpp_dlgser p_cpp_dlgser = NULL; if (p_cpp_dlgser == NULL) { validateSignature("NumericVector(*cpp_dlgser)(const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dlgser = (Ptr_cpp_dlgser)R_GetCCallable("extraDistr", "_extraDistr_cpp_dlgser"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dlgser(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(theta)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_plgser(const NumericVector& x, const NumericVector& theta, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_plgser)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_plgser p_cpp_plgser = NULL; if (p_cpp_plgser == NULL) { validateSignature("NumericVector(*cpp_plgser)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_plgser = (Ptr_cpp_plgser)R_GetCCallable("extraDistr", "_extraDistr_cpp_plgser"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_plgser(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(theta)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qlgser(const NumericVector& p, const NumericVector& theta, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qlgser)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qlgser p_cpp_qlgser = NULL; if (p_cpp_qlgser == NULL) { validateSignature("NumericVector(*cpp_qlgser)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qlgser = (Ptr_cpp_qlgser)R_GetCCallable("extraDistr", "_extraDistr_cpp_qlgser"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qlgser(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(theta)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rlgser(const int& n, const NumericVector& theta) { typedef SEXP(*Ptr_cpp_rlgser)(SEXP,SEXP); static Ptr_cpp_rlgser p_cpp_rlgser = NULL; if (p_cpp_rlgser == NULL) { validateSignature("NumericVector(*cpp_rlgser)(const int&,const NumericVector&)"); p_cpp_rlgser = (Ptr_cpp_rlgser)R_GetCCallable("extraDistr", "_extraDistr_cpp_rlgser"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rlgser(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(theta))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dlomax(const NumericVector& x, const NumericVector& lambda, const NumericVector& kappa, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dlomax)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dlomax p_cpp_dlomax = NULL; if (p_cpp_dlomax == NULL) { validateSignature("NumericVector(*cpp_dlomax)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dlomax = (Ptr_cpp_dlomax)R_GetCCallable("extraDistr", "_extraDistr_cpp_dlomax"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dlomax(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(kappa)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_plomax(const NumericVector& x, const NumericVector& lambda, const NumericVector& kappa, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_plomax)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_plomax p_cpp_plomax = NULL; if (p_cpp_plomax == NULL) { validateSignature("NumericVector(*cpp_plomax)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_plomax = (Ptr_cpp_plomax)R_GetCCallable("extraDistr", "_extraDistr_cpp_plomax"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_plomax(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(kappa)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qlomax(const NumericVector& p, const NumericVector& lambda, const NumericVector& kappa, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qlomax)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qlomax p_cpp_qlomax = NULL; if (p_cpp_qlomax == NULL) { validateSignature("NumericVector(*cpp_qlomax)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qlomax = (Ptr_cpp_qlomax)R_GetCCallable("extraDistr", "_extraDistr_cpp_qlomax"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qlomax(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(kappa)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rlomax(const int& n, const NumericVector& lambda, const NumericVector& kappa) { typedef SEXP(*Ptr_cpp_rlomax)(SEXP,SEXP,SEXP); static Ptr_cpp_rlomax p_cpp_rlomax = NULL; if (p_cpp_rlomax == NULL) { validateSignature("NumericVector(*cpp_rlomax)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rlomax = (Ptr_cpp_rlomax)R_GetCCallable("extraDistr", "_extraDistr_cpp_rlomax"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rlomax(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(kappa))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dmixnorm(const NumericVector& x, const NumericMatrix& mu, const NumericMatrix& sigma, const NumericMatrix& alpha, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dmixnorm)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dmixnorm p_cpp_dmixnorm = NULL; if (p_cpp_dmixnorm == NULL) { validateSignature("NumericVector(*cpp_dmixnorm)(const NumericVector&,const NumericMatrix&,const NumericMatrix&,const NumericMatrix&,const bool&)"); p_cpp_dmixnorm = (Ptr_cpp_dmixnorm)R_GetCCallable("extraDistr", "_extraDistr_cpp_dmixnorm"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dmixnorm(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pmixnorm(const NumericVector& x, const NumericMatrix& mu, const NumericMatrix& sigma, const NumericMatrix& alpha, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pmixnorm)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pmixnorm p_cpp_pmixnorm = NULL; if (p_cpp_pmixnorm == NULL) { validateSignature("NumericVector(*cpp_pmixnorm)(const NumericVector&,const NumericMatrix&,const NumericMatrix&,const NumericMatrix&,const bool&,const bool&)"); p_cpp_pmixnorm = (Ptr_cpp_pmixnorm)R_GetCCallable("extraDistr", "_extraDistr_cpp_pmixnorm"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pmixnorm(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rmixnorm(const int& n, const NumericMatrix& mu, const NumericMatrix& sigma, const NumericMatrix& alpha) { typedef SEXP(*Ptr_cpp_rmixnorm)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rmixnorm p_cpp_rmixnorm = NULL; if (p_cpp_rmixnorm == NULL) { validateSignature("NumericVector(*cpp_rmixnorm)(const int&,const NumericMatrix&,const NumericMatrix&,const NumericMatrix&)"); p_cpp_rmixnorm = (Ptr_cpp_rmixnorm)R_GetCCallable("extraDistr", "_extraDistr_cpp_rmixnorm"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rmixnorm(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(alpha))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dmixpois(const NumericVector& x, const NumericMatrix& lambda, const NumericMatrix& alpha, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dmixpois)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dmixpois p_cpp_dmixpois = NULL; if (p_cpp_dmixpois == NULL) { validateSignature("NumericVector(*cpp_dmixpois)(const NumericVector&,const NumericMatrix&,const NumericMatrix&,const bool&)"); p_cpp_dmixpois = (Ptr_cpp_dmixpois)R_GetCCallable("extraDistr", "_extraDistr_cpp_dmixpois"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dmixpois(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pmixpois(const NumericVector& x, const NumericMatrix& lambda, const NumericMatrix& alpha, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pmixpois)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pmixpois p_cpp_pmixpois = NULL; if (p_cpp_pmixpois == NULL) { validateSignature("NumericVector(*cpp_pmixpois)(const NumericVector&,const NumericMatrix&,const NumericMatrix&,const bool&,const bool&)"); p_cpp_pmixpois = (Ptr_cpp_pmixpois)R_GetCCallable("extraDistr", "_extraDistr_cpp_pmixpois"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pmixpois(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rmixpois(const int& n, const NumericMatrix& lambda, const NumericMatrix& alpha) { typedef SEXP(*Ptr_cpp_rmixpois)(SEXP,SEXP,SEXP); static Ptr_cpp_rmixpois p_cpp_rmixpois = NULL; if (p_cpp_rmixpois == NULL) { validateSignature("NumericVector(*cpp_rmixpois)(const int&,const NumericMatrix&,const NumericMatrix&)"); p_cpp_rmixpois = (Ptr_cpp_rmixpois)R_GetCCallable("extraDistr", "_extraDistr_cpp_rmixpois"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rmixpois(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(alpha))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dmnom(const NumericMatrix& x, const NumericVector& size, const NumericMatrix& prob, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dmnom)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dmnom p_cpp_dmnom = NULL; if (p_cpp_dmnom == NULL) { validateSignature("NumericVector(*cpp_dmnom)(const NumericMatrix&,const NumericVector&,const NumericMatrix&,const bool&)"); p_cpp_dmnom = (Ptr_cpp_dmnom)R_GetCCallable("extraDistr", "_extraDistr_cpp_dmnom"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dmnom(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericMatrix cpp_rmnom(const int& n, const NumericVector& size, const NumericMatrix& prob) { typedef SEXP(*Ptr_cpp_rmnom)(SEXP,SEXP,SEXP); static Ptr_cpp_rmnom p_cpp_rmnom = NULL; if (p_cpp_rmnom == NULL) { validateSignature("NumericMatrix(*cpp_rmnom)(const int&,const NumericVector&,const NumericMatrix&)"); p_cpp_rmnom = (Ptr_cpp_rmnom)R_GetCCallable("extraDistr", "_extraDistr_cpp_rmnom"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rmnom(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dmvhyper(const NumericMatrix& x, const NumericMatrix& n, const NumericVector& k, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dmvhyper)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dmvhyper p_cpp_dmvhyper = NULL; if (p_cpp_dmvhyper == NULL) { validateSignature("NumericVector(*cpp_dmvhyper)(const NumericMatrix&,const NumericMatrix&,const NumericVector&,const bool&)"); p_cpp_dmvhyper = (Ptr_cpp_dmvhyper)R_GetCCallable("extraDistr", "_extraDistr_cpp_dmvhyper"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dmvhyper(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(k)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericMatrix cpp_rmvhyper(const int& nn, const NumericMatrix& n, const NumericVector& k) { typedef SEXP(*Ptr_cpp_rmvhyper)(SEXP,SEXP,SEXP); static Ptr_cpp_rmvhyper p_cpp_rmvhyper = NULL; if (p_cpp_rmvhyper == NULL) { validateSignature("NumericMatrix(*cpp_rmvhyper)(const int&,const NumericMatrix&,const NumericVector&)"); p_cpp_rmvhyper = (Ptr_cpp_rmvhyper)R_GetCCallable("extraDistr", "_extraDistr_cpp_rmvhyper"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rmvhyper(Shield(Rcpp::wrap(nn)), Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(k))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dnhyper(const NumericVector& x, const NumericVector& n, const NumericVector& m, const NumericVector& r, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dnhyper)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dnhyper p_cpp_dnhyper = NULL; if (p_cpp_dnhyper == NULL) { validateSignature("NumericVector(*cpp_dnhyper)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dnhyper = (Ptr_cpp_dnhyper)R_GetCCallable("extraDistr", "_extraDistr_cpp_dnhyper"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dnhyper(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(m)), Shield(Rcpp::wrap(r)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pnhyper(const NumericVector& x, const NumericVector& n, const NumericVector& m, const NumericVector& r, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pnhyper)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pnhyper p_cpp_pnhyper = NULL; if (p_cpp_pnhyper == NULL) { validateSignature("NumericVector(*cpp_pnhyper)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pnhyper = (Ptr_cpp_pnhyper)R_GetCCallable("extraDistr", "_extraDistr_cpp_pnhyper"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pnhyper(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(m)), Shield(Rcpp::wrap(r)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qnhyper(const NumericVector& p, const NumericVector& n, const NumericVector& m, const NumericVector& r, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qnhyper)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qnhyper p_cpp_qnhyper = NULL; if (p_cpp_qnhyper == NULL) { validateSignature("NumericVector(*cpp_qnhyper)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qnhyper = (Ptr_cpp_qnhyper)R_GetCCallable("extraDistr", "_extraDistr_cpp_qnhyper"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qnhyper(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(m)), Shield(Rcpp::wrap(r)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rnhyper(const int& nn, const NumericVector& n, const NumericVector& m, const NumericVector& r) { typedef SEXP(*Ptr_cpp_rnhyper)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rnhyper p_cpp_rnhyper = NULL; if (p_cpp_rnhyper == NULL) { validateSignature("NumericVector(*cpp_rnhyper)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rnhyper = (Ptr_cpp_rnhyper)R_GetCCallable("extraDistr", "_extraDistr_cpp_rnhyper"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rnhyper(Shield(Rcpp::wrap(nn)), Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(m)), Shield(Rcpp::wrap(r))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dnsbeta(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& lower, const NumericVector& upper, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dnsbeta)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dnsbeta p_cpp_dnsbeta = NULL; if (p_cpp_dnsbeta == NULL) { validateSignature("NumericVector(*cpp_dnsbeta)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dnsbeta = (Ptr_cpp_dnsbeta)R_GetCCallable("extraDistr", "_extraDistr_cpp_dnsbeta"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dnsbeta(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pnsbeta(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pnsbeta)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pnsbeta p_cpp_pnsbeta = NULL; if (p_cpp_pnsbeta == NULL) { validateSignature("NumericVector(*cpp_pnsbeta)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pnsbeta = (Ptr_cpp_pnsbeta)R_GetCCallable("extraDistr", "_extraDistr_cpp_pnsbeta"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pnsbeta(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qnsbeta(const NumericVector& p, const NumericVector& alpha, const NumericVector& beta, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qnsbeta)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qnsbeta p_cpp_qnsbeta = NULL; if (p_cpp_qnsbeta == NULL) { validateSignature("NumericVector(*cpp_qnsbeta)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qnsbeta = (Ptr_cpp_qnsbeta)R_GetCCallable("extraDistr", "_extraDistr_cpp_qnsbeta"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qnsbeta(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rnsbeta(const int& n, const NumericVector& alpha, const NumericVector& beta, const NumericVector& lower, const NumericVector& upper) { typedef SEXP(*Ptr_cpp_rnsbeta)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rnsbeta p_cpp_rnsbeta = NULL; if (p_cpp_rnsbeta == NULL) { validateSignature("NumericVector(*cpp_rnsbeta)(const int&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rnsbeta = (Ptr_cpp_rnsbeta)R_GetCCallable("extraDistr", "_extraDistr_cpp_rnsbeta"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rnsbeta(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dpareto(const NumericVector& x, const NumericVector& a, const NumericVector& b, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dpareto)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dpareto p_cpp_dpareto = NULL; if (p_cpp_dpareto == NULL) { validateSignature("NumericVector(*cpp_dpareto)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dpareto = (Ptr_cpp_dpareto)R_GetCCallable("extraDistr", "_extraDistr_cpp_dpareto"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dpareto(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_ppareto(const NumericVector& x, const NumericVector& a, const NumericVector& b, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_ppareto)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_ppareto p_cpp_ppareto = NULL; if (p_cpp_ppareto == NULL) { validateSignature("NumericVector(*cpp_ppareto)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_ppareto = (Ptr_cpp_ppareto)R_GetCCallable("extraDistr", "_extraDistr_cpp_ppareto"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_ppareto(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qpareto(const NumericVector& p, const NumericVector& a, const NumericVector& b, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qpareto)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qpareto p_cpp_qpareto = NULL; if (p_cpp_qpareto == NULL) { validateSignature("NumericVector(*cpp_qpareto)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qpareto = (Ptr_cpp_qpareto)R_GetCCallable("extraDistr", "_extraDistr_cpp_qpareto"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qpareto(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rpareto(const int& n, const NumericVector& a, const NumericVector& b) { typedef SEXP(*Ptr_cpp_rpareto)(SEXP,SEXP,SEXP); static Ptr_cpp_rpareto p_cpp_rpareto = NULL; if (p_cpp_rpareto == NULL) { validateSignature("NumericVector(*cpp_rpareto)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rpareto = (Ptr_cpp_rpareto)R_GetCCallable("extraDistr", "_extraDistr_cpp_rpareto"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rpareto(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dpower(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dpower)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dpower p_cpp_dpower = NULL; if (p_cpp_dpower == NULL) { validateSignature("NumericVector(*cpp_dpower)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dpower = (Ptr_cpp_dpower)R_GetCCallable("extraDistr", "_extraDistr_cpp_dpower"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dpower(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_ppower(const NumericVector& x, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_ppower)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_ppower p_cpp_ppower = NULL; if (p_cpp_ppower == NULL) { validateSignature("NumericVector(*cpp_ppower)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_ppower = (Ptr_cpp_ppower)R_GetCCallable("extraDistr", "_extraDistr_cpp_ppower"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_ppower(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qpower(const NumericVector& p, const NumericVector& alpha, const NumericVector& beta, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qpower)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qpower p_cpp_qpower = NULL; if (p_cpp_qpower == NULL) { validateSignature("NumericVector(*cpp_qpower)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qpower = (Ptr_cpp_qpower)R_GetCCallable("extraDistr", "_extraDistr_cpp_qpower"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qpower(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rpower(const int& n, const NumericVector& alpha, const NumericVector& beta) { typedef SEXP(*Ptr_cpp_rpower)(SEXP,SEXP,SEXP); static Ptr_cpp_rpower p_cpp_rpower = NULL; if (p_cpp_rpower == NULL) { validateSignature("NumericVector(*cpp_rpower)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rpower = (Ptr_cpp_rpower)R_GetCCallable("extraDistr", "_extraDistr_cpp_rpower"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rpower(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(alpha)), Shield(Rcpp::wrap(beta))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dprop(const NumericVector& x, const NumericVector& size, const NumericVector& mean, const NumericVector& prior, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dprop)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dprop p_cpp_dprop = NULL; if (p_cpp_dprop == NULL) { validateSignature("NumericVector(*cpp_dprop)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dprop = (Ptr_cpp_dprop)R_GetCCallable("extraDistr", "_extraDistr_cpp_dprop"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dprop(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(mean)), Shield(Rcpp::wrap(prior)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pprop(const NumericVector& x, const NumericVector& size, const NumericVector& mean, const NumericVector& prior, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pprop)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pprop p_cpp_pprop = NULL; if (p_cpp_pprop == NULL) { validateSignature("NumericVector(*cpp_pprop)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pprop = (Ptr_cpp_pprop)R_GetCCallable("extraDistr", "_extraDistr_cpp_pprop"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pprop(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(mean)), Shield(Rcpp::wrap(prior)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qprop(const NumericVector& p, const NumericVector& size, const NumericVector& mean, const NumericVector& prior, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qprop)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qprop p_cpp_qprop = NULL; if (p_cpp_qprop == NULL) { validateSignature("NumericVector(*cpp_qprop)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qprop = (Ptr_cpp_qprop)R_GetCCallable("extraDistr", "_extraDistr_cpp_qprop"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qprop(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(mean)), Shield(Rcpp::wrap(prior)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rprop(const int& n, const NumericVector& size, const NumericVector& mean, const NumericVector& prior) { typedef SEXP(*Ptr_cpp_rprop)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rprop p_cpp_rprop = NULL; if (p_cpp_rprop == NULL) { validateSignature("NumericVector(*cpp_rprop)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rprop = (Ptr_cpp_rprop)R_GetCCallable("extraDistr", "_extraDistr_cpp_rprop"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rprop(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(mean)), Shield(Rcpp::wrap(prior))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rsign(const int& n) { typedef SEXP(*Ptr_cpp_rsign)(SEXP); static Ptr_cpp_rsign p_cpp_rsign = NULL; if (p_cpp_rsign == NULL) { validateSignature("NumericVector(*cpp_rsign)(const int&)"); p_cpp_rsign = (Ptr_cpp_rsign)R_GetCCallable("extraDistr", "_extraDistr_cpp_rsign"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rsign(Shield(Rcpp::wrap(n))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_drayleigh(const NumericVector& x, const NumericVector& sigma, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_drayleigh)(SEXP,SEXP,SEXP); static Ptr_cpp_drayleigh p_cpp_drayleigh = NULL; if (p_cpp_drayleigh == NULL) { validateSignature("NumericVector(*cpp_drayleigh)(const NumericVector&,const NumericVector&,const bool&)"); p_cpp_drayleigh = (Ptr_cpp_drayleigh)R_GetCCallable("extraDistr", "_extraDistr_cpp_drayleigh"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_drayleigh(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_prayleigh(const NumericVector& x, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_prayleigh)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_prayleigh p_cpp_prayleigh = NULL; if (p_cpp_prayleigh == NULL) { validateSignature("NumericVector(*cpp_prayleigh)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_prayleigh = (Ptr_cpp_prayleigh)R_GetCCallable("extraDistr", "_extraDistr_cpp_prayleigh"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_prayleigh(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qrayleigh(const NumericVector& p, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qrayleigh)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qrayleigh p_cpp_qrayleigh = NULL; if (p_cpp_qrayleigh == NULL) { validateSignature("NumericVector(*cpp_qrayleigh)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qrayleigh = (Ptr_cpp_qrayleigh)R_GetCCallable("extraDistr", "_extraDistr_cpp_qrayleigh"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qrayleigh(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rrayleigh(const int& n, const NumericVector& sigma) { typedef SEXP(*Ptr_cpp_rrayleigh)(SEXP,SEXP); static Ptr_cpp_rrayleigh p_cpp_rrayleigh = NULL; if (p_cpp_rrayleigh == NULL) { validateSignature("NumericVector(*cpp_rrayleigh)(const int&,const NumericVector&)"); p_cpp_rrayleigh = (Ptr_cpp_rrayleigh)R_GetCCallable("extraDistr", "_extraDistr_cpp_rrayleigh"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rrayleigh(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(sigma))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dsgomp(const NumericVector& x, const NumericVector& b, const NumericVector& eta, bool log_prob = false) { typedef SEXP(*Ptr_cpp_dsgomp)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dsgomp p_cpp_dsgomp = NULL; if (p_cpp_dsgomp == NULL) { validateSignature("NumericVector(*cpp_dsgomp)(const NumericVector&,const NumericVector&,const NumericVector&,bool)"); p_cpp_dsgomp = (Ptr_cpp_dsgomp)R_GetCCallable("extraDistr", "_extraDistr_cpp_dsgomp"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dsgomp(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(eta)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_psgomp(const NumericVector& x, const NumericVector& b, const NumericVector& eta, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_psgomp)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_psgomp p_cpp_psgomp = NULL; if (p_cpp_psgomp == NULL) { validateSignature("NumericVector(*cpp_psgomp)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_psgomp = (Ptr_cpp_psgomp)R_GetCCallable("extraDistr", "_extraDistr_cpp_psgomp"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_psgomp(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(eta)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rsgomp(const int& n, const NumericVector& b, const NumericVector& eta) { typedef SEXP(*Ptr_cpp_rsgomp)(SEXP,SEXP,SEXP); static Ptr_cpp_rsgomp p_cpp_rsgomp = NULL; if (p_cpp_rsgomp == NULL) { validateSignature("NumericVector(*cpp_rsgomp)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rsgomp = (Ptr_cpp_rsgomp)R_GetCCallable("extraDistr", "_extraDistr_cpp_rsgomp"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rsgomp(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(eta))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dskellam(const NumericVector& x, const NumericVector& mu1, const NumericVector& mu2, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dskellam)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dskellam p_cpp_dskellam = NULL; if (p_cpp_dskellam == NULL) { validateSignature("NumericVector(*cpp_dskellam)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dskellam = (Ptr_cpp_dskellam)R_GetCCallable("extraDistr", "_extraDistr_cpp_dskellam"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dskellam(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu1)), Shield(Rcpp::wrap(mu2)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rskellam(const int& n, const NumericVector& mu1, const NumericVector& mu2) { typedef SEXP(*Ptr_cpp_rskellam)(SEXP,SEXP,SEXP); static Ptr_cpp_rskellam p_cpp_rskellam = NULL; if (p_cpp_rskellam == NULL) { validateSignature("NumericVector(*cpp_rskellam)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rskellam = (Ptr_cpp_rskellam)R_GetCCallable("extraDistr", "_extraDistr_cpp_rskellam"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rskellam(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(mu1)), Shield(Rcpp::wrap(mu2))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dslash(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dslash)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dslash p_cpp_dslash = NULL; if (p_cpp_dslash == NULL) { validateSignature("NumericVector(*cpp_dslash)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dslash = (Ptr_cpp_dslash)R_GetCCallable("extraDistr", "_extraDistr_cpp_dslash"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dslash(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pslash(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pslash)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pslash p_cpp_pslash = NULL; if (p_cpp_pslash == NULL) { validateSignature("NumericVector(*cpp_pslash)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pslash = (Ptr_cpp_pslash)R_GetCCallable("extraDistr", "_extraDistr_cpp_pslash"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pslash(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rslash(const int& n, const NumericVector& mu, const NumericVector& sigma) { typedef SEXP(*Ptr_cpp_rslash)(SEXP,SEXP,SEXP); static Ptr_cpp_rslash p_cpp_rslash = NULL; if (p_cpp_rslash == NULL) { validateSignature("NumericVector(*cpp_rslash)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rslash = (Ptr_cpp_rslash)R_GetCCallable("extraDistr", "_extraDistr_cpp_rslash"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rslash(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dtriang(const NumericVector& x, const NumericVector& a, const NumericVector& b, const NumericVector& c, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dtriang)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dtriang p_cpp_dtriang = NULL; if (p_cpp_dtriang == NULL) { validateSignature("NumericVector(*cpp_dtriang)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dtriang = (Ptr_cpp_dtriang)R_GetCCallable("extraDistr", "_extraDistr_cpp_dtriang"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dtriang(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(c)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_ptriang(const NumericVector& x, const NumericVector& a, const NumericVector& b, const NumericVector& c, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_ptriang)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_ptriang p_cpp_ptriang = NULL; if (p_cpp_ptriang == NULL) { validateSignature("NumericVector(*cpp_ptriang)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_ptriang = (Ptr_cpp_ptriang)R_GetCCallable("extraDistr", "_extraDistr_cpp_ptriang"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_ptriang(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(c)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qtriang(const NumericVector& p, const NumericVector& a, const NumericVector& b, const NumericVector& c, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qtriang)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qtriang p_cpp_qtriang = NULL; if (p_cpp_qtriang == NULL) { validateSignature("NumericVector(*cpp_qtriang)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qtriang = (Ptr_cpp_qtriang)R_GetCCallable("extraDistr", "_extraDistr_cpp_qtriang"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qtriang(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(c)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rtriang(const int& n, const NumericVector& a, const NumericVector& b, const NumericVector& c) { typedef SEXP(*Ptr_cpp_rtriang)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rtriang p_cpp_rtriang = NULL; if (p_cpp_rtriang == NULL) { validateSignature("NumericVector(*cpp_rtriang)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rtriang = (Ptr_cpp_rtriang)R_GetCCallable("extraDistr", "_extraDistr_cpp_rtriang"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rtriang(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(a)), Shield(Rcpp::wrap(b)), Shield(Rcpp::wrap(c))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dtbinom(const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& lower, const NumericVector& upper, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dtbinom)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dtbinom p_cpp_dtbinom = NULL; if (p_cpp_dtbinom == NULL) { validateSignature("NumericVector(*cpp_dtbinom)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dtbinom = (Ptr_cpp_dtbinom)R_GetCCallable("extraDistr", "_extraDistr_cpp_dtbinom"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dtbinom(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_ptbinom(const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_ptbinom)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_ptbinom p_cpp_ptbinom = NULL; if (p_cpp_ptbinom == NULL) { validateSignature("NumericVector(*cpp_ptbinom)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_ptbinom = (Ptr_cpp_ptbinom)R_GetCCallable("extraDistr", "_extraDistr_cpp_ptbinom"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_ptbinom(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qtbinom(const NumericVector& p, const NumericVector& size, const NumericVector& prob, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qtbinom)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qtbinom p_cpp_qtbinom = NULL; if (p_cpp_qtbinom == NULL) { validateSignature("NumericVector(*cpp_qtbinom)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qtbinom = (Ptr_cpp_qtbinom)R_GetCCallable("extraDistr", "_extraDistr_cpp_qtbinom"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qtbinom(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rtbinom(const int& n, const NumericVector& size, const NumericVector& prob, const NumericVector& lower, const NumericVector& upper) { typedef SEXP(*Ptr_cpp_rtbinom)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rtbinom p_cpp_rtbinom = NULL; if (p_cpp_rtbinom == NULL) { validateSignature("NumericVector(*cpp_rtbinom)(const int&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rtbinom = (Ptr_cpp_rtbinom)R_GetCCallable("extraDistr", "_extraDistr_cpp_rtbinom"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rtbinom(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dtnorm(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& lower, const NumericVector& upper, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dtnorm)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dtnorm p_cpp_dtnorm = NULL; if (p_cpp_dtnorm == NULL) { validateSignature("NumericVector(*cpp_dtnorm)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dtnorm = (Ptr_cpp_dtnorm)R_GetCCallable("extraDistr", "_extraDistr_cpp_dtnorm"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dtnorm(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_ptnorm(const NumericVector& x, const NumericVector& mu, const NumericVector& sigma, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_ptnorm)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_ptnorm p_cpp_ptnorm = NULL; if (p_cpp_ptnorm == NULL) { validateSignature("NumericVector(*cpp_ptnorm)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_ptnorm = (Ptr_cpp_ptnorm)R_GetCCallable("extraDistr", "_extraDistr_cpp_ptnorm"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_ptnorm(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qtnorm(const NumericVector& p, const NumericVector& mu, const NumericVector& sigma, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qtnorm)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qtnorm p_cpp_qtnorm = NULL; if (p_cpp_qtnorm == NULL) { validateSignature("NumericVector(*cpp_qtnorm)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qtnorm = (Ptr_cpp_qtnorm)R_GetCCallable("extraDistr", "_extraDistr_cpp_qtnorm"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qtnorm(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rtnorm(const int& n, const NumericVector& mu, const NumericVector& sigma, const NumericVector& lower, const NumericVector& upper) { typedef SEXP(*Ptr_cpp_rtnorm)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rtnorm p_cpp_rtnorm = NULL; if (p_cpp_rtnorm == NULL) { validateSignature("NumericVector(*cpp_rtnorm)(const int&,const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rtnorm = (Ptr_cpp_rtnorm)R_GetCCallable("extraDistr", "_extraDistr_cpp_rtnorm"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rtnorm(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(sigma)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dtpois(const NumericVector& x, const NumericVector& lambda, const NumericVector& lower, const NumericVector& upper, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dtpois)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dtpois p_cpp_dtpois = NULL; if (p_cpp_dtpois == NULL) { validateSignature("NumericVector(*cpp_dtpois)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dtpois = (Ptr_cpp_dtpois)R_GetCCallable("extraDistr", "_extraDistr_cpp_dtpois"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dtpois(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_ptpois(const NumericVector& x, const NumericVector& lambda, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_ptpois)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_ptpois p_cpp_ptpois = NULL; if (p_cpp_ptpois == NULL) { validateSignature("NumericVector(*cpp_ptpois)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_ptpois = (Ptr_cpp_ptpois)R_GetCCallable("extraDistr", "_extraDistr_cpp_ptpois"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_ptpois(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qtpois(const NumericVector& p, const NumericVector& lambda, const NumericVector& lower, const NumericVector& upper, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qtpois)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qtpois p_cpp_qtpois = NULL; if (p_cpp_qtpois == NULL) { validateSignature("NumericVector(*cpp_qtpois)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qtpois = (Ptr_cpp_qtpois)R_GetCCallable("extraDistr", "_extraDistr_cpp_qtpois"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qtpois(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rtpois(const int& n, const NumericVector& lambda, const NumericVector& lower, const NumericVector& upper) { typedef SEXP(*Ptr_cpp_rtpois)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rtpois p_cpp_rtpois = NULL; if (p_cpp_rtpois == NULL) { validateSignature("NumericVector(*cpp_rtpois)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rtpois = (Ptr_cpp_rtpois)R_GetCCallable("extraDistr", "_extraDistr_cpp_rtpois"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rtpois(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(lower)), Shield(Rcpp::wrap(upper))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qtlambda(const NumericVector& p, const NumericVector& lambda, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qtlambda)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qtlambda p_cpp_qtlambda = NULL; if (p_cpp_qtlambda == NULL) { validateSignature("NumericVector(*cpp_qtlambda)(const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qtlambda = (Ptr_cpp_qtlambda)R_GetCCallable("extraDistr", "_extraDistr_cpp_qtlambda"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qtlambda(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rtlambda(const int& n, const NumericVector& lambda) { typedef SEXP(*Ptr_cpp_rtlambda)(SEXP,SEXP); static Ptr_cpp_rtlambda p_cpp_rtlambda = NULL; if (p_cpp_rtlambda == NULL) { validateSignature("NumericVector(*cpp_rtlambda)(const int&,const NumericVector&)"); p_cpp_rtlambda = (Ptr_cpp_rtlambda)R_GetCCallable("extraDistr", "_extraDistr_cpp_rtlambda"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rtlambda(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(lambda))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dwald(const NumericVector& x, const NumericVector& mu, const NumericVector& lambda, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dwald)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dwald p_cpp_dwald = NULL; if (p_cpp_dwald == NULL) { validateSignature("NumericVector(*cpp_dwald)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dwald = (Ptr_cpp_dwald)R_GetCCallable("extraDistr", "_extraDistr_cpp_dwald"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dwald(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pwald(const NumericVector& x, const NumericVector& mu, const NumericVector& lambda, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pwald)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pwald p_cpp_pwald = NULL; if (p_cpp_pwald == NULL) { validateSignature("NumericVector(*cpp_pwald)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pwald = (Ptr_cpp_pwald)R_GetCCallable("extraDistr", "_extraDistr_cpp_pwald"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pwald(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rwald(const int& n, const NumericVector& mu, const NumericVector& lambda) { typedef SEXP(*Ptr_cpp_rwald)(SEXP,SEXP,SEXP); static Ptr_cpp_rwald p_cpp_rwald = NULL; if (p_cpp_rwald == NULL) { validateSignature("NumericVector(*cpp_rwald)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rwald = (Ptr_cpp_rwald)R_GetCCallable("extraDistr", "_extraDistr_cpp_rwald"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rwald(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(mu)), Shield(Rcpp::wrap(lambda))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dzib(const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dzib)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dzib p_cpp_dzib = NULL; if (p_cpp_dzib == NULL) { validateSignature("NumericVector(*cpp_dzib)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dzib = (Ptr_cpp_dzib)R_GetCCallable("extraDistr", "_extraDistr_cpp_dzib"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dzib(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(pi)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pzib(const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pzib)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pzib p_cpp_pzib = NULL; if (p_cpp_pzib == NULL) { validateSignature("NumericVector(*cpp_pzib)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pzib = (Ptr_cpp_pzib)R_GetCCallable("extraDistr", "_extraDistr_cpp_pzib"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pzib(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(pi)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qzib(const NumericVector& p, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qzib)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qzib p_cpp_qzib = NULL; if (p_cpp_qzib == NULL) { validateSignature("NumericVector(*cpp_qzib)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qzib = (Ptr_cpp_qzib)R_GetCCallable("extraDistr", "_extraDistr_cpp_qzib"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qzib(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(pi)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rzib(const int& n, const NumericVector& size, const NumericVector& prob, const NumericVector& pi) { typedef SEXP(*Ptr_cpp_rzib)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rzib p_cpp_rzib = NULL; if (p_cpp_rzib == NULL) { validateSignature("NumericVector(*cpp_rzib)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rzib = (Ptr_cpp_rzib)R_GetCCallable("extraDistr", "_extraDistr_cpp_rzib"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rzib(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(pi))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dzinb(const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dzinb)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dzinb p_cpp_dzinb = NULL; if (p_cpp_dzinb == NULL) { validateSignature("NumericVector(*cpp_dzinb)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dzinb = (Ptr_cpp_dzinb)R_GetCCallable("extraDistr", "_extraDistr_cpp_dzinb"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dzinb(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(pi)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pzinb(const NumericVector& x, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pzinb)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pzinb p_cpp_pzinb = NULL; if (p_cpp_pzinb == NULL) { validateSignature("NumericVector(*cpp_pzinb)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pzinb = (Ptr_cpp_pzinb)R_GetCCallable("extraDistr", "_extraDistr_cpp_pzinb"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pzinb(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(pi)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qzinb(const NumericVector& p, const NumericVector& size, const NumericVector& prob, const NumericVector& pi, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qzinb)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qzinb p_cpp_qzinb = NULL; if (p_cpp_qzinb == NULL) { validateSignature("NumericVector(*cpp_qzinb)(const NumericVector&,const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qzinb = (Ptr_cpp_qzinb)R_GetCCallable("extraDistr", "_extraDistr_cpp_qzinb"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qzinb(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(pi)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rzinb(const int& n, const NumericVector& size, const NumericVector& prob, const NumericVector& pi) { typedef SEXP(*Ptr_cpp_rzinb)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_rzinb p_cpp_rzinb = NULL; if (p_cpp_rzinb == NULL) { validateSignature("NumericVector(*cpp_rzinb)(const int&,const NumericVector&,const NumericVector&,const NumericVector&)"); p_cpp_rzinb = (Ptr_cpp_rzinb)R_GetCCallable("extraDistr", "_extraDistr_cpp_rzinb"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rzinb(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(size)), Shield(Rcpp::wrap(prob)), Shield(Rcpp::wrap(pi))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_dzip(const NumericVector& x, const NumericVector& lambda, const NumericVector& pi, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_dzip)(SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_dzip p_cpp_dzip = NULL; if (p_cpp_dzip == NULL) { validateSignature("NumericVector(*cpp_dzip)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&)"); p_cpp_dzip = (Ptr_cpp_dzip)R_GetCCallable("extraDistr", "_extraDistr_cpp_dzip"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_dzip(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(pi)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_pzip(const NumericVector& x, const NumericVector& lambda, const NumericVector& pi, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_pzip)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_pzip p_cpp_pzip = NULL; if (p_cpp_pzip == NULL) { validateSignature("NumericVector(*cpp_pzip)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_pzip = (Ptr_cpp_pzip)R_GetCCallable("extraDistr", "_extraDistr_cpp_pzip"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_pzip(Shield(Rcpp::wrap(x)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(pi)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_qzip(const NumericVector& p, const NumericVector& lambda, const NumericVector& pi, const bool& lower_tail = true, const bool& log_prob = false) { typedef SEXP(*Ptr_cpp_qzip)(SEXP,SEXP,SEXP,SEXP,SEXP); static Ptr_cpp_qzip p_cpp_qzip = NULL; if (p_cpp_qzip == NULL) { validateSignature("NumericVector(*cpp_qzip)(const NumericVector&,const NumericVector&,const NumericVector&,const bool&,const bool&)"); p_cpp_qzip = (Ptr_cpp_qzip)R_GetCCallable("extraDistr", "_extraDistr_cpp_qzip"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_qzip(Shield(Rcpp::wrap(p)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(pi)), Shield(Rcpp::wrap(lower_tail)), Shield(Rcpp::wrap(log_prob))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } inline NumericVector cpp_rzip(const int& n, const NumericVector& lambda, const NumericVector& pi) { typedef SEXP(*Ptr_cpp_rzip)(SEXP,SEXP,SEXP); static Ptr_cpp_rzip p_cpp_rzip = NULL; if (p_cpp_rzip == NULL) { validateSignature("NumericVector(*cpp_rzip)(const int&,const NumericVector&,const NumericVector&)"); p_cpp_rzip = (Ptr_cpp_rzip)R_GetCCallable("extraDistr", "_extraDistr_cpp_rzip"); } RObject rcpp_result_gen; { RNGScope RCPP_rngScope_gen; rcpp_result_gen = p_cpp_rzip(Shield(Rcpp::wrap(n)), Shield(Rcpp::wrap(lambda)), Shield(Rcpp::wrap(pi))); } if (rcpp_result_gen.inherits("interrupted-error")) throw Rcpp::internal::InterruptedException(); if (Rcpp::internal::isLongjumpSentinel(rcpp_result_gen)) throw Rcpp::LongjumpException(rcpp_result_gen); if (rcpp_result_gen.inherits("try-error")) throw Rcpp::exception(Rcpp::as(rcpp_result_gen).c_str()); return Rcpp::as(rcpp_result_gen); } } #endif // RCPP_extraDistr_RCPPEXPORTS_H_GEN_ extraDistr/inst/include/extraDistr.h0000644000176200001440000000040614475546572017330 0ustar liggesusers// Generated by using Rcpp::compileAttributes() -> do not edit by hand // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 #ifndef RCPP_extraDistr_H_GEN_ #define RCPP_extraDistr_H_GEN_ #include "extraDistr_RcppExports.h" #endif // RCPP_extraDistr_H_GEN_