Description Usage Arguments Details Value Author(s) See Also

Density and random generation functions for the categorical distribution.

1 2 | ```
dcategorical(x, prob, log=FALSE)
rcategorical(n, prob)
``` |

`x` |
vector of integers between 1 and some integer |

`prob` |
vector of probabilities such that |

`log` |
logical; if |

`n` |
number of observations. |

The categorical distribution is a special case of the multinomial distribution with size 1. Values may be between 1 and some integer *K*, inclusive. If the random variable *X* is categorical with probability vector *p* of length *K*, then *P(X=x) = p_x*. The density is

*
f(x) = prod_k p_k^I(x=k) = p_x*

where *I(.)* is the indicator function and *k = 1,…,K*.

`dcategorical`

gives the density and `rcategorical`

generates random deviates.

Daniel Dvorkin

lcmix documentation built on May 21, 2017, 4:05 a.m.

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

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

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

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.