October 2019
Beginner to intermediate
674 pages
16h 43m
English
To illustrate this, let's consider the following dataset, which consists of marks that were obtained by 15 pupils for a test scored out of 20:
In [18]: grades = [10, 10, 14, 18, 18, 5, 10, 8, 1, 12, 14, 12, 13, 1, 18]
The mean, median, and mode can be obtained as follows:
In [29]: %precision 3 # Set output precision to 3 decimal places Out[29]:u'%.3f' In [30]: import numpy as np np.mean(grades) Out[30]: 10.933 In [35]: %precision np.median(grades) Out[35]: 12.0 In [24]: from scipy import stats stats.mode(grades) Out[24]: (array([ 10.]), array([ 3.])) In [39]: import matplotlib.pyplot as plt In [40]: plt.hist(grades) plt.title('Histogram of grades') plt.xlabel('Grade') plt.ylabel('Frequency') ...Read now
Unlock full access