Skip to content
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

25 lines (18 sloc) 579 Bytes
Code by Tae-Hwan Hung(@graykode)
import numpy as np
from matplotlib import pyplot as plt
def uniform(x, a, b):
y = [1 / (b - a) if a <= val and val <= b
else 0 for val in x]
return x, y, np.mean(y), np.std(y)
x = np.arange(-100, 100) # define range of x
for ls in [(-50, 50), (10, 20)]:
a, b = ls[0], ls[1]
x, y, u, s = uniform(x, a, b)
plt.plot(x, y, label=r'$\mu=%.2f,\ \sigma=%.2f$' % (u, s))
You can’t perform that action at this time.