December 2017
Intermediate to advanced
386 pages
10h 42m
English
We start this example by simulating populations of males and females, according to the known parameters for the distribution of heights in each subpopulation. Since heights are normally distributed, we use the norm object from the scipy.stats module to generate the data. For example, the male population is generated with the following statement:
mdata = mdist.rvs(size=nm)
After the data is generated, we issue the plt.figure(figsize=(12, 4)) function call, which sets the figure dimensions. The histogram is then generated by executing the following code:
plt.subplot(1,2,1)plt.hist([mdata, fdata], bins=20, label=['Males', 'Females'])plt.legend()plt.xlabel('Height (inches)')plt.ylabel('Frequency')
Since we want the plots to appear ...
Read now
Unlock full access