Continuous Uniform Function#
Continuous Uniform Distribution Wiki
$\(
f(x)=
\begin{cases}
\frac{1}{b - a} &\text{for}\, a \le x \le b \\
0 &\text{for}\, x \lt a \,\text{or}\, x \gt b \\
\end{cases}
\)$
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-2, 2, 4001)
a = -1
b = 1
y = np.where((x < a) | (x > b), 0, 1/(b-a))
plt.plot(x, y);