Description Usage Arguments Details Examples
The two wrapper functions call Rcpp functions to speed up computation. The codes are based on Christopher Jackson's msm (1.5) package and Jonathan Olmsted's RcppTN (0.1-8) package.
1 2 3 4 5 |
x, n |
x in |
mean |
vector of means |
sd |
vector of standard deviations |
lower |
lower truncation point. Default as -Inf |
upper |
upper truncation point. Default as Inf. |
log |
default 0 (FALSE). Enter 1 to make it TRUE. Whether to calculate density. Use only in dtnorm. |
checks |
a switch to turn on check functions to check inputs and ouput. Default to FALSE for the sake of speed. |
dtnorm
calculates probability density for a truncated normal
distribution with mean equal to mean and standard deviation equal to
sd before truncation, and truncated on the interval [lower, upper].
rtnorm
generates a random number from a truncated Normal
distribution with mean equal to mean and standard deviation equal
to sd before truncation, and truncated on the interval [lower, upper].
1 2 3 4 5 6 7 8 9 10 | ## Use dtnorm and rtnorm with their default values
dtnorm()
rtnorm()
## A similar curve plotting example extracted from dnorm functions
plot(function(x) dnorm(x, log = FALSE), -2.5, 2.5,
main = "Normal Distribution", ylim=c(0,0.45), ylab="Density")
curve(dtnorm(x, lower=-2, upper=2), add=TRUE, col="tomato", lwd=2)
mtext("dnorm(x)", adj = 0)
mtext("dtnorm(x)", col = "tomato", adj = 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.