Solution (source code)

= Solution

Evaluate the <log-likelihood function> on the specified interval, retaining the rate with the largest value. A grid spacing of $0.001$ finds $0.157$; refining locally avoids relying on a coarse-grid location when reporting three significant figures:

``
def evaluate(mu):
    p = initialise_prob(leaves)
    return felsenstein(p, mu, len(leaves), left, right, left_time, right_time)

coarse = np.linspace(.1, 1., 901)
centre = coarse[np.argmax([evaluate(mu) for mu in coarse])]
fine = np.linspace(max(.1, centre-.001), min(1., centre+.001), 2001)
mu_max = float(fine[np.argmax([evaluate(mu) for mu in fine])])
print(f"mu = {mu_max:.3g}; log-likelihood = {evaluate(mu_max):.8f}")
``

\b[The maximum-likelihood estimate is $\boxed{\widehat\mu=0.157}$] to three significant figures, with refined value about $0.156556$ and log-likelihood $-9.86147978$. Under the alternative per-replacement convention this same fitted <transition matrix> has $\widehat q=\widehat\mu/3\simeq0.0521854$; these are equivalent parameterizations, not competing fitted trees.