## Zipf-Mandelbrodt distribution

### Description

Density, distribution function, quantile function and random generation for Zipf-Mandelbrodt distribution with parameters `N` `s` and `v`.

### Usage

```dmand( x, N, s, v, log=FALSE)
pmand( q, N, s, v, lower.tail=TRUE, log.p=FALSE)
qmand( p, N, s, v, lower.tail = TRUE, log.p = FALSE)
rmand( n, N, s, v)
```

### Arguments

 `x` vector of (non-negative integer) quantiles. In the context of species abundance distributions, this is a vector of abundance ranks of species in a sample. `q` vector of (non-negative integer) quantiles. In the context of species abundance distributions, a vector of abundance ranks of species in a sample. `n` number of random values to return. `p` vector of probabilities. `N` positive integer 0 < N < Inf, total number of elements of a collection. In the context of species abundance distributions, usually the number of species in a sample. `s` positive real s > 0; Zipf-Mandelbrodt exponent. `v` positive real or zero v >= 0; Zipf-Mandelbrodt parameter. `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

The Mandelbrodt distribution describes the probability or frequency of occurrence of a given element from a set of `N` elements. This probability is inversely proportional to a power `s` of the rank of the frequency of the element in the set. The density function is

p(x) = ((x+v)^(-s)) / sum(((1:N)+v)^(-s))

Since p(x) is proportional to a power of `x`, the Zipf-Mandelbrodt distribution is a power distribution. The Zipf distribution is a special case when v=0. Hence, the Zipf-Mandelbrodt distribution is a generalization of the Zipf Law, and is widely used in the [x] for the same purposes. In Ecology, it can be used to describe the probability of the abundance rank `x` of given species in a sample or assemblage of `N` species.

### Value

`dmand` gives the (log) density of the density, `pmand` gives the (log) distribution function, `qmand` gives the quantile function.

Invalid values for parameters `v` or `s` will result in return values `NaN`, with a warning.

### References

Johnson N.L., Kemp, A.W. and Kotz S. 2005. Univariate Discrete Distributions, 3rd edition, Hoboken, New Jersey: Wiley. Section 11.2.20.

Magurran, A.E. and McGill, B.J. 2011. Biological Diversity - Frontiers in measurement and assessment. Oxford: Oxford University Press.

`dmand` and `rmand` and related functions in mandR package; `Zeta` for zeta distribution in VGAM package.

### Examples

```x <- 1:100
PDF <- dmand(x=x, N=100, s=1.5, v=2)
CDF <- pmand(q=x, N=100, s=1.5, v=2)
par(mfrow=c(1,2))
plot(x,CDF, ylab="Cumulative Probability", type="b",
main="Zipf-Mandelbrodt distribution, CDF")
plot(x,PDF, ylab="Probability", type="h",
main="Zipf-Mandelbrodt distribution, PDF")
par(mfrow=c(1,1))

## quantile is the inverse of CDF
all.equal( qmand(p=CDF, N=100, s=1.5, v=2), x)

## Zipf distribution is a particular case of ZM when v=0
all.equal( dmand(x=x, N=100, s=1.5, v=0), dzipf(x=x, N=100, s=1.5) )

```