11 probdist_pick(struct probdist
*pd
)
13 assert(probdist_total(pd
) >= 0);
14 /* TODO: float random */
15 float stab
= fast_frandom() * probdist_total(pd
);
16 //fprintf(stderr, "stab %f / %f\n", stab, pd->items[pd->n - 1]);
17 for (int i
= 0; i
< pd
->n
; i
++) {
18 if (stab
<= pd
->items
[i
])
21 //fprintf(stderr, "overstab %f (total %f, sum %f)\n", stab, pd->items[pd->n - 1], sum);