I would look in the directon of SPRT:
https://en.wikipedia.org/wiki/Sequential_probability_ratio_t...