util_rand_resp#

  • Series: lecture-python.myst

  • File: lectures/util_rand_resp.md

  • Audit date: 2026-08-26

  • Corpus snapshot: e25fdf2345

  • Categories audited: writing, math, code, figures, references, links (JAX out of scope)

  • Overall score: 7.3 / 10

  • Priority: HIGH

Score breakdown#

Category

Score

One-line note

Writing

4/10

qe-writing-003 ×5; qe-writing-002 ×5; qe-writing-005 ×3, +2 more.

Math

4/10

qe-math-010 (proposed) ×113; qe-math-014 (proposed) ×2; qe-math-009 ×4.

Code

7.5/10

qe-code-001 ×6.

JAX

out of scope

JAX rules target lecture-jax.

Figures

9.5/10

qe-fig-008 ×3.

References

9/10

qe-ref-001 ×1.

Links

10/10

no mechanical violations detected.

Admonitions

N/A

no admonitions, exercises or solutions.

Issues#

Critical#

None found.

High severity#

  • [qe-code-001] (reviewer) — Follow PEP8 unless closer to mathematical notation. Count: 6. Lines: 302, 412, 421, 526, 603, 604. Example: 412-413 build constant arrays with a comprehension whose loop variable is never used, y1 = for i in x0], where np.full_like(x0, π) is meant - and its i shadows the loop index used nine lines later at 421; the same two lines recur at 530-531 and 623-624. 421-424, 542-545 and 636-639 iterate for i in range(len(nv)) where enumerate is idiomatic, and their expression contains n * (nv[i] / n), in which the n cancels. 526-527 binds y to the truth border and then the loop at 543 rebinds y to each iso-variance curve, so ax.fill_between(x, y, z, ...) at 538 works only because it happens to run before the loop - the same pattern at 619 and 637. 603 names a module-level function f, which is also the utility shifter \(f(\phi_i)\) in the maths at 325 and in the legends at 307-311, and 604 gives it a single-quoted docstring where the file’s only other docstring convention is absent entirely. 302-304 reach for pow(x2, 0.5) and pow(x3**2 - 0.4, 0.5) where 605 uses np.sqrt and 302 also uses **2 in the same expression. Line 422 is 88 characters, and 522-524 and 615-617 redefine π, n and nv at module scope, shadowing the parameters of plot_iso_variance_curves.

  • [qe-math-010 (proposed)] — Blackboard \mathbb{P}, \mathbb{E}, \mathbb{V} with braces. Count: 113. Lines: 41, 42, 50, 64, 66, 73, 82, 84, 89, 108, …. Example: non-blackboard \text{Pr}.

  • [qe-writing-002] (reviewer) — Keep writing clear, concise, and valuable. Count: 5. Lines: 24, 56, 396, 698, 702. Example: line 24 is a 45-word sentence whose second half is seven consecutive citations; 56 is filler (“At this point, we describe some concepts proposed by various researchers”) under a heading that already says “Zoo of concepts”; and the same announcement is made three times - “We use Python code to draw iso-variance curves” (396), “We’ll enlist Python code to help us” (499), “We can use Python to show the optimal model design” (600). Line 698 substitutes an adverb for the argument (“under a utilitarian framework, this is obviously contradictory”) where 700-702 then supplies the actual reason, and 702 opens with an “It” whose nearest antecedent is “the randomized response design” rather than the privacy measure being criticised.

  • [qe-writing-003] (reviewer) — Maintain logical flow. Count: 5. Lines: 390, 481, 522, 546, 658. Example: line 390 says variance falls with “the distance of \(\text{Pr}(A|\text{yes})\) and/or \(\text{Pr}(A|\text{no})\) from \(r_A\)”, but \(r_A\) is never defined anywhere in the lecture - the symbol wanted is \(\pi_A\) (50, 64, 66, 73, 243, 370), and \(r\) is already the response variable (47, 60), so \(r_A\) reads as A’s response. The Greenberg material at 652-678 repeats 140-170 almost verbatim - four displays and three sentences - with duplicate labels distinguished only by doubling the last letter (eq:util-rand-seven-a versus -seven-aa, -seven-b/-seven-bb, -eight-a/-eight-aa, -eight-b/-eight-bb), and Lanke’s criterion is likewise displayed twice under eq:util-rand-five-a (125) and eq:util-rand-five-b (507). Line 481 calls {eq}`eq:util-rand-nine-b` “Assumption” and 286 calls 9a and 9b “Assumptions”, in a lecture that has two real {prf:assumption} directives with {prf:ref} labels at 178 and 184 - so “assumption” points at two different kinds of object. And the twenty lines of plot_iso_variance_curves (407-431) are pasted inline twice more with small edits (522-554, 615-647) rather than parameterised, so the magic array nv and the iso-variance expression exist in three places; the three punchline points \(X\), \(Z\) and \(Q\) that carry the lecture’s whole argument are hard-coded scatter coordinates (546-547, 640) rather than solved from the truth border and the variance formula.

  • [qe-writing-008] — Remove excessive whitespace between words. Count: 13. Lines: 376, 390, 465, 467, 469, 479, 666. Example: 2 spaces.

Medium severity#

  • [qe-fig-008] — Use lw=2 for line charts. Count: 3. Lines: 423, 544, 638. Example: plot() without lw=.

  • [qe-math-009] (reviewer) — Choose simplicity in mathematical notation. Count: 4. Lines: 42, 263, 381, 441. Example: the lecture names its own simpler notation and then never uses it: line 290 says “writing \(p\) for \(\text{Pr}(A|r_i)\)”, the figure legends at 307-311 use it ($U_i = -p + f(\phi_i)$), and every one of the 113 mathematical occurrences afterwards spells the operator out in full. The cost is visible at 263, a single display running past 230 characters that writes \text{Pr}(A|\text{yes}) and \text{Pr}(A|\text{no}) five times inside a fraction of fractions of partial derivatives; the same display with \(p\) and \(q\) would be two lines. The operator itself is spelled three ways - \text{Pr} (41, 50, …), \text{ Pr} with a leading space inside the braces (381, 385, 477, 483, 489, 509), and bare Pr( in the axis labels (315, 350, 426, 549, 642). The complement of \(A\) is written A^{'} with braced prime throughout (42, 50, 60, 66, 82, 84, 95, 153, 158, 167, 663, 677, 692) where \(A^c\) is both shorter and unambiguous - and 119 quotes Lanke using the plain A' for the same set. And 441 introduces “\(\pi=0.3\)” for the parameter the rest of the lecture calls \(\pi_A\).

  • [qe-math-014 (proposed)] (reviewer) — Braces {…} for events, parentheses (…) for sets. Count: 2. Lines: 41, 50. Example: every probability in the lecture is written with parentheses, and the arguments are of two different kinds. \text{Pr}(\text{yes}|A) and \text{Pr}(\text{no}|A^{'}) (41-42, 89, 108, 147, 153, 161, 167, 563, 657, 663, 671, 677, 694) condition on the set but the argument is the event that the respondent answers yes or no, which the rule asks to be written in braces - \(\mathbb{P}\{\text{yes} \mid A\}\). \text{Pr}(A|r) and \text{Pr}(A|\text{yes}) (50, 64, 66, 114, 124, 136, 197, 216, 243, 719) have the named set \(A\) as their argument, which the rule asks to keep parentheses. So the lecture happens to be right for half of its 113 occurrences and wrong for the other half, with no signal that the two are different kinds of statement - and the same display at 73 puts one of each on either side of the equals sign.

  • [qe-writing-005] (reviewer) — Use bold for definitions, italic for emphasis. Count: 3. Lines: 158, 258, 680. Example: the lecture’s defined terms are in quotation marks rather than bold: 258 defines the central object of the whole lecture as ‘Equation {eq}`eq:util-rand-eleven` defines a “truth border”’, and “limited hazard” (158, 668), “private protection” (133), “optimal survey design” (461) and “reluctant” (493) all follow suit - only expected utility at 22 is bolded. Conversely 680 uses bold for pure emphasis, “a respondent commits himself or herself to answer truthfully … before randomly selecting the question”, where the lecture’s own correct instance of emphasis-in-italic is at 723.

  • [qe-writing-007] (reviewer) — Use visual elements to enhance understanding. Count: 4. Lines: 54, 400, 465, 572. Example: the optimal design is defined at 465-471 as the point where “the intersection of areas above all truth borders” touches the lowest iso-variance curve, and 473 says the estimator is “pinned down by an individual who is the least willing to volunteer a truthful answer” - and no figure ever shows more than one respondent. fig-truth-borders (292-319) draws three curves, but they are three functional forms of one utility function, not three individuals, so the binding-constraint argument that the whole “Optimal survey” section rests on has no picture. Second, {eq}`eq:util-rand-one` maps a design \((\text{Pr}(\text{yes}|A), \text{Pr}(\text{yes}|A'))\) into the posterior pair that every figure plots, and the design space is never drawn - so when 400-404 claims Warner’s model “is less flexible than the unrelated question model” the reader has only the magenta curve at 417 and no account of what it is the boundary of. Third, the “Zoo of concepts” (54-170) lists five competing privacy measures as five bare displays with no comparison, and the criticisms section 495 lines later has to re-derive each one before attacking it; one table with a row per measure would carry both halves. And the lecture uses {prf:assumption} twice at the start (178, 184) and then no admonition in the remaining 520 lines, though 572, 594-598 and 696-702 are each a one-line verdict that a {note} would set off.

Low severity#

  • [qe-ref-001] — Use correct citation style. Count: 1. Lines: 723. Example: {cite} in narrative flow: ‘of {cite}’.

Strengths#

  • The lecture is organised as claim and rebuttal, and the pairing is explicit: each privacy measure gets a subsection in “Zoo of concepts” (58-170) and a matching subsection in “Criticisms of proposed privacy measures” (501-702) - Lanke, Leysieffer-Warner, Chaudhuri-Mukerjee, Greenberg - so a reader can hold one measure at a time.

  • The two behavioural premises are hoisted into named {prf:assumption} directives at 178-191 with :label: fields, and the second one cross-references the first with {prf:ref} rather than restating it - so “the cost is the discomfort” is a link, not a duplicate.

  • The positive slope of the truth border is derived rather than assumed: {eq}`eq:util-rand-twelve` at 262-264 differentiates the indifference condition, and 266-274 then gives the economic reading in three steps - a rise in \(\text{Pr}(A|\text{yes})\) lowers the utility of truth, so \(\text{Pr}(A|\text{no})\) must rise to lower the utility of lying.

  • The shape restrictions on the iso-variance curves are stated as the first and second derivatives {eq}`eq:util-rand-fourteen-a` and {eq}`eq:util-rand-fourteen-b` (380-386) with their signs, and 390-392 reads exactly the two conclusions those signs give - upward-sloping and concave - before any curve is drawn.

  • The Lanke criticism is made geometrically and is checkable: 509-513 says Lanke’s criterion drives the design to point \(X\) with \(\text{Pr}(A|\text{no})\) pinned at 0, and fig-lanke-analysis (515-554) puts \(X\) and \(Z\) on the same axes as the truth border and the iso-variance family, so the reader can see that \(Z\) is inside the truth-telling region and on a lower curve.

  • All five figures carry mystnb caption and name metadata (293-297, 331-335, 448-452, 516-520, 609-613) and every one is cited from the prose with {numref} (290, 328, 445, 511, 650) - the lecture is the cleanest in this batch on qe-fig-005.

  • The Greenberg criticism at 684-702 is the sharpest argument in the lecture: it takes the “limited hazard” measure at face value, constructs the design that makes it arbitrarily small (“Say the word ‘no’”), and then shows that the same design forces a truthful member of \(A\) to reveal themselves completely - so the measure is minimised exactly where privacy is destroyed.