Solution (source code)

= Solution

At time $x_i$, the observed number of events is $v_i$ and the exposure to the common instantaneous hazard is the risk-set size $n-i+1$. The likelihood score for a hazard increment therefore equates observed and expected events:
$$
v_i=(n-i+1)\,d\widehat H(x_i).
$$
Thus the <Nelson–Aalen estimator> is
$$
\widehat H(t)
=\sum_{i:x_i\leq t}\frac{v_i}{n-i+1}.
$$
It estimates the <cumulative hazard function> by adding event count divided by current exposure at every observed event time.