def remainings(idx, remaining_count, remaining, min_delay): ... a = (remaining / remaining_count - min_delay) / (remaining_count - 1) ... b = min_delay - a ... return a * idx * idx + b * idx ... import random min_delay = random.random() remaining = random.random() remaining_count = int(random.random() * 64) remainings(0, remaining_count, remaining, min_delay) 0.0 remainings(1, remaining_count, remaining, min_delay) - min_delay 0.0 remainings(remaining_count, remaining_count, remaining, min_delay) - remaining 2.55351295663786e-15
parts moved around to elide mistakes ok, the final issue is there are remaining_count + 1 instances rather than remaining_count ... one at eta and one with remaining left .... ummmm i think that's in line with how remaining_count is calculated. one of them would be part of a different one-sided window. could be wrong.