unidpdf

Discrete uniform probability density function

Syntax

```Y = unidpdf(X,N) ```

Description

`Y = unidpdf(X,N)` computes the discrete uniform pdf at each of the values in `X` using the corresponding maximum observable value in `N`. `X` and `N` can be vectors, matrices, or multidimensional arrays that have the same size. A scalar input is expanded to a constant array with the same dimensions as the other inputs. The parameters in `N` must be positive integers.

The discrete uniform pdf is

`$y=f\left(x|N\right)=\frac{1}{N}{I}_{\left(1,...,N\right)}\left(x\right)$`

You can think of y as the probability of observing any one number between 1 and n.

Examples

For fixed `n`, the uniform discrete pdf is a constant.

```y = unidpdf(1:6,10) y = 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000```

Now fix `x`, and vary `n`.

```likelihood = unidpdf(5,4:9) likelihood = 0 0.2000 0.1667 0.1429 0.1250 0.1111```

Extended Capabilities

C/C++ Code GenerationGenerate C and C++ code using MATLAB® Coder™.

Introduced before R2006a