Continuous Uniform Function

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);
../../_images/a74f382463a293a2c07f81076a33bf55cda606d2df11b97e31db63a943395561.png