Choose the pattern from the question
A mean describes a central level. A maximum describes the largest sampled value. A threshold count describes how many samples satisfy a rule. None of these quantities is a substitute for the others.
Week 06 / Organise observations
Decide what the report needs before calculating a statistic.
We can now collect repeated observations and stop deliberately. The next question is what to tell a reader about those observations.
Two current logs are [4, 4, 4, 4] A and [2, 2, 4, 8] A. Both have a mean of 4 A. Our reporting rule flags sampled values strictly above 6 A.
Start with the problem
Give each log a one-line report. What must you add to the mean so that a reader notices the difference?
Running totals, counts and maximum trackers answer different questions. We will combine these small patterns instead of treating the average as the whole result.
By the end: Choose and justify a summary that reveals the 8 A sample, and describe what it cannot tell us about unsampled moments.
A mean describes a central level. A maximum describes the largest sampled value. A threshold count describes how many samples satisfy a rule. None of these quantities is a substitute for the others.
Mean = sum / count. If invalid values are removed later in the course, the denominator must count retained values. For now, all supplied values are valid and equally spaced.
Two high samples indicate two observations above the threshold. Turning that into an overload duration needs timing and an explicit assumption about the behaviour between samples. Keep the claim narrow.
Read the example alongside the explanation. Run it in a new notebook cell and change one input to see how it behaves.
readings_a = [4, 4, 4, 8, 0]
total = 0
count = 0
peak = readings_a[0]
over_limit = 0
for value in readings_a:
total += value
count += 1
if value > peak:
peak = value
if value > 6:
over_limit += 1
print('Mean, peak, high samples:', total / count, peak, over_limit)Mean, peak, high samples: 4.0 8 1
A sum remembers accumulated amount; a count remembers how many; a search remembers whether or where a match was found; a maximum remembers the greatest value seen so far. These are different questions about the same observations.
For readings −5, −2 and −7, create separate columns for running sum, count and maximum. For a nonempty sequence initialise the maximum from its first reading.
Predict before running. Why does maximum = 0 give a misleading result when all readings are negative?
The correct maximum is −2. An initial value must match the question and allowed inputs. For no readings, define a separate no-data result rather than inventing a maximum.
Change one thing. Change the question from maximum to first reading above a threshold. Explain why stopping early is now possible and why it would be wrong when finding the overall maximum.
Türkçe: Çözüm kalıbını istenen bilgiye göre seç. Başlangıç değeri, özellikle negatif ve boş girdilerde, sonucun anlamını belirler.
Each example changes something about the same problem. Open the ones you want to explore and follow the worked explanation.
[4, 4, 4, 4, 4] A; flag > 6 A
Question: Predict mean, peak and high-sample count.
The three summaries agree that no sampled value exceeded the threshold.
[4, 4, 4, 8, 0] A; flag > 6 A
Question: Can the mean distinguish this log from the steady log?
The mean alone hides the spike. Preserve a peak or event count when those answer the engineering question.
[6, 6, 6] A; flag strictly > 6 A
Question: How many values are flagged under the stated rule?
Changing > to >= changes the policy. Your report should state which rule it uses.
Interactive walkthroughs of Problem-Solving Patterns. Enable JavaScript to step through code, variables, collections and output. The companion notebook remains available below.
Use the notebook to try the ideas yourself. The steps below connect this week's example to the programming practice.
Something to take away: Two contrasted logs, their mean/peak/count summaries, and a short recommendation supported by the appropriate metric.
Read the notebook's teaching cells before these exercises.
Use the notebook's core and optional labels to choose your workload. This activity fits within guided class time.
Notes stay in this browser. Download a copy to keep them.
Ask AI for a current-log summary. If it returns only an average, challenge it with the two equal-mean datasets. Require it to justify each reported metric and define the empty-input behaviour.
You can also review the supplied example with a partner. Use the same inputs to compare the reasoning. Follow the syllabus rules for assessed work.