mirror of
https://github.com/fenago/data-science.git
synced 2026-11-01 19:44:50 +00:00
4.9 KiB
4.9 KiB
In [ ]:
import matplotlib.pyplot as pltIn [ ]:
# list of all xs
x = list(range(1, 11))In [ ]:
print(x)In [ ]:
# pmf
p_X_x = [1/len(x)] * len(x)In [ ]:
# sums to
print(p_X_x)In [ ]:
plt.bar(x, p_X_x)
plt.xlabel('X')
plt.ylabel('P(X=x)')In [ ]:
import numpy as np
import scipy.stats as statsIn [ ]:
# range of xs
x = np.linspace(-10, 10, 100)In [ ]:
# first normal distribution with mean = 0, variance = 1
p_X_1 = stats.norm.pdf(x=x, loc=0.0, scale=1.0**2)
# second normal distribution with mean = 0, variance = 2.25
p_X_2 = stats.norm.pdf(x=x, loc=0.0, scale=1.5**2)In [ ]:
plt.plot(x,p_X_1, color='blue')
plt.plot(x, p_X_2, color='orange')
plt.xlabel('X')
plt.ylabel('P(X)')