Description Usage Arguments Value Examples
Construct an xDensity
representation of a known distribution.
1 |
XY |
2-column matrix representation of a univariate density. The first column is a grid of x values giving the centers of bins. The second column are the corresponding densities. |
mean, sd |
Optional mean and standard deviation of the Normal distribution to use outside the grid values in |
An xDensity
object. See xDensity
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # xDensity approximation to a noncentral-t distribution
# true parameters
lambda <- rnorm(1) # noncentrality parameter
nu <- runif(1, 4, 6) # degrees of freedom
# xDensity encoding of known PDF
xlim <- qt(c(.005, .995), df = nu, ncp = lambda) # discretization range
xseq <- seq(xlim[1], xlim[2], len = 200) # where to evaluate density
xDens <- matrixXD(cbind(xseq, dt(xseq, df = nu, ncp = lambda)))
# true vs approximate PDFs
curve(dt(x, df = nu, ncp = lambda),
from = xlim[1], to = xlim[2], ylab = "Density")
curve(dXD(x, xDens = xDens), add = TRUE, col = "red")
legend("topleft", legend = c("True PDF", "xDensity Approx."),
fill = c("black", "red"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.