Library · The Fiddler: Solutions · Chapter 1

Can You Swim With the Fishes?

Revised PDF handout Report an error

Two koi share a long straight pond. Nemo swims at one mile per hour and Dory at two, and both spend the day going back and forth. A sensor placed in the water records the speed of every fish that passes it. After several days of logging, what average should you expect from the recorded speeds?

The Fiddler, Zach Wissner-Gross, October 2, 2026(original post)

The official solution appears in the post of October 9, 2026, which had not been published when this chapter was written. The answers here are my own.

Solution

The tempting answer is the average of the two speeds, 1.51.5 miles per hour. It is wrong, and the reason is worth more than the arithmetic that replaces it.

The log does not hold one entry per fish. It holds one entry per passing, and the two fish do not pass at the same rate. A fish of speed vv in a pond of length ℓ\ell takes time ℓ/v\ell/v to cross from one end to the other, and it goes by the sensor once on each such trip, so its entries arrive at a rate of v/ℓv/\ell per hour. That rate is proportional to the speed. Dory, swimming twice as fast, appears in the log twice as often.

The two fish bouncing between the ends of the pond, with the sensor fixed at one place. Each dot is an entry in the log. Dory’s path is steeper, so it meets the sensor line twice as often.
The two fish bouncing between the ends of the pond, with the sensor fixed at one place. Each dot is an entry in the log. Dory’s path is steeper, so it meets the sensor line twice as often.

In a long log, then, two entries in every three belong to Dory and one to Nemo, and the average of the recorded speeds weights each speed by itself: 1⋅1+2⋅21+2  =  53.\frac{1 \cdot 1 + 2 \cdot 2}{1 + 2} \;=\; \frac53 .  average recorded speed  =  53  ≈  1.667 miles per hour. \boxed{\ \text{average recorded speed} \;=\; \tfrac53 \;\approx\; 1.667 \text{ miles per hour}. \ }

Neither the sensor nor the fish is behaving oddly. The sampling is simply not uniform over fish, because a fish that moves more gets measured more. The same effect makes a bus stop feel slower than the timetable promises, and makes asking people how large their class is give an answer that is too large. Every observation here is made by something the observed object had to arrive at, and arriving is what the fast do more often.

The computation

The check counts crossings rather than assuming the rate law the argument rests on. A bouncing path is unfolded into a straight one, so a fish starting at x0x_0 with speed ss is at the sensor whenever x0+stx_0 + st is congruent to ±p\pm p modulo twice the pond’s length. The unfolding is itself checked against a brute-force count of the sign changes of the folded path, which is the step most likely to hide an off-by-one.

def crossings_unfold(v, T):
    """times t in [0,T] with the unfolded path x0 + |v| t equal to +-P mod 2L"""
    s, hi, n = abs(v), X0 + abs(v)*T, 0
    for target in (P, -P):
        k_lo = np.ceil((X0 - target)/(2*L))
        k_hi = np.floor((hi - target)/(2*L))
        n += max(0, int(k_hi - k_lo) + 1)
    return n

The two counts agree exactly at every speed tried. Over a long run the fish of speed 11 and 22 produce 20,00020{,}000 and 40,00040{,}000 entries, a ratio of exactly 22, and the logged average comes to 1.6666671.666667.

Extra Credit

Now the pond holds many koi, all starting at the centre, with velocities drawn from a normal distribution of mean 00 and standard deviation 11 mile per hour. The sensor records the speed of every fish that passes it, direction ignored. What value does the average recorded speed approach?

Solution

The counting argument never cared how many fish there were or how their speeds were spread, so it carries over whole. A fish of speed ss passes the sensor at a rate proportional to ss, so in a long log the chance that a given entry belongs to a fish of speed near ss is proportional to ss times how common that speed is among the fish. Writing ff for the density of the fish’s speeds, the log has density g(s)  =  s f(s)E[S],g(s) \;=\; \frac{s\,f(s)}{\mathbb{E}[S]} , the denominator being whatever makes it integrate to one. Averaging against gg gives the single formula that runs both halves of this puzzle: average recorded speed  =  E[S2]E[S].\text{average recorded speed} \;=\; \frac{\mathbb{E}[S^2]}{\mathbb{E}[S]} . With speeds 11 and 22 equally common it returns (1+4)/(1+2)=5/3(1+4)/(1+2) = 5/3, which is the main puzzle again.

Here the velocity VV is standard normal and the speed is S=∣V∣S = |V|. Both moments are standard: E[S2]=E[V2]=1\mathbb{E}[S^2] = \mathbb{E}[V^2] = 1, and E[S]=2/π\mathbb{E}[S] = \sqrt{2/\pi}, the mean of a half-normal. So  average recorded speed  =  12/π  =  π2∗[4pt]≈  1.253 miles per hour \boxed{\ \begin{array}{c} \text{average recorded speed} \;=\; \dfrac{1}{\sqrt{2/\pi}} \;=\; \sqrt{\tfrac{\pi}{2}} \\*[4pt] \approx\; 1.253 \text{ miles per hour} \end{array} \ }

Two things follow worth keeping. The answer is exactly π/2\pi/2 times the average speed of the fish themselves, 2/π=0.798\sqrt{2/\pi} = 0.798, so weighting by speed inflates the figure by about 5757 per cent, and that factor depends on the shape of the distribution rather than its scale.

The second is the shape of the log itself. Multiplying the half-normal density 2/π e−s2/2\sqrt{2/\pi}\,e^{-s^2/2} by ss and normalising gives g(s)  =  s e−s2/2,s>0,g(s) \;=\; s\,e^{-s^2/2}, \qquad s > 0, which is the Rayleigh distribution. The sensor’s log is therefore distributed exactly as the speed of a particle whose velocity is normal in two dimensions rather than one, and the mean of that distribution is π/2\sqrt{\pi/2}.

The speeds of the fish, a half-normal, against the speeds the sensor logs, a Rayleigh. Weighting by speed empties the log of the slow fish and moves the average from \sqrt{2/\pi} to \sqrt{\pi/2} .
The speeds of the fish, a half-normal, against the speeds the sensor logs, a Rayleigh. Weighting by speed empties the log of the slow fish and moves the average from 2/π\sqrt{2/\pi} to π/2\sqrt{\pi/2}.

The computation

Counting crossings for two hundred thousand fish gives a logged average of 1.25701.2570, against E[S2]/E[S]=1.2570\mathbb{E}[S^2]/\mathbb{E}[S] = 1.2570 computed from the same sample. That agreement is the part that matters, since it confirms the weighting without appealing to the normal distribution at all.

The gap from there to π/2\sqrt{\pi/2} is sampling error in the speeds themselves, and it closes with more fish. Twenty million give 1.2532861.253286 against π/2=1.253314\sqrt{\pi/2} = 1.253314, and the ratio of the logged mean to the true mean comes to 1.5708801.570880 against π/2=1.570796\pi/2 = 1.570796.

Report an error on this page

Reports are stored by Netlify. See the privacy note.