Generates random data from a given empirical probability function. It also returns cumulative distribution function corresponding to the entered probability function.

1 |

`n` |
number of observations. |

`pf` |
empirical probability function. |

`pf`

is an array of any dimensionality with all elements sum up to one. If its dimension is greater than one, it is transformed to a row vector column-by-column.

A list including

`rdiscrete` |
an |

`cdf` |
a vector including cumulative distribution function. |

Haydar Demirhan

Maintainer: Haydar Demirhan <haydarde@hacettepe.edu.tr>

Kroese D.P., Taimre T., Botev Z.I. (2011) *Handbook of Monte Carlo Methods*, Wiley, New York.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ```
p = c(0.23,0.11,0.05,0.03,0.31,0.03,0.22,0.02)
rDiscrete(n=2,pf=p)
# pf would be entered as a matrix:
p = matrix(c(0.23,0.11,0.05,0.03,0.31,0.03,0.22,0.02), nrow=2, ncol=4, byrow = TRUE)
rDiscrete(n=2,pf=p)
p = matrix(c(0.23,0.11,0.05,0.03,0.31,0.03,0.22,0.02), nrow=4, ncol=2, byrow = TRUE)
rDiscrete(n=2,pf=p)
# or pf would be entered as a three dimensional array:
p = array(c(0.23,0.11,0.05,0.03,0.31,0.03,0.22,0.02), dim=c(2,2,2))
rDiscrete(n=2,pf=p)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.