Suppose that I have a variable like X
with unknown distribution. In Mathematica, by using SmoothKernelDensity
function we can have an estimated density function.This estimated density function can be used alongside with PDF
function to calculate probability density function of a value like X
in the form of PDF[density,X]
assuming that "density" is the result of SmoothKernelDensity
. It would be good if there is such feature in R.This is how it works in Mathematica
http://reference.wolfram.com/mathematica/ref/SmoothKernelDistribution.html
As an example (based on Mathematica functions):
data = RandomVariate[NormalDistribution[], 100]; #generates 100 values from N(0,1)
density= SmoothKernelDistribution[data]; #estimated density
PDF[density, 2.345] returns 0.0588784
Here you can find more information about PDF:
http://reference.wolfram.com/mathematica/ref/PDF.html
I know that I can plot its density function using density(X)
in R and by using ecdf(X)
I can obtain its empirical cumulative distribution function.Is it possible to do the same thing in R based on what I described about Mathematica?
Any help and idea is appreciated.