Solution
= Solution
The <risk set> at event time $a_j$ contains individuals still under observation and event-free immediately before $a_j$. For group $k$ its size is
$$
r_j^{(k)}=\sum_{i=1}^n\mathbf1\{g_i=k,,x_i\geq a_j\}.
$$
The use of $\geq$ keeps the individual who experiences the event at $a_j$ in the risk set just before that event.