-
Notifications
You must be signed in to change notification settings - Fork 7
/
Descriptive-Stat.py
31 lines (27 loc) · 1.08 KB
/
Descriptive-Stat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#Load the packages
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats
%matplotlib inline
def descriptive_stats(distribution):
dist = np.array(distribution)
print('Descriptive statistics for distribution:\n', dist)
print('Number of scores:', len(dist))
print('Number of unique scores:', len(np.unique(dist)))
print('Sum:', sum(dist))
print('Min:', min(dist))
print('Max:', max(dist))
print('Range:', max(dist)-min(dist))
print('Mean:', np.mean(dist, axis=0))
print('Median:', np.median(dist, axis=0))
print('Mode:', scipy.stats.mode(dist)[0][0])
print('Variance:', np.var(dist, axis=0))
print('Standard deviation:', np.std(dist, axis=0))
print('1st quartile:', np.percentile(dist, 25))
print('3rd quartile:', np.percentile(dist, 75))
print('Distribution skew:', scipy.stats.skew(dist))
plt.hist(dist, bins=len(dist))
plt.yticks(np.arange(0, 6, 1.0))
plt.title('Histogram of distribution scores')
plt.show()
descriptive_stats([ 1, 4, 5, 6, 8, 8, 9, 10, 10, 11, 11, 13, 13, 13, 14, 14, 15, 15, 15, 15 ])