Statistical Inference for EveryoneXYZ Homework Edition

⇩ Download ▾

3.6 Computer Examples

This section summarizes how to make histograms and scatter plots with the computer software.

Histograms

from sie import *

Load a sample data set, and select only the Male data...

data=load_data('data/survey.csv')
male_data=data[data['Sex']=='Male']

select only the height data, and drop the missing data (na)...

male_height=male_data['Height'].dropna()

make the histogram

hist(male_height,bins=20)
xlabel('Height [cm]')
ylabel('Number of People')
Show expected output
<matplotlib.text.Text at 0x1085728d0>
Histogram of the class height data in centimeters produced by the sample code: bars from about 155 to 200 cm with the tallest bar of 16 people just above 180 cm.

Scatter Plot

from sie import *

Load a sample data set, and select only the Male data...

data=load_data('data/survey.csv')
male_data=data[data['Sex']=='Male']

select only the height and the width of writing hand data, and drop the missing data (na)...

subdata=male_data[['Height','Wr.Hnd']].dropna()
height=subdata['Height']
wr_hand=subdata['Wr.Hnd']

plot the data

plot(height,wr_hand,'o')
ylabel('Writing Hand Span [cm]')
xlabel('Height [cm]')
Show expected output
<matplotlib.text.Text at 0x1085774d0>
Scatter plot from the sample code of writing hand span against height for the class data: a broad cloud of points between 150-200 cm height and 16-23 cm span, drifting upward to the right.

Adapted from Statistical Inference for Everyone, by Brian Blais (Bryant University), licensed under CC BY-SA 4.0 (dual-licensed under the GNU FDL 1.2 or later; this adaptation uses the CC BY-SA grant). Changes were made; this adaptation is distributed under the same license. License: CC-BY-SA-4.0.

These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or ADA Title II. Every page is built against an automated accessibility gate, and the published editions will meet ADA Title II requirements when they release in late September 2026. If something is unusable, please tell us.