# unidcdf

Discrete uniform cumulative distribution function

## Syntax

`p = unidcdf(x,N)p = unidcdf(x,N,'upper')`

## Description

`p = unidcdf(x,N)` returns the discrete uniform cdf at each value 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 maximum observable values in `N` must be positive integers.

`p = unidcdf(x,N,'upper')` returns the complement of the discrete uniform cdf at each value in `x`, using an algorithm that more accurately computes the extreme upper tail probabilities.

The discrete uniform cdf is

$p=F\left(x|N\right)=\frac{floor\left(x\right)}{N}{I}_{\left(1,...,N\right)}\left(x\right)$

The result, p, is the probability that a single observation from the discrete uniform distribution with maximum N will be a positive integer less than or equal to x. The values x do not need to be integers.

## Examples

collapse all

### Compute Discrete Uniform Distribution cdf

What is the probability of drawing a number 20 or less from a hat with the numbers from 1 to 50 inside?

`probability = unidcdf(20,50)`
```probability = 0.4000```