Description Usage Arguments Details See Also Examples
The kernels are key-objects of the KDE
package. The S3
class Kernel
tries to ensure some of the properties of kernels and
is a subclass of 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 kernel function is a real valued, integrable function, such that
its integral over the real numbers equals one. Kernel 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,
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 Kernel
tries to construct a valid Kernel
object based on the passed arguments. Returned objects are guaranteed to
pass the validator validate_Kernel
.
Attention: This does not guarantee the conditions in the first
'Details' paragraph: see validate_Kernel
.
List of built-in kernels functions:
rectangular
triangular
epanechnikov
biweight
triweight
tricube
gaussian
cosine
logistic
sigmoid
silverman
validate_Kernel
for the corresponding validator,
IntegrableFunction
for more information about the superclass.
1 2 3 4 5 6 7 8 9 10 11 12 | rectangular_function <- function(u) 1/2*(abs(u) <= 1)
rectangular_ker <- Kernel(rectangular_function, support=c(-1,1))
x <- seq(from = -4, to = 4, length.out = 1000)
plot(x, gaussian$fun(x),
xlim=c(-5,5), ylim=c(0,1),
main="Kernels", xlab="", ylab="",
col="black", type="l")
lines(x, triangular$fun(x), col="red")
lines(x, rectangular_ker$fun(x), col="blue")
legend("topright",
legend=c("gaussian", "triangular","rectangular"),
col=c("black","red", "blue"), lty=1, cex=0.8)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.