Chapter 1 worked answers: Understanding Data Analysis
On this page
Compare your reasoning after an attempt. Different valid implementations are welcome when they preserve the observation set and the stated meaning.
B2-01-E01 · Define the denominator
Calculate the pooled attendance proportion. Report the denominator and explain why it is not a count of distinct people.
There are 42 attendances among 60 registrations. Repeated people could contribute several registrations.
registered=[20,10,30]
attended=[15,9,18]
rate=sum(attended)/sum(registered)
assert rate==.7
print(rate)0.7
B2-01-E02 · Investigate an impossible count
Reject this record before calculating a valid attendance rate. Explain the violated assumption.
The task defines attendances as a subset of registrations. Eleven among eight violates that contract; clipping would conceal the issue.
registered=8
attended=11
valid=0 <= attended <= registered
assert valid is False
print(valid)False
B2-01-E03 · Write a bounded comparison
Compute visits per open day for each period and identify the higher period. State why total visits answers a different question.
February has more visits but January has more visits per open day. Exposure defines the comparison.
records=[{"period":"Jan","visits":10,"open_days":2},{"period":"Feb","visits":18,"open_days":6}]
rates={r["period"]:r["visits"]/r["open_days"] for r in records}
assert rates=={"Jan":5.,"Feb":3.}
print(rates){'Jan': 5.0, 'Feb': 3.0}
Return to practice
Change one supplied input, predict the effect and rerun your own implementation. Return to the exercise prompts to identify a task you can now explain independently.