11 BinaryIndexedTree<...> L;
27 for (
int j = 1; j <= n; ++j)
30 auto x = Segment(0, m, j);
57 lambda_r = r(t) * total;
59 lambda = lambda_r + P.size() * (P.size() - 1);
62 std::exponential_distribution<> exp_dis(lambda);
63 auto delta_t = exp_dis(generator);
65 std::uniform_real_distribution<> unif_dis(0.0, 1.0)
if (unif_dis(gen) < lambda_r / lambda)
73 common_ancestor_event();
86 R2_break_between_segments();
87 R3_break_within_segments();
88 R4_update_population();
95 std::uniform_real_distribution<> unif_dis(1, L.total());
96 auto h = unif_dis(generator);
100 auto k = right(y) - L.total(y) + h - 1 x = prev(y)
104 R3_break_within_segments();
108 R2_break_between_segments();
112 auto R2_break_between_segments()
116 next(x) = big_lambda;
117 prev(y) = big_lambda;
121 R4_update_population();
127 auto R3_break_within_segments()
131 z = Segment(k, right(y), node(y), big_lambda, next(y));
132 if (next(y) != big_lambda)
136 next(y) = big_lambda;
140 L[y] += k - right(z);
143 auto R4_update_population()
146 L[z] = right(z) - left(z) - 1;