In [ ]:
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
In [ ]:
# simulate students' scores (50, random, 0-100)
scores_int = np.random.randint(0, 101, size=50) # 101 bc we always go one up on the upper bound
print(scores_int)
[92 70 54 57 75 13 24 56 11 68 90 88 46 0 93 91 4 93 92 48 60 25 11 28 72 67 44 49 30 28 52 35 54 33 60 44 11 42 99 47 13 82 93 62 99 20 5 19 2 17]
In [ ]:
# explore the data distribution
sns.histplot(scores_int, color ='skyblue', kde= True)
plt.show()
In [ ]:
# simulate scores that are float for 50 students
scores_float = np.round(np.random.uniform(0, 100, 50),1 ) # with decimals you dont need the higher upper bound, and the 1 is the decimal point length
print(scores_float)
[ 7.9 90.1 34.2 1. 42. 80.2 15.8 66.2 51.2 20.5 9.4 44.4 37.6 64.3 92.6 45.6 49.7 49.4 75.1 85.3 24.8 1.9 97.3 97.1 5.9 13.9 20.4 67.8 8.4 72.8 63.4 84.5 2.1 92.7 60.2 35.6 61.9 89.4 17.6 72.8 20. 90.9 14.4 18.2 37.6 21. 77.8 22.9 47. 68.3]
In [ ]:
# change the distribution
scores_normal = np.round(np.random.normal(loc=80, scale= 5, size=50 ),1) #SD is 5, mean is 80
scores_normal
Out[ ]:
array([88. , 73.2, 78.2, 82.5, 79.7, 72.1, 87.8, 88.5, 87.5, 82.7, 73.8,
74.3, 63. , 75. , 83.1, 72.1, 86.4, 76.3, 76.5, 73.8, 74.8, 82.4,
76.3, 85.2, 79.2, 79.5, 79.7, 84.4, 85.3, 79. , 73.7, 76.9, 85.6,
74. , 74.3, 90.1, 82.2, 80.5, 81.6, 80.4, 78.6, 86.3, 82.4, 85.7,
70. , 85.5, 84.4, 72.7, 75.6, 81.6])
In [ ]:
#explore the distribution
sns.histplot(scores_normal, kde= True)
plt.show()
In [ ]:
!jupyter nbconvert --to html Bana410_01.ipynb
[NbConvertApp] Converting notebook Bana410_01.ipynb to html [NbConvertApp] WARNING | Alternative text is missing on 2 image(s). [NbConvertApp] Writing 322117 bytes to Bana410_01.html