# Chapter 24 notebook: Signal Processing: Sampling, Resolution, and Spectral Judgment

**Goal:** Separate spectral display spacing from information acquired and plan sampling before aliasing occurs.

**Start with:** Rules 24.1.1, 24.1.4, 24.2.2. Use a calculator or the optional Python lab. Programming is optional for the workbook; the Jupyter version requires a Python 3 kernel. All lab numbers are constructed practice inputs, not observed data.

**Source:** [Finished Chapter 24](../skills/math-thumb-signal-processing/references/chapter.md) from *Mathematical Rules of Thumb*. Numbered rules, classifications, and the decision path come from the book. The lab, exercises, answer key, and worksheet prompts are companion additions.

## 1. Frame your decision

Write a question in which an answer would change something you do. Gather: Sample rate; acquired sample count and duration; signal bandwidth; anti-alias filtering; window; tone spacing or event duration; amplitude/power units.

- My question and intended decision:
- Known inputs and units:
- Required accuracy or threshold:
- What I expect before calculating:
- What I still need to find out:

Use the lab as a worked starting point if you do not yet have your own problem. For notation or prerequisites, ask the chapter skill to explain only the concept blocking the next step.

## 2. Choose a route

- **Are analog or preexisting digital components above the new Nyquist limit?** Filter before sampling or decimation; after folding, recovery is not generally possible.
- **Is the question about bin labels or resolving components?** Use \(f_s/N\) for labels and acquired duration plus window width for resolution.
- **Does a tone fail to land on a bin?** Choose a taper, correct coherent gain and off-bin scalloping for tone amplitude, and apply ENBW only when the noise-density scaling requires it.
- **Does a denser spectrum look more detailed?** Check whether new samples were acquired or only zeros were appended.
- **Does the signal change in time?** Select STFT windows against both event duration and tone spacing; use more than one scale when necessary.
- **Is a level stated in decibels?** Identify power versus amplitude, reference level, impedance, and one-sided or RMS conventions before converting.
- **Is a PSD unstable?** Vary Welch segment length, quantify effective averaging, and report confidence rather than hiding variance with overlap.
- **Is a filter high order or zero phase?** Use SOS for numerical realization and reserve forward–backward application for offline records with explicit edge treatment.

**Chapter-specific stop check:** A denser FFT display does not add observations or remove leakage. Specify window corrections and anti-alias filtering before treating spectrum values as measurements.

## 3. Work the lab

A record has 1,000 acquired samples at 1,000 Hz: its duration is 1 s and its unpadded FFT spacing is 1 Hz. Padding to 8,000 points makes the displayed spacing 0.125 Hz while leaving acquired duration at 1 s. Two tones 0.2 Hz apart are not made resolvable by padding. A rough 1/delta_f scale suggests at least 5 s of acquisition, with the selected window, noise, and resolution criterion determining what is actually sufficient.

Predict the sign and scale before running the code. Then change one input and explain why the result moves. The code checks the constructed example; it does not prove the rule for every possible input. Code assertions may describe the example's chosen regime, so inspect them before changing that regime.

```python
sample_rate, acquired, transform_length = 1000.0, 1000, 8000
assert sample_rate > 0 and transform_length >= acquired > 0
duration = acquired/sample_rate
original_spacing = sample_rate/acquired
padded_spacing = sample_rate/transform_length
tone_separation = 0.2
print(f"Acquired duration: {duration:.3f} s; original spacing: {original_spacing:.3f} Hz")
print(f"Padded display spacing: {padded_spacing:.3f} Hz; rough duration scale for 0.2 Hz: {1/tone_separation:.1f} s")
```

**My prediction, observed result, and explanation:**

_Record your work here._

## 4. Practise without the answers

### Exercise 1

At 1,000 samples/s, an unfiltered 600 Hz sinusoid is sampled. What alias frequency appears?

**My approach, assumptions, calculation, and check:**

_Write your attempt here._

### Exercise 2

A voltage amplitude rises by a factor of ten at fixed impedance. Give amplitude and power changes in dB.

**My approach, assumptions, calculation, and check:**

_Write your attempt here._

### Exercise 3

A live controller proposes forward-backward filtering to remove phase lag. Why is that workflow unsuitable?

**My approach, assumptions, calculation, and check:**

_Write your attempt here._

**Coaching prompt:** “Use the Chapter 24 skill to help me with Exercise 2. Ask for my attempt, give one useful hint if I need it, and help me check the assumptions before showing the answer.”

## 5. Answer key and reasoning

Read this after attempting the exercises, or use it immediately if you prefer a complete walkthrough. An answer is complete only when its assumptions and stopping point are clear.

### Answer 1

It folds to |600-1000|=400 Hz. Filtering after sampling cannot generally distinguish it from an original 400 Hz component.

### Answer 2

20 × log10(10)=20 dB in amplitude. Power rises by 100, giving 10 × log10(100)=20 dB.

### Answer 3

The backward pass needs future samples or a completed record. It is an offline operation with edge effects and a changed magnitude response, not a causal live filter.

## 6. Build the complete chapter toolkit

The new lab samples the chapter; the following checklist covers all 13 rules. Study one thematic group at a time. A large group can take several sessions.

- **Acquire Enough Information Before Transforming It:** work with rules 24.1.1, 24.1.2, 24.1.3, 24.1.4.
- **Interpret a Spectrum Without Manufacturing Detail:** work with rules 24.2.1, 24.2.2, 24.2.3, 24.2.4.
- **Estimate Spectra and Implement Filters Safely:** work with rules 24.3.1, 24.3.2, 24.3.3, 24.3.4, 24.3.5.

For each selected rule, read its equation, explanation, and worked use in the source. Reproduce that example; change one input; then change one assumption so the rule is no longer justified. Record the result and what check catches the failure. Historical examples remain labeled and qualified as in the source.

Read each complete numbered profile in the [chapter reference](../skills/math-thumb-signal-processing/references/chapter.md) before applying it. The cues below abbreviate the graph metadata; they are not complete conditions. Change the status only after doing the practice described below.

| Rule | Book role | First assumptions to inspect | Practice status |
|---|---|---|---|
| 24.1.1: Sample above twice the highest frequency with a guard band | Independent | sampled signal model;  known sampling rate | new |
| 24.1.2: Low-pass before every downsampling step | Workflow | sampled signal model;  known sampling rate | new |
| 24.1.3: Compute FFT bin spacing as sample rate over transform length | Independent | sampled signal model;  known sampling rate | new |
| 24.1.4: Increase record duration to improve true frequency resolution | Independent | sampled signal model;  known sampling rate | new |
| 24.2.1: Window noncoherent records before spectral measurement | Workflow | sampled signal model;  known sampling rate | new |
| 24.2.2: Use zero padding for spectral interpolation, not added resolution | Workflow | fixed observed record;  unchanged windowed samples | new |
| 24.2.3: Choose STFT window from the shortest event and closest tones | Workflow | sampled signal model;  known sampling rate | new |
| 24.2.4: Twenty decibels means tenfold amplitude or hundredfold power | Independent | positive ratio;  declared reference | new |
| 24.3.1: Trade Welch segment length against PSD variance | Specialized | sampled signal model;  known sampling rate | new |
| 24.3.2: Start Welch averaging with Hann windows and fifty-percent overlap | Specialized | sampled signal model;  known sampling rate | new |
| 24.3.3: Use equivalent noise bandwidth when converting FFT noise to density | Specialized | sampled signal model;  known sampling rate | new |
| 24.3.4: Implement moderate-to-high-order IIR filters as second-order sections | Specialized | sampled signal model;  known sampling rate | new |
| 24.3.5: Use forward-backward filtering only for offline zero-phase work | Workflow | sampled signal model;  known sampling rate | new |

For a completed row, record: **rule number / my new input / mathematical claim type / verified assumptions / calculation / check / valid use / rejected use / next step**. “Practised” means you worked an example. “Demonstrated” means you can explain a valid use, transfer it, and reject a misuse without the answer key.

## 7. Apply it to your own problem

Return to your opening question. Choose the smallest rule set that can settle it. Use the book's independent/workflow/specialized classification separately from the claim type (exact, approximate, bound, diagnostic, or heuristic).

- Selected rule number(s) and reason:
- Assumptions that hold, fail, or remain uncertain:
- Substitution with units:
- Result and error, uncertainty, or bound:
- Independent check or limiting case:
- Decision this supports:
- Stop here, do a named next calculation, or gather missing information:

## 8. Transfer and continue

Useful nearby chapters: Chapter 3: trigonometry; Chapter 15: information theory; Chapter 25: control theory. Bring the question, units, assumptions, result type, and uncertainty to the next chapter. Choose a bridge only when it supplies an operation you actually need.

**Completion check:** Explain this chapter's lab in your own words; solve one changed-input exercise; reject one invalid use; and produce a decision record for your own problem. If one check fails, revisit that part of the chapter rather than marking every rule complete.
