Creating Empirical Distribution Functions

Easily creating empirical distribution functions from data: 'dfun', 'pfun', 'qfun' and 'rfun'.


Table of contents:

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 devtools
if (!require(devtools)) install.packages("devtools");
 
devtools::install_github('talgalili/edfun')

And then you may load the package using:

library("edfun")

Quick example:

library(edfun)
 
set.seed(123)
x <- rnorm(1000)
x_dist <- edfun(x)
 
f <- x_dist$dfun
curve(f, -2,2)
 
f <- x_dist$pfun
curve(f, -2,2)
 
f <- x_dist$qfun
curve(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.

News

edfun 0.2.0 (2016-08-27)

  • dfun in edfun now accepts NULL - and will return NULL in such a case. This is useful if using the functions ONLY for creating the CDF and inv-CDF and wanting to save computation time.
  • a few fixes before going on CRAN.

edfun 0.1.0 (2016-08-26)

  • First version. The core functionality of edfun works.

TODO:

  • create some unit tests from the examples in the vignette

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("edfun")

0.2.0 by Tal Galili, 6 months ago


https://cran.r-project.org/package=edfun, https://github.com/talgalili/edfun/, https://www.r-statistics.com/tag/edfun/


Report a bug at https://github.com/talgalili/edfun/issues


Browse source code at https://github.com/cran/edfun


Authors: Tal Galili [aut, cre, cph] (https://www.r-statistics.com)


Documentation:   PDF Manual  


GPL-2 | GPL-3 license


Imports stats

Suggests knitr, rmarkdown


See at CRAN