# Uniform Distribution

 English Português Français ‎Español Italiano Nederlands

## Discrete uniform distribution

A discrete random variable X with a finite number of outcomes ${\displaystyle x_{i}(i=1,2,\dots ,n)}$ is called uniform distribution, if each value of X can occur with an equal probability, which depends on n. The probability density function of a uniform random variable is: ${\displaystyle f(x_{i})=\left\{{\begin{array}{ll}{\frac {1}{n}}\quad &{\text{for}}\ i=1,\dots ,n\\&\\0\quad &{\text{otherwise}}\end{array}}\right.}$

The distribution function for a uniform random variable is: ${\displaystyle F(x)=\left\{{\begin{array}{ll}0\quad &{\text{for}}\ x

The expected value and variance of discrete uniform random variable X are: ${\displaystyle E(X)=\mu ={\frac {1}{n}}\sum \limits _{i=1}^{n}x_{i}}$ ${\displaystyle Var(X)=\sigma ^{2}={\frac {1}{n}}\sum \limits _{i=1}^{n}(x_{i}-\mu )^{2}}$

## Continuous uniform distribution

A continuous random variable X on the interval [a,b] has a uniform distribution if each point in that interval has an equal probability of occurring, the density function will have the following form: ${\displaystyle f(x)=\left\{{\begin{array}{ll}{\frac {1}{b-a}}\quad &{\text{for}}\ a\leq x\leq b\\&\\0\quad &{\text{otherwise}}\end{array}}\right.}$

The distribution function for a continuous uniform random variable is: ${\displaystyle F(x)=\left\{{\begin{array}{ll}0\quad &{\text{for}}\ x The expected value and variance of continuous uniform random variables are: ${\displaystyle E(X)={\frac {b+a}{2}}}$ ${\displaystyle Var(X)={\frac {(b-a)^{2}}{12}}}$ The parameters of a continuous uniform distribution are ${\displaystyle a}$ and ${\displaystyle b}$.

A man arrives at a tram stop, but does not know the schedule of the tram. The tram arrives at that stop every 20 minutes. Define the random variable X: ”waiting time for a tram in minutes”. This random variable can take any value in the interval [0,20]. This implies: P(0 ${\displaystyle \leq }$ X ${\displaystyle \leq }$ 20) = 1, a = 0, b = 20. The random variable ${\displaystyle X=\{}$waiting time${\displaystyle \}}$ will have a uniform distribution. Density of X: ${\displaystyle f(x)=\left\{{\begin{array}{ll}{\frac {1}{20}}\quad &{\text{for}}\ 0 Distribution function: ${\displaystyle F(x)=\left\{{\begin{array}{ll}0\quad &{\text{for}}\ x<0\\&\\{\frac {1}{20}}\cdot x\quad &{\text{for}}\ 0\leq x\leq 20\\&\\1\quad &{\text{otherwise}}\end{array}}\right.}$ The expected value of X is:

 ${\displaystyle E(X)=}$ ${\displaystyle \int \limits _{-\infty }^{\infty }xf(x)\,dx=\int \limits _{0}^{20}x{\frac {1}{20}}\,dx}$ ${\displaystyle {\frac {1}{20}}\left[{\frac {1}{20}}x^{2}\right]_{0}^{2}0={\frac {1}{20}}\left[{\frac {1}{2}}20^{2}-{\frac {1}{2}}0^{2}\right]=10}$

On average the a person will have to wait 10 minutes for a tram. The variance is:

 ${\displaystyle Var(X)}$ ${\displaystyle =\int \limits _{-\infty }^{\infty }(x-\mu )^{2}f(x)\,dx=\int \limits _{0}^{20}(x-10)^{2}\cdot {\frac {1}{20}}\,dx}$ ${\displaystyle ={\frac {1}{20}}\int \limits _{0}^{20}(x^{2}-20x+100)\,dx}$ ${\displaystyle ={\frac {1}{20}}\left[{\frac {1}{3}}x^{3}-{\frac {1}{2}}20x^{2}+100x\right]}$ ${\displaystyle ={\frac {1}{20}}\left[{\frac {1}{3}}20^{3}-{\frac {1}{2}}20^{3}+100\cdot 20\right]=33.33}$

Standard deviation: ${\displaystyle \sigma }$ = 5.77 .The density and the distribution function look like this:

## Discrete Uniform Distribution

The probability density function of discrete Uniform random variable can be illustrated with a histogram. The distribution function of this random variable, on the other hand, will be a step function. A common example of a discrete Uniform random variable are the outcomes associated with the roll of a fair die. The discrete random variable X (= result of the throw) can take integer numbers between 1 and 6. If the dice are “fair”, the probability of each outcome of X is ${\displaystyle f(x_{i})=1/6,i=1,\dots ,6.}$

## Continuous Uniform Distribution

Let us verify whether ${\displaystyle f(x)=\left\{{\begin{array}{ll}{\frac {1}{b-a}}\quad &{\text{for}}\ a\leq x\leq b\\&\\0\quad &{\text{otherwise}}\end{array}}\right.}$ is a density function: First, ${\displaystyle b>a}$ , so f(x) ${\displaystyle \geq }$ 0 for all x, i.e. the function is nonnegative. Furthermore we have: ${\displaystyle \int \limits _{-\infty }^{\infty }f(x)\,dx=\int \limits _{a}^{b}{\frac {1}{b-a}}\,dx=\left[{\frac {x}{b-a}}\right]_{a}^{b}={\frac {b-a}{b-a}}=1.}$ This indicates that f(x) is a density. The distribution function F(x) can be computed as: ${\displaystyle F(x)=\int \limits _{a}^{x}{\frac {1}{b-a}}\,dv=\left[{\frac {v}{b-a}}\right]_{a}^{x}={\frac {x-a}{b-a}}}$ The expected value and the variance for this random variable are: ${\displaystyle E(X)=\int \limits _{a}^{b}x{\frac {1}{b-a}}\,dx=\left[{\frac {x^{2}}{2(b-a)}}\right]_{a}^{b}={\frac {b^{2}-a^{2}}{2(b-a)}}={\frac {(b-a)(b+a)}{2(b-a)}}={\frac {(b+a)}{2}}}$ ${\displaystyle Var(X)=\int \limits _{a}^{b}x^{2}{\frac {1}{b-a}}\,dx-\left({\frac {(b+a)}{2}}\right)^{2}=\left[{\frac {x^{3}}{3(b-a)}}\right]_{a}^{b}-\left({\frac {(b+a)}{2}}\right)^{2}={\frac {b^{3}-a^{3}}{3(b-a)}}-{\frac {b+a}{4}}={\frac {(b-a)^{2}}{12}}}$ The following diagram illustrates the density and distribution function of a continuous Uniform random variable. Density:

Distribution function: