In [ ]:
import numpy as np
import matplotlib.pyplot as plt
In [ ]:
#model the knowledge acquisition by manually define the data, AI skills
#steps = np.repeat(np.arange(6), [1, 3, 4, 4, 5, 3])
steps = np.repeat(np.arange(6), np.random.randint(5, 15, size=6))
steps
Out[ ]:
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])
In [ ]:
plt.figure(figsize=(6, 3))
t_t = np.arange(len(steps))
plt.step(t_t, steps, where='post', linestyle= '--', color= 'crimson', linewidth=3)
plt.grid()
plt.show()
#final will have questions on this
In [ ]:
# economic situation
# 80:20 rule is called the power law, long tail
$$ y(x, \alpha)= \alpha(1+x)^-(\alpha+1) $$
In [ ]:
#define power law function describing poor and rich
def lomax_pdf(x, alpha):
outcome = alpha*(1+x)**(-(alpha+1))
return outcome
In [ ]:
#s means wealth level
s= np.linspace(1, 10, 100)#sample size
alpha = 1.5
prob= lomax_pdf(s, alpha)
In [ ]:
#visualize
plt.figure(figsize=(7, 3))
plt.plot(s, prob, color= 'green', linestyle= ':')
plt.axvline(x=1, color= 'grey', linestyle= '--', linewidth=1.3)
plt.axvline(x=6, color= 'red', linestyle= '--', linewidth=1.3)
plt.axvline(x=10, color= 'grey', linestyle= '--', linewidth=1.3)
plt.fill_between(s, prob, where=(s>=1)&(s<=6), color='skyblue', alpha=0.4)
plt.fill_between(s, prob, where=(s>=6)&(s<=10), color='gold', alpha=0.4)
plt.xlabel('Wealth level')
plt.ylabel('Probability')
plt.grid()
plt.show()
In [ ]: