Easily creating empirical distribution functions from data: 'dfun', 'pfun', 'qfun' and 'rfun'.
This package is still under active development. If you have features you would like to have added, please submit your suggestions (and bug-reports) at: https://github.com/talgalili/edfun/issues
As mentioned in CRAN Task View: Probability Distributions
This package aims to easily wrap these into a single function
edfun (short for Empirical Distribution FUNctions). Also, since quantile is generally a slow function to perform, the default for creating a quantile function (inverse-CDF) is by approximating the function of predicting the data values (x) from their quantiles (CDF). This is done using the
approxfun function. It takes a bit longer to create qfun, but it is MUCH faster to run than quantile (and is thus much better for simulations). Special care is taken for dealing with the support of the distribution (if it is known upfront).
The added speed allows to use these functions to run simulation studies for unusual distributions.
To install the stable version on CRAN:
# install.packages('edfun') # not on CRAN yet
To install the latest ("cutting-edge") GitHub version run:
# You'll need devtoolsif (!require(devtools)) install.packages("devtools");devtools::install_github('talgalili/edfun')
And then you may load the package using:
library(edfun)set.seed(123)x <- rnorm(1000)x_dist <- edfun(x)f <- x_dist$dfuncurve(f, -2,2)f <- x_dist$pfuncurve(f, -2,2)f <- x_dist$qfuncurve(f, 0,1)new_x <- x_dist$rfun(1000)hist(new_x)
This is especially useful for cases where we can simulate numbers or have their density, but don't have their CDF or inv-CDF. For example, for the double exponential distribution, or a bi-modal normal distribution.
This package is thanks to the amazing work done by MANY people in the (open source) R community.
You are welcome to:
You can see the most recent changes to the package in the NEWS.md file
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.