Data Analysis with Python: From Raw Data to Real-World Insights
BOOK 2 · MATHEMATICS & STATISTICS · CHAPTER 5

Chapter 5 exercises: Statistical Reasoning and Randomness

On this page

Attempt these tasks before opening the worked answers. Use the chapter experiment notebook, or import NumPy as np and Pandas as pd in your own notebook. Retain your first attempt and explain each correction.

B2-05-E01 · Compare location summaries

Calculate mean and median and explain the influence of 40.

x=np.array([10.,12.,14.,40.])
One hint after an attempt

Sort the values before identifying the middle.

B2-05-E02 · Compute a conditional probability

Under a fair-die model, calculate P(result>4 | result is odd).

die=np.arange(1,7)
One hint after an attempt

Restrict the outcome space before counting successes.

B2-05-E03 · Separate spread and standard error

Calculate the sample standard deviation and estimated standard error of the mean; state the assumptions for using s/sqrt(n).

x=np.array([4.,6.,8.,10.])
One hint after an attempt

Use n−1 for the sample variance, then divide s by sqrt(n).

B2-05-E04 · Original cultural-production challenge: all six tasks

Complete the original challenge: shapes, means, total, slices, threshold selection, logarithms, spread, square roots and a reproducible random comparison.

books=np.array([[120,150,180,210,190],[80,100,120,160,220],[90,130,170,200,250]])
decades=np.array([1970,1980,1990,2000,2010])
One hint after an attempt

Check totals by rows, then verify the squared deviations independently.

Reflect and get feedback

Explain one result without looking at the code. Identify one boundary case that would change your method. An optional tutor prompt is: “Here is my attempt at B2-05-E04. Give one hint about the violated assumption; do not give the solution yet.” Then use the worked answers.

Teaching edition · verified experiments · PDF and EPUB editions not generated.