Creating Empirical Distribution Functions

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

Build Status CRAN_Status_Badge

Table of contents:

Please submit features requests

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:


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");

And then you may load the package using:



Quick example:

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)

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:

Latest news

You can see the most recent changes to the package in the file

Code of conduct

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.


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.


  • 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.


0.2.0 by Tal Galili, 5 years ago,,

Report a bug at

Browse source code at

Authors: Tal Galili [aut, cre, cph] (

Documentation:   PDF Manual  

GPL-2 | GPL-3 license

Imports stats

Suggests knitr, rmarkdown

Imported by TesiproV.

See at CRAN