# empiricalC: The Continuous Empirical Distribution In mc2d: Tools for Two-Dimensional Monte-Carlo Simulations

## Description

Density, distribution function and random generation for a continuous empirical distribution.

## Usage

 ```1 2 3 4``` ```dempiricalC(x, min, max, values, prob=NULL, log=FALSE) pempiricalC(q, min, max, values, prob=NULL, lower.tail=TRUE, log.p=FALSE) qempiricalC(p, min, max, values, prob=NULL, lower.tail=TRUE, log.p=FALSE) rempiricalC(n, min, max, values, prob=NULL) ```

## Arguments

 `x, q` Vector of quantiles. `p` Vector of probabilities. `n` Number of random values. If length(n) > 1, the length is taken to be the number required. `min` A finite minimal value. `max` A finite maximal value. `values` Vector of numerical values. `prob` Optionnal vector of count or probabilities. `log, log.p` logical; if TRUE, probabilities p are given as log(p). `lower.tail` logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x].

## Details

Given p_i, the distribution value for x_i with i the rank i = 0, 1, 2, …, N+1, x_0 = min and x_(N+1) = max the density is:

f(x) = p_i + (p_(i+1) - p_i)/(x_(i+1) - x_i) for x_i<=x<x_(i+1)

The p values being normalized to give the distribution a unit area.

min and/or max and/or values and/or prob may vary: in that case, min and/or max should be vector(s). values and/or prob should be matrixes, the first row being used for the first element of x, q, p or the first random value, the second row for the second element of x, q, p or random value, ... Recycling is permitted if the number of elements of min or max or the number of rows of prob and values are equal or equals one.

## Value

dempiricalC gives the density, pempiricalC gives the distribution function, qempiricalC gives the quantile function and rempiricalC generates random deviates.

`empiricalD`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22``` ```prob <- c(2, 3, 1, 6, 1) values <- 1:5 par(mfrow=c(1, 2)) curve(dempiricalC(x, min=0, max=6, values, prob), from=-1, to=7, n=1001) curve(pempiricalC(x, min=0, max=6, values, prob), from=-1, to=7, n=1001) ## Varying values (values <- matrix(1:10, ncol=5)) ## the first x apply to the first row ## the second x to the second one dempiricalC(c(1, 1), values, min=0, max=11) ##Use with mc2d val <- c(100, 150, 170, 200) pr <- c(6, 12, 6, 6) out <- c("min", "mean", "max") ##First Bootstrap in the uncertainty dimension ##with rempirical D (x <- mcstoc(rempiricalD, type = "U", outm = out, nvariates = 30, values = val, prob = pr)) ##Continuous Empirical distribution in the variability dimension mcstoc(rempiricalC, type = "VU", values = x, min=90, max=210) ```