Description Usage Arguments Details See Also Examples
The S3 class Density
tries to ensure some of the
properties of densities and is a subclass IntegrableFunction
(see: 'Details' for exact requirements).
1 |
fun |
a |
support |
numerical vector of length 2; the lower- and upper bound of
the compact support in the first and second entry respectively. In
particular non-finite values are prohibited. |
subdivisions |
positive numeric scalar; the subdivisions parameter for
the function |
... |
additional parameters to keep fixed during the evaluation of
|
A density function is a real valued, non-negative, integrable
function, such that its integral over the real numbers equals one. Density
functions as R
functions are required to
be vectorised in its argument, taking a single numeric argument, returning a numerical vector of the same length only,
return zero for inputs outside their compact support,
return non-negative values for inputs inside their support,
can be integrated over their support using integrate_primitive
and the given number of subdivisions (the relative error converges),
yield an integral of nearly 1 (absolute error < 1%).
See the 'Details' section of IntegrableFunction
for comments
on the restrictiveness of compact supports.
The S3 class Density
exists to ensure some of the most basic
properties of density functions. The class is build on
IntegrableFunctions
and inherits its
structure.
The constructor Density
tries to construct a valid Density
object based on the passed arguments. Returned objects are guaranteed to
pass the validator validate_Density
.
Attention: This does not guarantee the conditions in the first
'Details' paragraph: see validate_Density
.
validate_Density
for the corresponding validator,
IntegrableFunction
for more information about the superclass.
1 2 3 4 5 6 7 8 9 10 11 | dens_norm <- Density(dnorm, c(-15, 15))
dens_unif <- Density(dunif)
x <- seq(from = -4, to = 4, length.out = 1000)
plot(x, dens_norm$fun(x),
xlim=c(-5,5), ylim=c(0,1),
main="Densities", xlab="", ylab="",
col="black", type="l")
lines(x,dens_unif$fun(x), col="red")
legend("topright",
legend=c("dens_norm", "dens_unif"),
col=c("black","red"), lty=1, cex=0.8)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.