Extract probability from density object

I am currently creating density objects for an environmental project that I am working on. Function densityin Rworks fine for setting density functions for my data.

The following is an example of how I use the function density:

dens.iris <- density(iris$Sepal.Length, bw = "bcv")

It works very well. However, the function predictdoes not work with objects density. Does anyone know a way to extract the density value for a specific point (for example, in a dataset iris, extract Sepal.Length 6.432)? It is very important to use the method for this biased cross validation.

+4
source share
1 answer

approxfun , . ,

diris <- with(dens.iris, approxfun(x, y, rule=1))
diris(6.432)
# [1] 0.349344

curve(diris(x), from=4.0, to=7.9)

enter image description here

, , . , , 6,432, 0.

+7

Source: https://habr.com/ru/post/1545609/


All Articles