def odds_of_factor_between(m, n):
# Returns the odds that there's a factor with size between m and n digits inclusive
odds = 0
for d in range(m, n+1):
odds += 1/d
return odds
...
def analyze_ecm_nfs_xover(digit_level, nfs_hours, include_missed_factors=1/2):
# This assumes that ECM has been run to one full t-level at the digits-5 level
odds_of_factor = odds_of_factor_between(digit_level-4, digit_level)
missed_factor_odds = exp(-1) * odds_of_factor_between(digit_level-9, digit_level-5)
# While the lower level ECM may have missed a factor, there's also a chance for it to find a
# factor larger than digits-5. In lieu of actually quantifying those odds, we merely fudge off
# some of the missed factor odds.
missed_factor_odds *= include_missed_factors
odds_factor_exists = odds_of_factor + missed_factor_odds