broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    q=Fraction(x['q'],100000); t=Fraction(*x['t']); a=x['assumption']
    if t<0 or t>1 or q<0 or q>1: return 'invalid'
    p=1-q
    if a=='udd':
        tp=1-t*q; mu=q if 1-t*q else None
    elif a=='cfm':
        if p==0: return 'infinite force'
        tp=Fraction(float(p)**float(t)); mu=-math.log(p)
    elif a=='balducci':
        tp=p/(1-(1-t)*q)
        mu=q/(1-(1-t)*q)
    else:
        return 'unknown assumption'
    if mu is None: return 'infinite force'
    return [round(float(tp),8),round(float(mu),8)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['udd mid-year', {'q': 3964, 't': [1, 4], 'assumption': 'udd'}, [0.99009, 0.04003676]], ['udd third of year', {'q': 57411, 't': [1, 3], 'assumption': 'udd'}, [0.80863, 0.70997861]], ['cfm mid-year', {'q': 31716, 't': [3, 4], 'assumption': 'cfm'}, [0.7511717, 0.38149471]], ['cfm third of year', {'q': 35719, 't': [1, 3], 'assumption': 'cfm'}, [0.86303328, 0.44190609]], ['balducci mid-year', {'q': 2891, 't': [2, 4], 'assumption': 'balducci'}, [0.98533299, 0.02933402]], ['balducci third of year', {'q': 37692, 't': [1, 3], 'assumption': 'balducci'}, [0.83219361, 0.50341917]], ['udd full year', {'q': 34482, 't': [1, 1], 'assumption': 'udd'}, [0.65518, 0.52629812]], ['cfm at start', {'q': 29787, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35363671]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 38019, 't': [2, 4], 'assumption': 'udd'}, [0.809905, 0.46942543]], ['udd third of year', {'q': 44263, 't': [1, 3], 'assumption': 'udd'}, [0.85245667, 0.51924047]], ['cfm mid-year', {'q': 36269, 't': [2, 4], 'assumption': 'cfm'}, [0.79831698, 0.45049909]], ['cfm third of year', {'q': 41961, 't': [1, 3], 'assumption': 'cfm'}, [0.83414197, 0.54405499]], ['balducci mid-year', {'q': 22422, 't': [2, 4], 'assumption': 'balducci'}, [0.87373436, 0.25253128]], ['balducci third of year', {'q': 25020, 't': [1, 3], 'assumption': 'balducci'}, [0.89990398, 0.30028805]], ['udd full year', {'q': 37371, 't': [1, 1], 'assumption': 'udd'}, [0.62629, 0.5967044]], ['cfm at start', {'q': 12769, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.13661041]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 7646, 't': [2, 4], 'assumption': 'udd'}, [0.96177, 0.07949926]], ['udd third of year', {'q': 30081, 't': [1, 3], 'assumption': 'udd'}, [0.89973, 0.33433363]], ['cfm mid-year', {'q': 8794, 't': [2, 4], 'assumption': 'cfm'}, [0.95501832, 0.0920495]], ['cfm third of year', {'q': 26692, 't': [1, 3], 'assumption': 'cfm'}, [0.90167589, 0.31050044]], ['balducci mid-year', {'q': 6887, 't': [1, 4], 'assumption': 'balducci'}, [0.98184474, 0.07262106]], ['balducci third of year', {'q': 38785, 't': [1, 3], 'assumption': 'balducci'}, [0.82563054, 0.52310839]], ['udd full year', {'q': 23553, 't': [1, 1], 'assumption': 'udd'}, [0.76447, 0.3080958]], ['cfm at start', {'q': 30697, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.36668199]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 31223, 't': [3, 4], 'assumption': 'udd'}, [0.7658275, 0.40770278]], ['udd third of year', {'q': 27799, 't': [1, 3], 'assumption': 'udd'}, [0.90733667, 0.30638021]], ['cfm mid-year', {'q': 5158, 't': [3, 4], 'assumption': 'cfm'}, [0.96106006, 0.05295784]], ['cfm third of year', {'q': 20081, 't': [1, 3], 'assumption': 'cfm'}, [0.92800435, 0.22415656]], ['balducci mid-year', {'q': 2076, 't': [2, 4], 'assumption': 'balducci'}, [0.98951113, 0.02097775]], ['balducci third of year', {'q': 51959, 't': [1, 3], 'assumption': 'balducci'}, [0.73501392, 0.79495823]], ['udd full year', {'q': 28689, 't': [1, 1], 'assumption': 'udd'}, [0.71311, 0.4023082]], ['cfm at start', {'q': 30130, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35853381]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 3152, 't': [2, 4], 'assumption': 'udd'}, [0.98424, 0.03202471]], ['udd third of year', {'q': 29489, 't': [1, 3], 'assumption': 'udd'}, [0.90170333, 0.32703661]], ['cfm mid-year', {'q': 34830, 't': [1, 4], 'assumption': 'cfm'}, [0.89848727, 0.42817095]], ['cfm third of year', {'q': 57603, 't': [1, 3], 'assumption': 'cfm'}, [0.75123943, 0.85809258]], ['balducci mid-year', {'q': 37115, 't': [3, 4], 'assumption': 'balducci'}, [0.69316726, 0.40911032]], ['balducci third of year', {'q': 20896, 't': [1, 3], 'assumption': 'balducci'}, [0.919073, 0.24278101]], ['udd full year', {'q': 24445, 't': [1, 1], 'assumption': 'udd'}, [0.75555, 0.32353914]], ['cfm at start', {'q': 24358, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.2791585]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    q=Fraction(x['q'],100000); t=Fraction(*x['t']); a=x['assumption']
    if t<0 or t>1 or q<0 or q>1: return 'invalid'
    p=1-q
    if a=='udd':
        tp=1-t*q; mu=q/(1-q) if 1-q else None
    elif a=='cfm':
        if p==0: return 'infinite force'
        tp=Fraction(float(p)**float(t)); mu=-math.log(p)
    elif a=='balducci':
        tp=p/(1-(1-t)*q)
        mu=q/(1-(1-t)*q)
    else:
        return 'unknown assumption'
    if mu is None: return 'infinite force'
    return [round(float(tp),8),round(float(mu),8)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['udd mid-year', {'q': 3964, 't': [1, 4], 'assumption': 'udd'}, [0.99009, 0.04003676]], ['udd third of year', {'q': 57411, 't': [1, 3], 'assumption': 'udd'}, [0.80863, 0.70997861]], ['cfm mid-year', {'q': 31716, 't': [3, 4], 'assumption': 'cfm'}, [0.7511717, 0.38149471]], ['cfm third of year', {'q': 35719, 't': [1, 3], 'assumption': 'cfm'}, [0.86303328, 0.44190609]], ['balducci mid-year', {'q': 2891, 't': [2, 4], 'assumption': 'balducci'}, [0.98533299, 0.02933402]], ['balducci third of year', {'q': 37692, 't': [1, 3], 'assumption': 'balducci'}, [0.83219361, 0.50341917]], ['udd full year', {'q': 34482, 't': [1, 1], 'assumption': 'udd'}, [0.65518, 0.52629812]], ['cfm at start', {'q': 29787, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35363671]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 38019, 't': [2, 4], 'assumption': 'udd'}, [0.809905, 0.46942543]], ['udd third of year', {'q': 44263, 't': [1, 3], 'assumption': 'udd'}, [0.85245667, 0.51924047]], ['cfm mid-year', {'q': 36269, 't': [2, 4], 'assumption': 'cfm'}, [0.79831698, 0.45049909]], ['cfm third of year', {'q': 41961, 't': [1, 3], 'assumption': 'cfm'}, [0.83414197, 0.54405499]], ['balducci mid-year', {'q': 22422, 't': [2, 4], 'assumption': 'balducci'}, [0.87373436, 0.25253128]], ['balducci third of year', {'q': 25020, 't': [1, 3], 'assumption': 'balducci'}, [0.89990398, 0.30028805]], ['udd full year', {'q': 37371, 't': [1, 1], 'assumption': 'udd'}, [0.62629, 0.5967044]], ['cfm at start', {'q': 12769, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.13661041]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 7646, 't': [2, 4], 'assumption': 'udd'}, [0.96177, 0.07949926]], ['udd third of year', {'q': 30081, 't': [1, 3], 'assumption': 'udd'}, [0.89973, 0.33433363]], ['cfm mid-year', {'q': 8794, 't': [2, 4], 'assumption': 'cfm'}, [0.95501832, 0.0920495]], ['cfm third of year', {'q': 26692, 't': [1, 3], 'assumption': 'cfm'}, [0.90167589, 0.31050044]], ['balducci mid-year', {'q': 6887, 't': [1, 4], 'assumption': 'balducci'}, [0.98184474, 0.07262106]], ['balducci third of year', {'q': 38785, 't': [1, 3], 'assumption': 'balducci'}, [0.82563054, 0.52310839]], ['udd full year', {'q': 23553, 't': [1, 1], 'assumption': 'udd'}, [0.76447, 0.3080958]], ['cfm at start', {'q': 30697, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.36668199]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 31223, 't': [3, 4], 'assumption': 'udd'}, [0.7658275, 0.40770278]], ['udd third of year', {'q': 27799, 't': [1, 3], 'assumption': 'udd'}, [0.90733667, 0.30638021]], ['cfm mid-year', {'q': 5158, 't': [3, 4], 'assumption': 'cfm'}, [0.96106006, 0.05295784]], ['cfm third of year', {'q': 20081, 't': [1, 3], 'assumption': 'cfm'}, [0.92800435, 0.22415656]], ['balducci mid-year', {'q': 2076, 't': [2, 4], 'assumption': 'balducci'}, [0.98951113, 0.02097775]], ['balducci third of year', {'q': 51959, 't': [1, 3], 'assumption': 'balducci'}, [0.73501392, 0.79495823]], ['udd full year', {'q': 28689, 't': [1, 1], 'assumption': 'udd'}, [0.71311, 0.4023082]], ['cfm at start', {'q': 30130, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35853381]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 3152, 't': [2, 4], 'assumption': 'udd'}, [0.98424, 0.03202471]], ['udd third of year', {'q': 29489, 't': [1, 3], 'assumption': 'udd'}, [0.90170333, 0.32703661]], ['cfm mid-year', {'q': 34830, 't': [1, 4], 'assumption': 'cfm'}, [0.89848727, 0.42817095]], ['cfm third of year', {'q': 57603, 't': [1, 3], 'assumption': 'cfm'}, [0.75123943, 0.85809258]], ['balducci mid-year', {'q': 37115, 't': [3, 4], 'assumption': 'balducci'}, [0.69316726, 0.40911032]], ['balducci third of year', {'q': 20896, 't': [1, 3], 'assumption': 'balducci'}, [0.919073, 0.24278101]], ['udd full year', {'q': 24445, 't': [1, 1], 'assumption': 'udd'}, [0.75555, 0.32353914]], ['cfm at start', {'q': 24358, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.2791585]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The UDD hazard is flat within the year.

Input q (per 100000), t as [num, den] in [0,1], assumption udd|cfm|balducci. UDD: tp=1-tq, mu=q/(1-tq); constant force: tp=p^t, mu=-ln p; Balducci: tp=p/(1-(1-t)q), mu=q/(1-(1-t)q). Out-of-range -> 'invalid'; infinite force -> 'infinite force'; other -> 'unknown assumption'. Return [tp, mu] rounded to 8 places.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    q=Fraction(x['q'],100000); t=Fraction(*x['t']); a=x['assumption']
    if t<0 or t>1 or q<0 or q>1: return 'invalid'
    p=1-q
    if a=='udd':
        tp=1-t*q; mu=q/(1-t*q) if 1-t*q else None
    elif a=='cfm':
        if p==0: return 'infinite force'
        tp=Fraction(1-float(q)*float(t)); mu=-math.log(p)
    elif a=='balducci':
        tp=p/(1-(1-t)*q)
        mu=q/(1-(1-t)*q)
    else:
        return 'unknown assumption'
    if mu is None: return 'infinite force'
    return [round(float(tp),8),round(float(mu),8)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['udd mid-year', {'q': 3964, 't': [1, 4], 'assumption': 'udd'}, [0.99009, 0.04003676]], ['udd third of year', {'q': 57411, 't': [1, 3], 'assumption': 'udd'}, [0.80863, 0.70997861]], ['cfm mid-year', {'q': 31716, 't': [3, 4], 'assumption': 'cfm'}, [0.7511717, 0.38149471]], ['cfm third of year', {'q': 35719, 't': [1, 3], 'assumption': 'cfm'}, [0.86303328, 0.44190609]], ['balducci mid-year', {'q': 2891, 't': [2, 4], 'assumption': 'balducci'}, [0.98533299, 0.02933402]], ['balducci third of year', {'q': 37692, 't': [1, 3], 'assumption': 'balducci'}, [0.83219361, 0.50341917]], ['udd full year', {'q': 34482, 't': [1, 1], 'assumption': 'udd'}, [0.65518, 0.52629812]], ['cfm at start', {'q': 29787, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35363671]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 38019, 't': [2, 4], 'assumption': 'udd'}, [0.809905, 0.46942543]], ['udd third of year', {'q': 44263, 't': [1, 3], 'assumption': 'udd'}, [0.85245667, 0.51924047]], ['cfm mid-year', {'q': 36269, 't': [2, 4], 'assumption': 'cfm'}, [0.79831698, 0.45049909]], ['cfm third of year', {'q': 41961, 't': [1, 3], 'assumption': 'cfm'}, [0.83414197, 0.54405499]], ['balducci mid-year', {'q': 22422, 't': [2, 4], 'assumption': 'balducci'}, [0.87373436, 0.25253128]], ['balducci third of year', {'q': 25020, 't': [1, 3], 'assumption': 'balducci'}, [0.89990398, 0.30028805]], ['udd full year', {'q': 37371, 't': [1, 1], 'assumption': 'udd'}, [0.62629, 0.5967044]], ['cfm at start', {'q': 12769, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.13661041]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 7646, 't': [2, 4], 'assumption': 'udd'}, [0.96177, 0.07949926]], ['udd third of year', {'q': 30081, 't': [1, 3], 'assumption': 'udd'}, [0.89973, 0.33433363]], ['cfm mid-year', {'q': 8794, 't': [2, 4], 'assumption': 'cfm'}, [0.95501832, 0.0920495]], ['cfm third of year', {'q': 26692, 't': [1, 3], 'assumption': 'cfm'}, [0.90167589, 0.31050044]], ['balducci mid-year', {'q': 6887, 't': [1, 4], 'assumption': 'balducci'}, [0.98184474, 0.07262106]], ['balducci third of year', {'q': 38785, 't': [1, 3], 'assumption': 'balducci'}, [0.82563054, 0.52310839]], ['udd full year', {'q': 23553, 't': [1, 1], 'assumption': 'udd'}, [0.76447, 0.3080958]], ['cfm at start', {'q': 30697, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.36668199]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 31223, 't': [3, 4], 'assumption': 'udd'}, [0.7658275, 0.40770278]], ['udd third of year', {'q': 27799, 't': [1, 3], 'assumption': 'udd'}, [0.90733667, 0.30638021]], ['cfm mid-year', {'q': 5158, 't': [3, 4], 'assumption': 'cfm'}, [0.96106006, 0.05295784]], ['cfm third of year', {'q': 20081, 't': [1, 3], 'assumption': 'cfm'}, [0.92800435, 0.22415656]], ['balducci mid-year', {'q': 2076, 't': [2, 4], 'assumption': 'balducci'}, [0.98951113, 0.02097775]], ['balducci third of year', {'q': 51959, 't': [1, 3], 'assumption': 'balducci'}, [0.73501392, 0.79495823]], ['udd full year', {'q': 28689, 't': [1, 1], 'assumption': 'udd'}, [0.71311, 0.4023082]], ['cfm at start', {'q': 30130, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35853381]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 3152, 't': [2, 4], 'assumption': 'udd'}, [0.98424, 0.03202471]], ['udd third of year', {'q': 29489, 't': [1, 3], 'assumption': 'udd'}, [0.90170333, 0.32703661]], ['cfm mid-year', {'q': 34830, 't': [1, 4], 'assumption': 'cfm'}, [0.89848727, 0.42817095]], ['cfm third of year', {'q': 57603, 't': [1, 3], 'assumption': 'cfm'}, [0.75123943, 0.85809258]], ['balducci mid-year', {'q': 37115, 't': [3, 4], 'assumption': 'balducci'}, [0.69316726, 0.40911032]], ['balducci third of year', {'q': 20896, 't': [1, 3], 'assumption': 'balducci'}, [0.919073, 0.24278101]], ['udd full year', {'q': 24445, 't': [1, 1], 'assumption': 'udd'}, [0.75555, 0.32353914]], ['cfm at start', {'q': 24358, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.2791585]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    q=Fraction(x['q'],100000); t=Fraction(*x['t']); a=x['assumption']
    if t<0 or t>1 or q<0 or q>1: return 'invalid'
    p=1-q
    if a=='udd':
        tp=1-t*q; mu=q/(1-t*q) if 1-t*q else None
    elif a=='cfm':
        if p==0: return 'infinite force'
        tp=Fraction(float(p)**float(1-t)); mu=-math.log(p)
    elif a=='balducci':
        tp=p/(1-(1-t)*q)
        mu=q/(1-(1-t)*q)
    else:
        return 'unknown assumption'
    if mu is None: return 'infinite force'
    return [round(float(tp),8),round(float(mu),8)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['udd mid-year', {'q': 3964, 't': [1, 4], 'assumption': 'udd'}, [0.99009, 0.04003676]], ['udd third of year', {'q': 57411, 't': [1, 3], 'assumption': 'udd'}, [0.80863, 0.70997861]], ['cfm mid-year', {'q': 31716, 't': [3, 4], 'assumption': 'cfm'}, [0.7511717, 0.38149471]], ['cfm third of year', {'q': 35719, 't': [1, 3], 'assumption': 'cfm'}, [0.86303328, 0.44190609]], ['balducci mid-year', {'q': 2891, 't': [2, 4], 'assumption': 'balducci'}, [0.98533299, 0.02933402]], ['balducci third of year', {'q': 37692, 't': [1, 3], 'assumption': 'balducci'}, [0.83219361, 0.50341917]], ['udd full year', {'q': 34482, 't': [1, 1], 'assumption': 'udd'}, [0.65518, 0.52629812]], ['cfm at start', {'q': 29787, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35363671]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 38019, 't': [2, 4], 'assumption': 'udd'}, [0.809905, 0.46942543]], ['udd third of year', {'q': 44263, 't': [1, 3], 'assumption': 'udd'}, [0.85245667, 0.51924047]], ['cfm mid-year', {'q': 36269, 't': [2, 4], 'assumption': 'cfm'}, [0.79831698, 0.45049909]], ['cfm third of year', {'q': 41961, 't': [1, 3], 'assumption': 'cfm'}, [0.83414197, 0.54405499]], ['balducci mid-year', {'q': 22422, 't': [2, 4], 'assumption': 'balducci'}, [0.87373436, 0.25253128]], ['balducci third of year', {'q': 25020, 't': [1, 3], 'assumption': 'balducci'}, [0.89990398, 0.30028805]], ['udd full year', {'q': 37371, 't': [1, 1], 'assumption': 'udd'}, [0.62629, 0.5967044]], ['cfm at start', {'q': 12769, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.13661041]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 7646, 't': [2, 4], 'assumption': 'udd'}, [0.96177, 0.07949926]], ['udd third of year', {'q': 30081, 't': [1, 3], 'assumption': 'udd'}, [0.89973, 0.33433363]], ['cfm mid-year', {'q': 8794, 't': [2, 4], 'assumption': 'cfm'}, [0.95501832, 0.0920495]], ['cfm third of year', {'q': 26692, 't': [1, 3], 'assumption': 'cfm'}, [0.90167589, 0.31050044]], ['balducci mid-year', {'q': 6887, 't': [1, 4], 'assumption': 'balducci'}, [0.98184474, 0.07262106]], ['balducci third of year', {'q': 38785, 't': [1, 3], 'assumption': 'balducci'}, [0.82563054, 0.52310839]], ['udd full year', {'q': 23553, 't': [1, 1], 'assumption': 'udd'}, [0.76447, 0.3080958]], ['cfm at start', {'q': 30697, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.36668199]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 31223, 't': [3, 4], 'assumption': 'udd'}, [0.7658275, 0.40770278]], ['udd third of year', {'q': 27799, 't': [1, 3], 'assumption': 'udd'}, [0.90733667, 0.30638021]], ['cfm mid-year', {'q': 5158, 't': [3, 4], 'assumption': 'cfm'}, [0.96106006, 0.05295784]], ['cfm third of year', {'q': 20081, 't': [1, 3], 'assumption': 'cfm'}, [0.92800435, 0.22415656]], ['balducci mid-year', {'q': 2076, 't': [2, 4], 'assumption': 'balducci'}, [0.98951113, 0.02097775]], ['balducci third of year', {'q': 51959, 't': [1, 3], 'assumption': 'balducci'}, [0.73501392, 0.79495823]], ['udd full year', {'q': 28689, 't': [1, 1], 'assumption': 'udd'}, [0.71311, 0.4023082]], ['cfm at start', {'q': 30130, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35853381]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 3152, 't': [2, 4], 'assumption': 'udd'}, [0.98424, 0.03202471]], ['udd third of year', {'q': 29489, 't': [1, 3], 'assumption': 'udd'}, [0.90170333, 0.32703661]], ['cfm mid-year', {'q': 34830, 't': [1, 4], 'assumption': 'cfm'}, [0.89848727, 0.42817095]], ['cfm third of year', {'q': 57603, 't': [1, 3], 'assumption': 'cfm'}, [0.75123943, 0.85809258]], ['balducci mid-year', {'q': 37115, 't': [3, 4], 'assumption': 'balducci'}, [0.69316726, 0.40911032]], ['balducci third of year', {'q': 20896, 't': [1, 3], 'assumption': 'balducci'}, [0.919073, 0.24278101]], ['udd full year', {'q': 24445, 't': [1, 1], 'assumption': 'udd'}, [0.75555, 0.32353914]], ['cfm at start', {'q': 24358, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.2791585]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Constant-force survival equals the UDD value.

Input q (per 100000), t as [num, den] in [0,1], assumption udd|cfm|balducci. UDD: tp=1-tq, mu=q/(1-tq); constant force: tp=p^t, mu=-ln p; Balducci: tp=p/(1-(1-t)q), mu=q/(1-(1-t)q). Out-of-range -> 'invalid'; infinite force -> 'infinite force'; other -> 'unknown assumption'. Return [tp, mu] rounded to 8 places.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    q=Fraction(x['q'],100000); t=Fraction(*x['t']); a=x['assumption']
    if t<0 or t>1 or q<0 or q>1: return 'invalid'
    p=1-q
    if a=='udd':
        tp=1-t*q; mu=q/(1-t*q) if 1-t*q else None
    elif a=='cfm':
        if p==0: return 'infinite force'
        tp=Fraction(float(p)**float(t)); mu=-math.log(p)
    elif a=='balducci':
        tp=p/(1-t*q)
        mu=q/(1-(1-t)*q)
    else:
        return 'unknown assumption'
    if mu is None: return 'infinite force'
    return [round(float(tp),8),round(float(mu),8)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['udd mid-year', {'q': 3964, 't': [1, 4], 'assumption': 'udd'}, [0.99009, 0.04003676]], ['udd third of year', {'q': 57411, 't': [1, 3], 'assumption': 'udd'}, [0.80863, 0.70997861]], ['cfm mid-year', {'q': 31716, 't': [3, 4], 'assumption': 'cfm'}, [0.7511717, 0.38149471]], ['cfm third of year', {'q': 35719, 't': [1, 3], 'assumption': 'cfm'}, [0.86303328, 0.44190609]], ['balducci mid-year', {'q': 2891, 't': [2, 4], 'assumption': 'balducci'}, [0.98533299, 0.02933402]], ['balducci third of year', {'q': 37692, 't': [1, 3], 'assumption': 'balducci'}, [0.83219361, 0.50341917]], ['udd full year', {'q': 34482, 't': [1, 1], 'assumption': 'udd'}, [0.65518, 0.52629812]], ['cfm at start', {'q': 29787, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35363671]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 38019, 't': [2, 4], 'assumption': 'udd'}, [0.809905, 0.46942543]], ['udd third of year', {'q': 44263, 't': [1, 3], 'assumption': 'udd'}, [0.85245667, 0.51924047]], ['cfm mid-year', {'q': 36269, 't': [2, 4], 'assumption': 'cfm'}, [0.79831698, 0.45049909]], ['cfm third of year', {'q': 41961, 't': [1, 3], 'assumption': 'cfm'}, [0.83414197, 0.54405499]], ['balducci mid-year', {'q': 22422, 't': [2, 4], 'assumption': 'balducci'}, [0.87373436, 0.25253128]], ['balducci third of year', {'q': 25020, 't': [1, 3], 'assumption': 'balducci'}, [0.89990398, 0.30028805]], ['udd full year', {'q': 37371, 't': [1, 1], 'assumption': 'udd'}, [0.62629, 0.5967044]], ['cfm at start', {'q': 12769, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.13661041]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 7646, 't': [2, 4], 'assumption': 'udd'}, [0.96177, 0.07949926]], ['udd third of year', {'q': 30081, 't': [1, 3], 'assumption': 'udd'}, [0.89973, 0.33433363]], ['cfm mid-year', {'q': 8794, 't': [2, 4], 'assumption': 'cfm'}, [0.95501832, 0.0920495]], ['cfm third of year', {'q': 26692, 't': [1, 3], 'assumption': 'cfm'}, [0.90167589, 0.31050044]], ['balducci mid-year', {'q': 6887, 't': [1, 4], 'assumption': 'balducci'}, [0.98184474, 0.07262106]], ['balducci third of year', {'q': 38785, 't': [1, 3], 'assumption': 'balducci'}, [0.82563054, 0.52310839]], ['udd full year', {'q': 23553, 't': [1, 1], 'assumption': 'udd'}, [0.76447, 0.3080958]], ['cfm at start', {'q': 30697, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.36668199]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 31223, 't': [3, 4], 'assumption': 'udd'}, [0.7658275, 0.40770278]], ['udd third of year', {'q': 27799, 't': [1, 3], 'assumption': 'udd'}, [0.90733667, 0.30638021]], ['cfm mid-year', {'q': 5158, 't': [3, 4], 'assumption': 'cfm'}, [0.96106006, 0.05295784]], ['cfm third of year', {'q': 20081, 't': [1, 3], 'assumption': 'cfm'}, [0.92800435, 0.22415656]], ['balducci mid-year', {'q': 2076, 't': [2, 4], 'assumption': 'balducci'}, [0.98951113, 0.02097775]], ['balducci third of year', {'q': 51959, 't': [1, 3], 'assumption': 'balducci'}, [0.73501392, 0.79495823]], ['udd full year', {'q': 28689, 't': [1, 1], 'assumption': 'udd'}, [0.71311, 0.4023082]], ['cfm at start', {'q': 30130, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35853381]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 3152, 't': [2, 4], 'assumption': 'udd'}, [0.98424, 0.03202471]], ['udd third of year', {'q': 29489, 't': [1, 3], 'assumption': 'udd'}, [0.90170333, 0.32703661]], ['cfm mid-year', {'q': 34830, 't': [1, 4], 'assumption': 'cfm'}, [0.89848727, 0.42817095]], ['cfm third of year', {'q': 57603, 't': [1, 3], 'assumption': 'cfm'}, [0.75123943, 0.85809258]], ['balducci mid-year', {'q': 37115, 't': [3, 4], 'assumption': 'balducci'}, [0.69316726, 0.40911032]], ['balducci third of year', {'q': 20896, 't': [1, 3], 'assumption': 'balducci'}, [0.919073, 0.24278101]], ['udd full year', {'q': 24445, 't': [1, 1], 'assumption': 'udd'}, [0.75555, 0.32353914]], ['cfm at start', {'q': 24358, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.2791585]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    q=Fraction(x['q'],100000); t=Fraction(*x['t']); a=x['assumption']
    if t<0 or t>1 or q<0 or q>1: return 'invalid'
    p=1-q
    if a=='udd':
        tp=1-t*q; mu=q/(1-t*q) if 1-t*q else None
    elif a=='cfm':
        if p==0: return 'infinite force'
        tp=Fraction(float(p)**float(t)); mu=-math.log(p)
    elif a=='balducci':
        tp=p/(1+(1-t)*q)
        mu=q/(1-(1-t)*q)
    else:
        return 'unknown assumption'
    if mu is None: return 'infinite force'
    return [round(float(tp),8),round(float(mu),8)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['udd mid-year', {'q': 3964, 't': [1, 4], 'assumption': 'udd'}, [0.99009, 0.04003676]], ['udd third of year', {'q': 57411, 't': [1, 3], 'assumption': 'udd'}, [0.80863, 0.70997861]], ['cfm mid-year', {'q': 31716, 't': [3, 4], 'assumption': 'cfm'}, [0.7511717, 0.38149471]], ['cfm third of year', {'q': 35719, 't': [1, 3], 'assumption': 'cfm'}, [0.86303328, 0.44190609]], ['balducci mid-year', {'q': 2891, 't': [2, 4], 'assumption': 'balducci'}, [0.98533299, 0.02933402]], ['balducci third of year', {'q': 37692, 't': [1, 3], 'assumption': 'balducci'}, [0.83219361, 0.50341917]], ['udd full year', {'q': 34482, 't': [1, 1], 'assumption': 'udd'}, [0.65518, 0.52629812]], ['cfm at start', {'q': 29787, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35363671]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 38019, 't': [2, 4], 'assumption': 'udd'}, [0.809905, 0.46942543]], ['udd third of year', {'q': 44263, 't': [1, 3], 'assumption': 'udd'}, [0.85245667, 0.51924047]], ['cfm mid-year', {'q': 36269, 't': [2, 4], 'assumption': 'cfm'}, [0.79831698, 0.45049909]], ['cfm third of year', {'q': 41961, 't': [1, 3], 'assumption': 'cfm'}, [0.83414197, 0.54405499]], ['balducci mid-year', {'q': 22422, 't': [2, 4], 'assumption': 'balducci'}, [0.87373436, 0.25253128]], ['balducci third of year', {'q': 25020, 't': [1, 3], 'assumption': 'balducci'}, [0.89990398, 0.30028805]], ['udd full year', {'q': 37371, 't': [1, 1], 'assumption': 'udd'}, [0.62629, 0.5967044]], ['cfm at start', {'q': 12769, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.13661041]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 7646, 't': [2, 4], 'assumption': 'udd'}, [0.96177, 0.07949926]], ['udd third of year', {'q': 30081, 't': [1, 3], 'assumption': 'udd'}, [0.89973, 0.33433363]], ['cfm mid-year', {'q': 8794, 't': [2, 4], 'assumption': 'cfm'}, [0.95501832, 0.0920495]], ['cfm third of year', {'q': 26692, 't': [1, 3], 'assumption': 'cfm'}, [0.90167589, 0.31050044]], ['balducci mid-year', {'q': 6887, 't': [1, 4], 'assumption': 'balducci'}, [0.98184474, 0.07262106]], ['balducci third of year', {'q': 38785, 't': [1, 3], 'assumption': 'balducci'}, [0.82563054, 0.52310839]], ['udd full year', {'q': 23553, 't': [1, 1], 'assumption': 'udd'}, [0.76447, 0.3080958]], ['cfm at start', {'q': 30697, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.36668199]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 31223, 't': [3, 4], 'assumption': 'udd'}, [0.7658275, 0.40770278]], ['udd third of year', {'q': 27799, 't': [1, 3], 'assumption': 'udd'}, [0.90733667, 0.30638021]], ['cfm mid-year', {'q': 5158, 't': [3, 4], 'assumption': 'cfm'}, [0.96106006, 0.05295784]], ['cfm third of year', {'q': 20081, 't': [1, 3], 'assumption': 'cfm'}, [0.92800435, 0.22415656]], ['balducci mid-year', {'q': 2076, 't': [2, 4], 'assumption': 'balducci'}, [0.98951113, 0.02097775]], ['balducci third of year', {'q': 51959, 't': [1, 3], 'assumption': 'balducci'}, [0.73501392, 0.79495823]], ['udd full year', {'q': 28689, 't': [1, 1], 'assumption': 'udd'}, [0.71311, 0.4023082]], ['cfm at start', {'q': 30130, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35853381]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 3152, 't': [2, 4], 'assumption': 'udd'}, [0.98424, 0.03202471]], ['udd third of year', {'q': 29489, 't': [1, 3], 'assumption': 'udd'}, [0.90170333, 0.32703661]], ['cfm mid-year', {'q': 34830, 't': [1, 4], 'assumption': 'cfm'}, [0.89848727, 0.42817095]], ['cfm third of year', {'q': 57603, 't': [1, 3], 'assumption': 'cfm'}, [0.75123943, 0.85809258]], ['balducci mid-year', {'q': 37115, 't': [3, 4], 'assumption': 'balducci'}, [0.69316726, 0.40911032]], ['balducci third of year', {'q': 20896, 't': [1, 3], 'assumption': 'balducci'}, [0.919073, 0.24278101]], ['udd full year', {'q': 24445, 't': [1, 1], 'assumption': 'udd'}, [0.75555, 0.32353914]], ['cfm at start', {'q': 24358, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.2791585]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Balducci survival probabilities are too high early in the year.

Input q (per 100000), t as [num, den] in [0,1], assumption udd|cfm|balducci. UDD: tp=1-tq, mu=q/(1-tq); constant force: tp=p^t, mu=-ln p; Balducci: tp=p/(1-(1-t)q), mu=q/(1-(1-t)q). Out-of-range -> 'invalid'; infinite force -> 'infinite force'; other -> 'unknown assumption'. Return [tp, mu] rounded to 8 places.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    q=Fraction(x['q'],100000); t=Fraction(*x['t']); a=x['assumption']
    if t<0 or t>=1 or q<0 or q>1: return 'invalid'
    p=1-q
    if a=='udd':
        tp=1-t*q; mu=q/(1-t*q) if 1-t*q else None
    elif a=='cfm':
        if p==0: return 'infinite force'
        tp=Fraction(float(p)**float(t)); mu=-math.log(p)
    elif a=='balducci':
        tp=p/(1-(1-t)*q)
        mu=q/(1-(1-t)*q)
    else:
        return 'unknown assumption'
    if mu is None: return 'infinite force'
    return [round(float(tp),8),round(float(mu),8)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['udd mid-year', {'q': 3964, 't': [1, 4], 'assumption': 'udd'}, [0.99009, 0.04003676]], ['udd third of year', {'q': 57411, 't': [1, 3], 'assumption': 'udd'}, [0.80863, 0.70997861]], ['cfm mid-year', {'q': 31716, 't': [3, 4], 'assumption': 'cfm'}, [0.7511717, 0.38149471]], ['cfm third of year', {'q': 35719, 't': [1, 3], 'assumption': 'cfm'}, [0.86303328, 0.44190609]], ['balducci mid-year', {'q': 2891, 't': [2, 4], 'assumption': 'balducci'}, [0.98533299, 0.02933402]], ['balducci third of year', {'q': 37692, 't': [1, 3], 'assumption': 'balducci'}, [0.83219361, 0.50341917]], ['udd full year', {'q': 34482, 't': [1, 1], 'assumption': 'udd'}, [0.65518, 0.52629812]], ['cfm at start', {'q': 29787, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35363671]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 38019, 't': [2, 4], 'assumption': 'udd'}, [0.809905, 0.46942543]], ['udd third of year', {'q': 44263, 't': [1, 3], 'assumption': 'udd'}, [0.85245667, 0.51924047]], ['cfm mid-year', {'q': 36269, 't': [2, 4], 'assumption': 'cfm'}, [0.79831698, 0.45049909]], ['cfm third of year', {'q': 41961, 't': [1, 3], 'assumption': 'cfm'}, [0.83414197, 0.54405499]], ['balducci mid-year', {'q': 22422, 't': [2, 4], 'assumption': 'balducci'}, [0.87373436, 0.25253128]], ['balducci third of year', {'q': 25020, 't': [1, 3], 'assumption': 'balducci'}, [0.89990398, 0.30028805]], ['udd full year', {'q': 37371, 't': [1, 1], 'assumption': 'udd'}, [0.62629, 0.5967044]], ['cfm at start', {'q': 12769, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.13661041]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 7646, 't': [2, 4], 'assumption': 'udd'}, [0.96177, 0.07949926]], ['udd third of year', {'q': 30081, 't': [1, 3], 'assumption': 'udd'}, [0.89973, 0.33433363]], ['cfm mid-year', {'q': 8794, 't': [2, 4], 'assumption': 'cfm'}, [0.95501832, 0.0920495]], ['cfm third of year', {'q': 26692, 't': [1, 3], 'assumption': 'cfm'}, [0.90167589, 0.31050044]], ['balducci mid-year', {'q': 6887, 't': [1, 4], 'assumption': 'balducci'}, [0.98184474, 0.07262106]], ['balducci third of year', {'q': 38785, 't': [1, 3], 'assumption': 'balducci'}, [0.82563054, 0.52310839]], ['udd full year', {'q': 23553, 't': [1, 1], 'assumption': 'udd'}, [0.76447, 0.3080958]], ['cfm at start', {'q': 30697, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.36668199]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 31223, 't': [3, 4], 'assumption': 'udd'}, [0.7658275, 0.40770278]], ['udd third of year', {'q': 27799, 't': [1, 3], 'assumption': 'udd'}, [0.90733667, 0.30638021]], ['cfm mid-year', {'q': 5158, 't': [3, 4], 'assumption': 'cfm'}, [0.96106006, 0.05295784]], ['cfm third of year', {'q': 20081, 't': [1, 3], 'assumption': 'cfm'}, [0.92800435, 0.22415656]], ['balducci mid-year', {'q': 2076, 't': [2, 4], 'assumption': 'balducci'}, [0.98951113, 0.02097775]], ['balducci third of year', {'q': 51959, 't': [1, 3], 'assumption': 'balducci'}, [0.73501392, 0.79495823]], ['udd full year', {'q': 28689, 't': [1, 1], 'assumption': 'udd'}, [0.71311, 0.4023082]], ['cfm at start', {'q': 30130, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35853381]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 3152, 't': [2, 4], 'assumption': 'udd'}, [0.98424, 0.03202471]], ['udd third of year', {'q': 29489, 't': [1, 3], 'assumption': 'udd'}, [0.90170333, 0.32703661]], ['cfm mid-year', {'q': 34830, 't': [1, 4], 'assumption': 'cfm'}, [0.89848727, 0.42817095]], ['cfm third of year', {'q': 57603, 't': [1, 3], 'assumption': 'cfm'}, [0.75123943, 0.85809258]], ['balducci mid-year', {'q': 37115, 't': [3, 4], 'assumption': 'balducci'}, [0.69316726, 0.40911032]], ['balducci third of year', {'q': 20896, 't': [1, 3], 'assumption': 'balducci'}, [0.919073, 0.24278101]], ['udd full year', {'q': 24445, 't': [1, 1], 'assumption': 'udd'}, [0.75555, 0.32353914]], ['cfm at start', {'q': 24358, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.2791585]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    q=Fraction(x['q'],100000); t=Fraction(*x['t']); a=x['assumption']
    if t<=0 or t>1 or q<0 or q>1: return 'invalid'
    p=1-q
    if a=='udd':
        tp=1-t*q; mu=q/(1-t*q) if 1-t*q else None
    elif a=='cfm':
        if p==0: return 'infinite force'
        tp=Fraction(float(p)**float(t)); mu=-math.log(p)
    elif a=='balducci':
        tp=p/(1-(1-t)*q)
        mu=q/(1-(1-t)*q)
    else:
        return 'unknown assumption'
    if mu is None: return 'infinite force'
    return [round(float(tp),8),round(float(mu),8)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['udd mid-year', {'q': 3964, 't': [1, 4], 'assumption': 'udd'}, [0.99009, 0.04003676]], ['udd third of year', {'q': 57411, 't': [1, 3], 'assumption': 'udd'}, [0.80863, 0.70997861]], ['cfm mid-year', {'q': 31716, 't': [3, 4], 'assumption': 'cfm'}, [0.7511717, 0.38149471]], ['cfm third of year', {'q': 35719, 't': [1, 3], 'assumption': 'cfm'}, [0.86303328, 0.44190609]], ['balducci mid-year', {'q': 2891, 't': [2, 4], 'assumption': 'balducci'}, [0.98533299, 0.02933402]], ['balducci third of year', {'q': 37692, 't': [1, 3], 'assumption': 'balducci'}, [0.83219361, 0.50341917]], ['udd full year', {'q': 34482, 't': [1, 1], 'assumption': 'udd'}, [0.65518, 0.52629812]], ['cfm at start', {'q': 29787, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35363671]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 38019, 't': [2, 4], 'assumption': 'udd'}, [0.809905, 0.46942543]], ['udd third of year', {'q': 44263, 't': [1, 3], 'assumption': 'udd'}, [0.85245667, 0.51924047]], ['cfm mid-year', {'q': 36269, 't': [2, 4], 'assumption': 'cfm'}, [0.79831698, 0.45049909]], ['cfm third of year', {'q': 41961, 't': [1, 3], 'assumption': 'cfm'}, [0.83414197, 0.54405499]], ['balducci mid-year', {'q': 22422, 't': [2, 4], 'assumption': 'balducci'}, [0.87373436, 0.25253128]], ['balducci third of year', {'q': 25020, 't': [1, 3], 'assumption': 'balducci'}, [0.89990398, 0.30028805]], ['udd full year', {'q': 37371, 't': [1, 1], 'assumption': 'udd'}, [0.62629, 0.5967044]], ['cfm at start', {'q': 12769, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.13661041]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 7646, 't': [2, 4], 'assumption': 'udd'}, [0.96177, 0.07949926]], ['udd third of year', {'q': 30081, 't': [1, 3], 'assumption': 'udd'}, [0.89973, 0.33433363]], ['cfm mid-year', {'q': 8794, 't': [2, 4], 'assumption': 'cfm'}, [0.95501832, 0.0920495]], ['cfm third of year', {'q': 26692, 't': [1, 3], 'assumption': 'cfm'}, [0.90167589, 0.31050044]], ['balducci mid-year', {'q': 6887, 't': [1, 4], 'assumption': 'balducci'}, [0.98184474, 0.07262106]], ['balducci third of year', {'q': 38785, 't': [1, 3], 'assumption': 'balducci'}, [0.82563054, 0.52310839]], ['udd full year', {'q': 23553, 't': [1, 1], 'assumption': 'udd'}, [0.76447, 0.3080958]], ['cfm at start', {'q': 30697, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.36668199]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 31223, 't': [3, 4], 'assumption': 'udd'}, [0.7658275, 0.40770278]], ['udd third of year', {'q': 27799, 't': [1, 3], 'assumption': 'udd'}, [0.90733667, 0.30638021]], ['cfm mid-year', {'q': 5158, 't': [3, 4], 'assumption': 'cfm'}, [0.96106006, 0.05295784]], ['cfm third of year', {'q': 20081, 't': [1, 3], 'assumption': 'cfm'}, [0.92800435, 0.22415656]], ['balducci mid-year', {'q': 2076, 't': [2, 4], 'assumption': 'balducci'}, [0.98951113, 0.02097775]], ['balducci third of year', {'q': 51959, 't': [1, 3], 'assumption': 'balducci'}, [0.73501392, 0.79495823]], ['udd full year', {'q': 28689, 't': [1, 1], 'assumption': 'udd'}, [0.71311, 0.4023082]], ['cfm at start', {'q': 30130, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35853381]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 3152, 't': [2, 4], 'assumption': 'udd'}, [0.98424, 0.03202471]], ['udd third of year', {'q': 29489, 't': [1, 3], 'assumption': 'udd'}, [0.90170333, 0.32703661]], ['cfm mid-year', {'q': 34830, 't': [1, 4], 'assumption': 'cfm'}, [0.89848727, 0.42817095]], ['cfm third of year', {'q': 57603, 't': [1, 3], 'assumption': 'cfm'}, [0.75123943, 0.85809258]], ['balducci mid-year', {'q': 37115, 't': [3, 4], 'assumption': 'balducci'}, [0.69316726, 0.40911032]], ['balducci third of year', {'q': 20896, 't': [1, 3], 'assumption': 'balducci'}, [0.919073, 0.24278101]], ['udd full year', {'q': 24445, 't': [1, 1], 'assumption': 'udd'}, [0.75555, 0.32353914]], ['cfm at start', {'q': 24358, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.2791585]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
t=1 returns invalid.

Input q (per 100000), t as [num, den] in [0,1], assumption udd|cfm|balducci. UDD: tp=1-tq, mu=q/(1-tq); constant force: tp=p^t, mu=-ln p; Balducci: tp=p/(1-(1-t)q), mu=q/(1-(1-t)q). Out-of-range -> 'invalid'; infinite force -> 'infinite force'; other -> 'unknown assumption'. Return [tp, mu] rounded to 8 places.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    q=Fraction(x['q'],100000); t=Fraction(*x['t']); a=x['assumption']
    if t<0 or t>1 or q<0 or q>1: return 'invalid'
    p=1-q
    if a=='udd':
        tp=1-t*q; mu=q/(1-t*q) if 1-t*q else None
    elif a=='cfm':
        if p==0: return 'infinite force'
        tp=Fraction(float(p)**float(t)); mu=q
    elif a=='balducci':
        tp=p/(1-(1-t)*q)
        mu=q/(1-(1-t)*q)
    else:
        return 'unknown assumption'
    if mu is None: return 'infinite force'
    return [round(float(tp),8),round(float(mu),8)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['udd mid-year', {'q': 3964, 't': [1, 4], 'assumption': 'udd'}, [0.99009, 0.04003676]], ['udd third of year', {'q': 57411, 't': [1, 3], 'assumption': 'udd'}, [0.80863, 0.70997861]], ['cfm mid-year', {'q': 31716, 't': [3, 4], 'assumption': 'cfm'}, [0.7511717, 0.38149471]], ['cfm third of year', {'q': 35719, 't': [1, 3], 'assumption': 'cfm'}, [0.86303328, 0.44190609]], ['balducci mid-year', {'q': 2891, 't': [2, 4], 'assumption': 'balducci'}, [0.98533299, 0.02933402]], ['balducci third of year', {'q': 37692, 't': [1, 3], 'assumption': 'balducci'}, [0.83219361, 0.50341917]], ['udd full year', {'q': 34482, 't': [1, 1], 'assumption': 'udd'}, [0.65518, 0.52629812]], ['cfm at start', {'q': 29787, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35363671]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 38019, 't': [2, 4], 'assumption': 'udd'}, [0.809905, 0.46942543]], ['udd third of year', {'q': 44263, 't': [1, 3], 'assumption': 'udd'}, [0.85245667, 0.51924047]], ['cfm mid-year', {'q': 36269, 't': [2, 4], 'assumption': 'cfm'}, [0.79831698, 0.45049909]], ['cfm third of year', {'q': 41961, 't': [1, 3], 'assumption': 'cfm'}, [0.83414197, 0.54405499]], ['balducci mid-year', {'q': 22422, 't': [2, 4], 'assumption': 'balducci'}, [0.87373436, 0.25253128]], ['balducci third of year', {'q': 25020, 't': [1, 3], 'assumption': 'balducci'}, [0.89990398, 0.30028805]], ['udd full year', {'q': 37371, 't': [1, 1], 'assumption': 'udd'}, [0.62629, 0.5967044]], ['cfm at start', {'q': 12769, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.13661041]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 7646, 't': [2, 4], 'assumption': 'udd'}, [0.96177, 0.07949926]], ['udd third of year', {'q': 30081, 't': [1, 3], 'assumption': 'udd'}, [0.89973, 0.33433363]], ['cfm mid-year', {'q': 8794, 't': [2, 4], 'assumption': 'cfm'}, [0.95501832, 0.0920495]], ['cfm third of year', {'q': 26692, 't': [1, 3], 'assumption': 'cfm'}, [0.90167589, 0.31050044]], ['balducci mid-year', {'q': 6887, 't': [1, 4], 'assumption': 'balducci'}, [0.98184474, 0.07262106]], ['balducci third of year', {'q': 38785, 't': [1, 3], 'assumption': 'balducci'}, [0.82563054, 0.52310839]], ['udd full year', {'q': 23553, 't': [1, 1], 'assumption': 'udd'}, [0.76447, 0.3080958]], ['cfm at start', {'q': 30697, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.36668199]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 31223, 't': [3, 4], 'assumption': 'udd'}, [0.7658275, 0.40770278]], ['udd third of year', {'q': 27799, 't': [1, 3], 'assumption': 'udd'}, [0.90733667, 0.30638021]], ['cfm mid-year', {'q': 5158, 't': [3, 4], 'assumption': 'cfm'}, [0.96106006, 0.05295784]], ['cfm third of year', {'q': 20081, 't': [1, 3], 'assumption': 'cfm'}, [0.92800435, 0.22415656]], ['balducci mid-year', {'q': 2076, 't': [2, 4], 'assumption': 'balducci'}, [0.98951113, 0.02097775]], ['balducci third of year', {'q': 51959, 't': [1, 3], 'assumption': 'balducci'}, [0.73501392, 0.79495823]], ['udd full year', {'q': 28689, 't': [1, 1], 'assumption': 'udd'}, [0.71311, 0.4023082]], ['cfm at start', {'q': 30130, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35853381]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 3152, 't': [2, 4], 'assumption': 'udd'}, [0.98424, 0.03202471]], ['udd third of year', {'q': 29489, 't': [1, 3], 'assumption': 'udd'}, [0.90170333, 0.32703661]], ['cfm mid-year', {'q': 34830, 't': [1, 4], 'assumption': 'cfm'}, [0.89848727, 0.42817095]], ['cfm third of year', {'q': 57603, 't': [1, 3], 'assumption': 'cfm'}, [0.75123943, 0.85809258]], ['balducci mid-year', {'q': 37115, 't': [3, 4], 'assumption': 'balducci'}, [0.69316726, 0.40911032]], ['balducci third of year', {'q': 20896, 't': [1, 3], 'assumption': 'balducci'}, [0.919073, 0.24278101]], ['udd full year', {'q': 24445, 't': [1, 1], 'assumption': 'udd'}, [0.75555, 0.32353914]], ['cfm at start', {'q': 24358, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.2791585]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    q=Fraction(x['q'],100000); t=Fraction(*x['t']); a=x['assumption']
    if t<0 or t>1 or q<0 or q>1: return 'invalid'
    p=1-q
    if a=='udd':
        tp=1-t*q; mu=q/(1-t*q) if 1-t*q else None
    elif a=='cfm':
        if p==0: return 'infinite force'
        tp=Fraction(float(p)**float(t)); mu=q/p
    elif a=='balducci':
        tp=p/(1-(1-t)*q)
        mu=q/(1-(1-t)*q)
    else:
        return 'unknown assumption'
    if mu is None: return 'infinite force'
    return [round(float(tp),8),round(float(mu),8)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['udd mid-year', {'q': 3964, 't': [1, 4], 'assumption': 'udd'}, [0.99009, 0.04003676]], ['udd third of year', {'q': 57411, 't': [1, 3], 'assumption': 'udd'}, [0.80863, 0.70997861]], ['cfm mid-year', {'q': 31716, 't': [3, 4], 'assumption': 'cfm'}, [0.7511717, 0.38149471]], ['cfm third of year', {'q': 35719, 't': [1, 3], 'assumption': 'cfm'}, [0.86303328, 0.44190609]], ['balducci mid-year', {'q': 2891, 't': [2, 4], 'assumption': 'balducci'}, [0.98533299, 0.02933402]], ['balducci third of year', {'q': 37692, 't': [1, 3], 'assumption': 'balducci'}, [0.83219361, 0.50341917]], ['udd full year', {'q': 34482, 't': [1, 1], 'assumption': 'udd'}, [0.65518, 0.52629812]], ['cfm at start', {'q': 29787, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35363671]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 38019, 't': [2, 4], 'assumption': 'udd'}, [0.809905, 0.46942543]], ['udd third of year', {'q': 44263, 't': [1, 3], 'assumption': 'udd'}, [0.85245667, 0.51924047]], ['cfm mid-year', {'q': 36269, 't': [2, 4], 'assumption': 'cfm'}, [0.79831698, 0.45049909]], ['cfm third of year', {'q': 41961, 't': [1, 3], 'assumption': 'cfm'}, [0.83414197, 0.54405499]], ['balducci mid-year', {'q': 22422, 't': [2, 4], 'assumption': 'balducci'}, [0.87373436, 0.25253128]], ['balducci third of year', {'q': 25020, 't': [1, 3], 'assumption': 'balducci'}, [0.89990398, 0.30028805]], ['udd full year', {'q': 37371, 't': [1, 1], 'assumption': 'udd'}, [0.62629, 0.5967044]], ['cfm at start', {'q': 12769, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.13661041]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 7646, 't': [2, 4], 'assumption': 'udd'}, [0.96177, 0.07949926]], ['udd third of year', {'q': 30081, 't': [1, 3], 'assumption': 'udd'}, [0.89973, 0.33433363]], ['cfm mid-year', {'q': 8794, 't': [2, 4], 'assumption': 'cfm'}, [0.95501832, 0.0920495]], ['cfm third of year', {'q': 26692, 't': [1, 3], 'assumption': 'cfm'}, [0.90167589, 0.31050044]], ['balducci mid-year', {'q': 6887, 't': [1, 4], 'assumption': 'balducci'}, [0.98184474, 0.07262106]], ['balducci third of year', {'q': 38785, 't': [1, 3], 'assumption': 'balducci'}, [0.82563054, 0.52310839]], ['udd full year', {'q': 23553, 't': [1, 1], 'assumption': 'udd'}, [0.76447, 0.3080958]], ['cfm at start', {'q': 30697, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.36668199]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 31223, 't': [3, 4], 'assumption': 'udd'}, [0.7658275, 0.40770278]], ['udd third of year', {'q': 27799, 't': [1, 3], 'assumption': 'udd'}, [0.90733667, 0.30638021]], ['cfm mid-year', {'q': 5158, 't': [3, 4], 'assumption': 'cfm'}, [0.96106006, 0.05295784]], ['cfm third of year', {'q': 20081, 't': [1, 3], 'assumption': 'cfm'}, [0.92800435, 0.22415656]], ['balducci mid-year', {'q': 2076, 't': [2, 4], 'assumption': 'balducci'}, [0.98951113, 0.02097775]], ['balducci third of year', {'q': 51959, 't': [1, 3], 'assumption': 'balducci'}, [0.73501392, 0.79495823]], ['udd full year', {'q': 28689, 't': [1, 1], 'assumption': 'udd'}, [0.71311, 0.4023082]], ['cfm at start', {'q': 30130, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.35853381]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']], [['udd mid-year', {'q': 3152, 't': [2, 4], 'assumption': 'udd'}, [0.98424, 0.03202471]], ['udd third of year', {'q': 29489, 't': [1, 3], 'assumption': 'udd'}, [0.90170333, 0.32703661]], ['cfm mid-year', {'q': 34830, 't': [1, 4], 'assumption': 'cfm'}, [0.89848727, 0.42817095]], ['cfm third of year', {'q': 57603, 't': [1, 3], 'assumption': 'cfm'}, [0.75123943, 0.85809258]], ['balducci mid-year', {'q': 37115, 't': [3, 4], 'assumption': 'balducci'}, [0.69316726, 0.40911032]], ['balducci third of year', {'q': 20896, 't': [1, 3], 'assumption': 'balducci'}, [0.919073, 0.24278101]], ['udd full year', {'q': 24445, 't': [1, 1], 'assumption': 'udd'}, [0.75555, 0.32353914]], ['cfm at start', {'q': 24358, 't': [0, 1], 'assumption': 'cfm'}, [1.0, 0.2791585]], ['udd terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'udd'}, [0.5, 2.0]], ['cfm terminal year', {'q': 100000, 't': [1, 2], 'assumption': 'cfm'}, 'infinite force'], ['beyond one year rejected', {'q': 1000, 't': [5, 4], 'assumption': 'udd'}, 'invalid'], ['unknown assumption', {'q': 1000, 't': [1, 2], 'assumption': 'gompertz'}, 'unknown assumption']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The constant force is understated.

Input q (per 100000), t as [num, den] in [0,1], assumption udd|cfm|balducci. UDD: tp=1-tq, mu=q/(1-tq); constant force: tp=p^t, mu=-ln p; Balducci: tp=p/(1-(1-t)q), mu=q/(1-(1-t)q). Out-of-range -> 'invalid'; infinite force -> 'infinite force'; other -> 'unknown assumption'. Return [tp, mu] rounded to 8 places.

split: open-access


prompt:
Lives in their final select year are charged ultimate mortality.

Input select {issue age: [q for durations 0..period-1]}, ultimate {attained age: q}, issue_age, period, dur, n. For each duration k in dur..dur+n-1 use the select rate row[issue][k] while k<period, else the ultimate rate at attained age issue+k. Missing rows -> 'no select row' / 'no ultimate rate'. Return [rates, survival over the n years rounded to 6].

split: open-access


prompt:
Ultimate mortality stops increasing with age.

Input select {issue age: [q for durations 0..period-1]}, ultimate {attained age: q}, issue_age, period, dur, n. For each duration k in dur..dur+n-1 use the select rate row[issue][k] while k<period, else the ultimate rate at attained age issue+k. Missing rows -> 'no select row' / 'no ultimate rate'. Return [rates, survival over the n years rounded to 6].

split: open-access


prompt:
Projections starting mid-select reuse early-duration rates.

Input select {issue age: [q for durations 0..period-1]}, ultimate {attained age: q}, issue_age, period, dur, n. For each duration k in dur..dur+n-1 use the select rate row[issue][k] while k<period, else the ultimate rate at attained age issue+k. Missing rows -> 'no select row' / 'no ultimate rate'. Return [rates, survival over the n years rounded to 6].

split: open-access


prompt:
Lives are treated as if newly selected at each age.

Input select {issue age: [q for durations 0..period-1]}, ultimate {attained age: q}, issue_age, period, dur, n. For each duration k in dur..dur+n-1 use the select rate row[issue][k] while k<period, else the ultimate rate at attained age issue+k. Missing rows -> 'no select row' / 'no ultimate rate'. Return [rates, survival over the n years rounded to 6].

split: open-access


prompt:
Multi-year survival is slightly too low.

Input select {issue age: [q for durations 0..period-1]}, ultimate {attained age: q}, issue_age, period, dur, n. For each duration k in dur..dur+n-1 use the select rate row[issue][k] while k<period, else the ultimate rate at attained age issue+k. Missing rows -> 'no select row' / 'no ultimate rate'. Return [rates, survival over the n years rounded to 6].

split: open-access


prompt:
Annuity values are slightly too low.

Input l by age from 0, i (per mille), age, n (None = whole life). v=1/(1+i); D_k = v^k l_k (zero beyond the table); N_k = sum of D from k. end = table length for whole life else min(length, age+n). Annuity-due = (N_age - N_end)/D_age; immediate = (N_{age+1} - N_{end+1})/D_age. Missing or extinct age -> 'invalid age'. Return both rounded to 6.

split: open-access


prompt:
An n-year annuity-due makes n-1 payments.

Input l by age from 0, i (per mille), age, n (None = whole life). v=1/(1+i); D_k = v^k l_k (zero beyond the table); N_k = sum of D from k. end = table length for whole life else min(length, age+n). Annuity-due = (N_age - N_end)/D_age; immediate = (N_{age+1} - N_{end+1})/D_age. Missing or extinct age -> 'invalid age'. Return both rounded to 6.

split: open-access


prompt:
Temporary immediate annuities are one payment short.

Input l by age from 0, i (per mille), age, n (None = whole life). v=1/(1+i); D_k = v^k l_k (zero beyond the table); N_k = sum of D from k. end = table length for whole life else min(length, age+n). Annuity-due = (N_age - N_end)/D_age; immediate = (N_{age+1} - N_{end+1})/D_age. Missing or extinct age -> 'invalid age'. Return both rounded to 6.

split: open-access


prompt:
Annuity values are shifted by one payment.

Input l by age from 0, i (per mille), age, n (None = whole life). v=1/(1+i); D_k = v^k l_k (zero beyond the table); N_k = sum of D from k. end = table length for whole life else min(length, age+n). Annuity-due = (N_age - N_end)/D_age; immediate = (N_{age+1} - N_{end+1})/D_age. Missing or extinct age -> 'invalid age'. Return both rounded to 6.

split: open-access


prompt:
Whole-life annuities omit payments at the oldest tabulated age.

Input l by age from 0, i (per mille), age, n (None = whole life). v=1/(1+i); D_k = v^k l_k (zero beyond the table); N_k = sum of D from k. end = table length for whole life else min(length, age+n). Annuity-due = (N_age - N_end)/D_age; immediate = (N_{age+1} - N_{end+1})/D_age. Missing or extinct age -> 'invalid age'. Return both rounded to 6.

split: open-access


prompt:
Year-end term premiums are overstated by a year of interest.

Input q (per 100000 from the issue age), n, i (per mille), benefit (cents), timing eoy|immediate. n > table length -> 'table too short'. A = sum_{k<n} v^(k+1) kp q_k with exact rationals; immediate payment multiplies benefit*A by i/ln(1+i). Return the premium in cents rounded half-up.

split: open-access


prompt:
Claims in each year are weighted by survival through that same year.

Input q (per 100000 from the issue age), n, i (per mille), benefit (cents), timing eoy|immediate. n > table length -> 'table too short'. A = sum_{k<n} v^(k+1) kp q_k with exact rationals; immediate payment multiplies benefit*A by i/ln(1+i). Return the premium in cents rounded half-up.

split: open-access


prompt:
A term that uses every tabulated rate returns table too short.

Input q (per 100000 from the issue age), n, i (per mille), benefit (cents), timing eoy|immediate. n > table length -> 'table too short'. A = sum_{k<n} v^(k+1) kp q_k with exact rationals; immediate payment multiplies benefit*A by i/ln(1+i). Return the premium in cents rounded half-up.

split: open-access


prompt:
Immediate-payment premiums are lower than year-end premiums.

Input q (per 100000 from the issue age), n, i (per mille), benefit (cents), timing eoy|immediate. n > table length -> 'table too short'. A = sum_{k<n} v^(k+1) kp q_k with exact rationals; immediate payment multiplies benefit*A by i/ln(1+i). Return the premium in cents rounded half-up.

split: open-access


prompt:
Large face amounts are mispriced by many cents.

Input q (per 100000 from the issue age), n, i (per mille), benefit (cents), timing eoy|immediate. n > table length -> 'table too short'. A = sum_{k<n} v^(k+1) kp q_k with exact rationals; immediate payment multiplies benefit*A by i/ln(1+i). Return the premium in cents rounded half-up.

split: open-access


prompt:
Limited-pay premiums are understated.

Input q (per 100000), n (coverage years), m (premium years, 1<=m<=n and n<=table length else 'invalid'), type term|endowment (else 'invalid type'), i (per mille), benefit. A = sum v^(k+1) kp q_k (+ v^n np for endowment); premium annuity-due over m years; return benefit*A/annuity rounded half-up.

split: open-access


prompt:
Net premiums are too high because premiums are discounted an extra year.

Input q (per 100000), n (coverage years), m (premium years, 1<=m<=n and n<=table length else 'invalid'), type term|endowment (else 'invalid type'), i (per mille), benefit. A = sum v^(k+1) kp q_k (+ v^n np for endowment); premium annuity-due over m years; return benefit*A/annuity rounded half-up.

split: open-access


prompt:
Endowment premiums are overstated.

Input q (per 100000), n (coverage years), m (premium years, 1<=m<=n and n<=table length else 'invalid'), type term|endowment (else 'invalid type'), i (per mille), benefit. A = sum v^(k+1) kp q_k (+ v^n np for endowment); premium annuity-due over m years; return benefit*A/annuity rounded half-up.

split: open-access


prompt:
A 7-pay 5-year term returns a premium.

Input q (per 100000), n (coverage years), m (premium years, 1<=m<=n and n<=table length else 'invalid'), type term|endowment (else 'invalid type'), i (per mille), benefit. A = sum v^(k+1) kp q_k (+ v^n np for endowment); premium annuity-due over m years; return benefit*A/annuity rounded half-up.

split: open-access


prompt:
A misspelled plan silently prices as term insurance.

Input q (per 100000), n (coverage years), m (premium years, 1<=m<=n and n<=table length else 'invalid'), type term|endowment (else 'invalid type'), i (per mille), benefit. A = sum v^(k+1) kp q_k (+ v^n np for endowment); premium annuity-due over m years; return benefit*A/annuity rounded half-up.

split: open-access


prompt:
Deferred annuity values are one payment short.

Input l (from issue age), defer n, guarantee g, term (None = to end of table), i. Payments at times n..end-1; the first g payments are certain once the annuitant survives the deferral (probability l_n/l_0), later payments need survival to k. PV = sum v^k * probability, rounded to 6. l_0=0 or negative n/g -> 'invalid'.

split: open-access


prompt:
Guaranteed payments are valued as certain from issue.

Input l (from issue age), defer n, guarantee g, term (None = to end of table), i. Payments at times n..end-1; the first g payments are certain once the annuitant survives the deferral (probability l_n/l_0), later payments need survival to k. PV = sum v^k * probability, rounded to 6. l_0=0 or negative n/g -> 'invalid'.

split: open-access


prompt:
A 3-year certain period guarantees four payments.

Input l (from issue age), defer n, guarantee g, term (None = to end of table), i. Payments at times n..end-1; the first g payments are certain once the annuitant survives the deferral (probability l_n/l_0), later payments need survival to k. PV = sum v^k * probability, rounded to 6. l_0=0 or negative n/g -> 'invalid'.

split: open-access


prompt:
Temporary deferred annuities lose payments equal to the deferral.

Input l (from issue age), defer n, guarantee g, term (None = to end of table), i. Payments at times n..end-1; the first g payments are certain once the annuitant survives the deferral (probability l_n/l_0), later payments need survival to k. PV = sum v^k * probability, rounded to 6. l_0=0 or negative n/g -> 'invalid'.

split: open-access


prompt:
The present value ignores interest during deferral.

Input l (from issue age), defer n, guarantee g, term (None = to end of table), i. Payments at times n..end-1; the first g payments are certain once the annuitant survives the deferral (probability l_n/l_0), later payments need survival to k. PV = sum v^k * probability, rounded to 6. l_0=0 or negative n/g -> 'invalid'.

split: open-access


prompt:
Last-survivor probabilities exceed one.

Input lx, ly (independent lives, survival zero beyond each table), status joint|last (else 'unknown status'), t. Joint: tp_x*tp_y; last survivor: tp_x+tp_y-tp_x*tp_y. Return [status survival at t, curtate expectation = sum over k from 1 to the longer table length - 1], rounded to 6.

split: open-access


prompt:
Joint-life survival is overstated.

Input lx, ly (independent lives, survival zero beyond each table), status joint|last (else 'unknown status'), t. Joint: tp_x*tp_y; last survivor: tp_x+tp_y-tp_x*tp_y. Return [status survival at t, curtate expectation = sum over k from 1 to the longer table length - 1], rounded to 6.

split: open-access


prompt:
Last-survivor expectation ignores years when only the longer-lived table survives.

Input lx, ly (independent lives, survival zero beyond each table), status joint|last (else 'unknown status'), t. Joint: tp_x*tp_y; last survivor: tp_x+tp_y-tp_x*tp_y. Return [status survival at t, curtate expectation = sum over k from 1 to the longer table length - 1], rounded to 6.

split: open-access


prompt:
Lives from open tables never die after the last tabulated age.

Input lx, ly (independent lives, survival zero beyond each table), status joint|last (else 'unknown status'), t. Joint: tp_x*tp_y; last survivor: tp_x+tp_y-tp_x*tp_y. Return [status survival at t, curtate expectation = sum over k from 1 to the longer table length - 1], rounded to 6.

split: open-access


prompt:
Curtate expectations are one year too high.

Input lx, ly (independent lives, survival zero beyond each table), status joint|last (else 'unknown status'), t. Joint: tp_x*tp_y; last survivor: tp_x+tp_y-tp_x*tp_y. Return [status survival at t, curtate expectation = sum over k from 1 to the longer table length - 1], rounded to 6.

split: open-access


prompt:
Generational tables show no improvement as the cohort ages.

Input q {age: per 100000 at base_year}, aa {age: annual improvement per 10000}, age, year, n, mode static|generational. For k<n: attained age age+k, projection year = year+k (generational) or year (static); q = min(1, q_base*(1-AA)^(year-base)) with negative exponents de-improving. Missing age -> 'missing age <a>'. Return rates rounded to 8.

split: open-access


prompt:
Older ages are improved at the younger age's rate.

Input q {age: per 100000 at base_year}, aa {age: annual improvement per 10000}, age, year, n, mode static|generational. For k<n: attained age age+k, projection year = year+k (generational) or year (static); q = min(1, q_base*(1-AA)^(year-base)) with negative exponents de-improving. Missing age -> 'missing age <a>'. Return rates rounded to 8.

split: open-access


prompt:
Historical-year rates equal base-year rates.

Input q {age: per 100000 at base_year}, aa {age: annual improvement per 10000}, age, year, n, mode static|generational. For k<n: attained age age+k, projection year = year+k (generational) or year (static); q = min(1, q_base*(1-AA)^(year-base)) with negative exponents de-improving. Missing age -> 'missing age <a>'. Return rates rounded to 8.

split: open-access


prompt:
De-improved old-age rates exceed one.

Input q {age: per 100000 at base_year}, aa {age: annual improvement per 10000}, age, year, n, mode static|generational. For k<n: attained age age+k, projection year = year+k (generational) or year (static); q = min(1, q_base*(1-AA)^(year-base)) with negative exponents de-improving. Missing age -> 'missing age <a>'. Return rates rounded to 8.

split: open-access


prompt:
Long projections over-improve mortality.

Input q {age: per 100000 at base_year}, aa {age: annual improvement per 10000}, age, year, n, mode static|generational. For k<n: attained age age+k, projection year = year+k (generational) or year (static); q = min(1, q_base*(1-AA)^(year-base)) with negative exponents de-improving. Missing age -> 'missing age <a>'. Return rates rounded to 8.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    d=x['deaths']; E=Fraction(*x['exposure'])
    if E<=0 or d<0: return 'invalid'
    m=Fraction(d)/E
    if x['method']=='udd':
        q=m*(1-m/2)
    elif x['method']=='cfm':
        q=Fraction(1-math.exp(-float(m)))
    elif x['method']=='actuarial':
        q=Fraction(d)/(E+d)
    else:
        return 'unknown method'
    if q>1: return 'rate exceeds unity'
    return [round(float(m),8),round(float(q),8)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['udd typical', {'deaths': 34, 'exposure': [3917, 1], 'method': 'udd'}, [0.00868011, 0.0086426]], ['cfm typical', {'deaths': 22, 'exposure': [1748, 1], 'method': 'cfm'}, [0.01258581, 0.01250694]], ['actuarial typical', {'deaths': 54, 'exposure': [3265, 1], 'method': 'actuarial'}, [0.01653905, 0.01626996]], ['udd high rate', {'deaths': 31, 'exposure': [40, 1], 'method': 'udd'}, [0.775, 0.55855856]], ['udd rate exactly one', {'deaths': 2, 'exposure': [1, 1], 'method': 'udd'}, [2.0, 1.0]], ['udd rate above one', {'deaths': 5, 'exposure': [2, 1], 'method': 'udd'}, 'rate exceeds unity'], ['negative deaths rejected', {'deaths': -1, 'exposure': [100, 1], 'method': 'udd'}, 'invalid'], ['negative deaths actuarial', {'deaths': -2, 'exposure': [100, 1], 'method': 'actuarial'}, 'invalid'], ['zero exposure rejected', {'deaths': 1, 'exposure': [0, 1], 'method': 'cfm'}, 'invalid'], ['unknown method', {'deaths': 1, 'exposure': [10, 1], 'method': 'balducci'}, 'unknown method']], [['udd typical', {'deaths': 6, 'exposure': [842, 2], 'method': 'udd'}, [0.01425178, 0.01415094]], ['cfm typical', {'deaths': 59, 'exposure': [2784, 1], 'method': 'cfm'}, [0.02119253, 0.02096955]], ['actuarial typical', {'deaths': 20, 'exposure': [2966, 2], 'method': 'actuarial'}, [0.01348618, 0.01330672]], ['udd high rate', {'deaths': 32, 'exposure': [40, 1], 'method': 'udd'}, [0.8, 0.57142857]], ['udd rate exactly one', {'deaths': 4, 'exposure': [2, 1], 'method': 'udd'}, [2.0, 1.0]], ['udd rate above one', {'deaths': 10, 'exposure': [4, 1], 'method': 'udd'}, 'rate exceeds unity'], ['negative deaths rejected', {'deaths': -1, 'exposure': [100, 1], 'method': 'udd'}, 'invalid'], ['negative deaths actuarial', {'deaths': -2, 'exposure': [100, 1], 'method': 'actuarial'}, 'invalid'], ['zero exposure rejected', {'deaths': 1, 'exposure': [0, 1], 'method': 'cfm'}, 'invalid'], ['unknown method', {'deaths': 1, 'exposure': [10, 1], 'method': 'balducci'}, 'unknown method']], [['udd typical', {'deaths': 24, 'exposure': [4705, 1], 'method': 'udd'}, [0.00510096, 0.00508798]], ['cfm typical', {'deaths': 30, 'exposure': [3205, 4], 'method': 'cfm'}, [0.0374415, 0.03674923]], ['actuarial typical', {'deaths': 31, 'exposure': [2250, 1], 'method': 'actuarial'}, [0.01377778, 0.01359053]], ['udd high rate', {'deaths': 33, 'exposure': [40, 1], 'method': 'udd'}, [0.825, 0.5840708]], ['udd rate exactly one', {'deaths': 6, 'exposure': [3, 1], 'method': 'udd'}, [2.0, 1.0]], ['udd rate above one', {'deaths': 15, 'exposure': [6, 1], 'method': 'udd'}, 'rate exceeds unity'], ['negative deaths rejected', {'deaths': -1, 'exposure': [100, 1], 'method': 'udd'}, 'invalid'], ['negative deaths actuarial', {'deaths': -2, 'exposure': [100, 1], 'method': 'actuarial'}, 'invalid'], ['zero exposure rejected', {'deaths': 1, 'exposure': [0, 1], 'method': 'cfm'}, 'invalid'], ['unknown method', {'deaths': 1, 'exposure': [10, 1], 'method': 'balducci'}, 'unknown method']], [['udd typical', {'deaths': 49, 'exposure': [2311, 4], 'method': 'udd'}, [0.08481177, 0.08136156]], ['cfm typical', {'deaths': 58, 'exposure': [2503, 4], 'method': 'cfm'}, [0.09268877, 0.08852287]], ['actuarial typical', {'deaths': 40, 'exposure': [4345, 1], 'method': 'actuarial'}, [0.00920598, 0.00912201]], ['udd high rate', {'deaths': 34, 'exposure': [40, 1], 'method': 'udd'}, [0.85, 0.59649123]], ['udd rate exactly one', {'deaths': 8, 'exposure': [4, 1], 'method': 'udd'}, [2.0, 1.0]], ['udd rate above one', {'deaths': 20, 'exposure': [8, 1], 'method': 'udd'}, 'rate exceeds unity'], ['negative deaths rejected', {'deaths': -1, 'exposure': [100, 1], 'method': 'udd'}, 'invalid'], ['negative deaths actuarial', {'deaths': -2, 'exposure': [100, 1], 'method': 'actuarial'}, 'invalid'], ['zero exposure rejected', {'deaths': 1, 'exposure': [0, 1], 'method': 'cfm'}, 'invalid'], ['unknown method', {'deaths': 1, 'exposure': [10, 1], 'method': 'balducci'}, 'unknown method']], [['udd typical', {'deaths': 43, 'exposure': [1418, 4], 'method': 'udd'}, [0.1212976, 0.1143617]], ['cfm typical', {'deaths': 51, 'exposure': [2058, 4], 'method': 'cfm'}, [0.09912536, 0.09437083]], ['actuarial typical', {'deaths': 36, 'exposure': [959, 4], 'method': 'actuarial'}, [0.15015641, 0.13055304]], ['udd high rate', {'deaths': 35, 'exposure': [40, 1], 'method': 'udd'}, [0.875, 0.60869565]], ['udd rate exactly one', {'deaths': 10, 'exposure': [5, 1], 'method': 'udd'}, [2.0, 1.0]], ['udd rate above one', {'deaths': 25, 'exposure': [10, 1], 'method': 'udd'}, 'rate exceeds unity'], ['negative deaths rejected', {'deaths': -1, 'exposure': [100, 1], 'method': 'udd'}, 'invalid'], ['negative deaths actuarial', {'deaths': -2, 'exposure': [100, 1], 'method': 'actuarial'}, 'invalid'], ['zero exposure rejected', {'deaths': 1, 'exposure': [0, 1], 'method': 'cfm'}, 'invalid'], ['unknown method', {'deaths': 1, 'exposure': [10, 1], 'method': 'balducci'}, 'unknown method']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    d=x['deaths']; E=Fraction(*x['exposure'])
    if E<=0 or d<0: return 'invalid'
    m=Fraction(d)/E
    if x['method']=='udd':
        q=m/(1+m)
    elif x['method']=='cfm':
        q=Fraction(1-math.exp(-float(m)))
    elif x['method']=='actuarial':
        q=Fraction(d)/(E+d)
    else:
        return 'unknown method'
    if q>1: return 'rate exceeds unity'
    return [round(float(m),8),round(float(q),8)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['udd typical', {'deaths': 34, 'exposure': [3917, 1], 'method': 'udd'}, [0.00868011, 0.0086426]], ['cfm typical', {'deaths': 22, 'exposure': [1748, 1], 'method': 'cfm'}, [0.01258581, 0.01250694]], ['actuarial typical', {'deaths': 54, 'exposure': [3265, 1], 'method': 'actuarial'}, [0.01653905, 0.01626996]], ['udd high rate', {'deaths': 31, 'exposure': [40, 1], 'method': 'udd'}, [0.775, 0.55855856]], ['udd rate exactly one', {'deaths': 2, 'exposure': [1, 1], 'method': 'udd'}, [2.0, 1.0]], ['udd rate above one', {'deaths': 5, 'exposure': [2, 1], 'method': 'udd'}, 'rate exceeds unity'], ['negative deaths rejected', {'deaths': -1, 'exposure': [100, 1], 'method': 'udd'}, 'invalid'], ['negative deaths actuarial', {'deaths': -2, 'exposure': [100, 1], 'method': 'actuarial'}, 'invalid'], ['zero exposure rejected', {'deaths': 1, 'exposure': [0, 1], 'method': 'cfm'}, 'invalid'], ['unknown method', {'deaths': 1, 'exposure': [10, 1], 'method': 'balducci'}, 'unknown method']], [['udd typical', {'deaths': 6, 'exposure': [842, 2], 'method': 'udd'}, [0.01425178, 0.01415094]], ['cfm typical', {'deaths': 59, 'exposure': [2784, 1], 'method': 'cfm'}, [0.02119253, 0.02096955]], ['actuarial typical', {'deaths': 20, 'exposure': [2966, 2], 'method': 'actuarial'}, [0.01348618, 0.01330672]], ['udd high rate', {'deaths': 32, 'exposure': [40, 1], 'method': 'udd'}, [0.8, 0.57142857]], ['udd rate exactly one', {'deaths': 4, 'exposure': [2, 1], 'method': 'udd'}, [2.0, 1.0]], ['udd rate above one', {'deaths': 10, 'exposure': [4, 1], 'method': 'udd'}, 'rate exceeds unity'], ['negative deaths rejected', {'deaths': -1, 'exposure': [100, 1], 'method': 'udd'}, 'invalid'], ['negative deaths actuarial', {'deaths': -2, 'exposure': [100, 1], 'method': 'actuarial'}, 'invalid'], ['zero exposure rejected', {'deaths': 1, 'exposure': [0, 1], 'method': 'cfm'}, 'invalid'], ['unknown method', {'deaths': 1, 'exposure': [10, 1], 'method': 'balducci'}, 'unknown method']], [['udd typical', {'deaths': 24, 'exposure': [4705, 1], 'method': 'udd'}, [0.00510096, 0.00508798]], ['cfm typical', {'deaths': 30, 'exposure': [3205, 4], 'method': 'cfm'}, [0.0374415, 0.03674923]], ['actuarial typical', {'deaths': 31, 'exposure': [2250, 1], 'method': 'actuarial'}, [0.01377778, 0.01359053]], ['udd high rate', {'deaths': 33, 'exposure': [40, 1], 'method': 'udd'}, [0.825, 0.5840708]], ['udd rate exactly one', {'deaths': 6, 'exposure': [3, 1], 'method': 'udd'}, [2.0, 1.0]], ['udd rate above one', {'deaths': 15, 'exposure': [6, 1], 'method': 'udd'}, 'rate exceeds unity'], ['negative deaths rejected', {'deaths': -1, 'exposure': [100, 1], 'method': 'udd'}, 'invalid'], ['negative deaths actuarial', {'deaths': -2, 'exposure': [100, 1], 'method': 'actuarial'}, 'invalid'], ['zero exposure rejected', {'deaths': 1, 'exposure': [0, 1], 'method': 'cfm'}, 'invalid'], ['unknown method', {'deaths': 1, 'exposure': [10, 1], 'method': 'balducci'}, 'unknown method']], [['udd typical', {'deaths': 49, 'exposure': [2311, 4], 'method': 'udd'}, [0.08481177, 0.08136156]], ['cfm typical', {'deaths': 58, 'exposure': [2503, 4], 'method': 'cfm'}, [0.09268877, 0.08852287]], ['actuarial typical', {'deaths': 40, 'exposure': [4345, 1], 'method': 'actuarial'}, [0.00920598, 0.00912201]], ['udd high rate', {'deaths': 34, 'exposure': [40, 1], 'method': 'udd'}, [0.85, 0.59649123]], ['udd rate exactly one', {'deaths': 8, 'exposure': [4, 1], 'method': 'udd'}, [2.0, 1.0]], ['udd rate above one', {'deaths': 20, 'exposure': [8, 1], 'method': 'udd'}, 'rate exceeds unity'], ['negative deaths rejected', {'deaths': -1, 'exposure': [100, 1], 'method': 'udd'}, 'invalid'], ['negative deaths actuarial', {'deaths': -2, 'exposure': [100, 1], 'method': 'actuarial'}, 'invalid'], ['zero exposure rejected', {'deaths': 1, 'exposure': [0, 1], 'method': 'cfm'}, 'invalid'], ['unknown method', {'deaths': 1, 'exposure': [10, 1], 'method': 'balducci'}, 'unknown method']], [['udd typical', {'deaths': 43, 'exposure': [1418, 4], 'method': 'udd'}, [0.1212976, 0.1143617]], ['cfm typical', {'deaths': 51, 'exposure': [2058, 4], 'method': 'cfm'}, [0.09912536, 0.09437083]], ['actuarial typical', {'deaths': 36, 'exposure': [959, 4], 'method': 'actuarial'}, [0.15015641, 0.13055304]], ['udd high rate', {'deaths': 35, 'exposure': [40, 1], 'method': 'udd'}, [0.875, 0.60869565]], ['udd rate exactly one', {'deaths': 10, 'exposure': [5, 1], 'method': 'udd'}, [2.0, 1.0]], ['udd rate above one', {'deaths': 25, 'exposure': [10, 1], 'method': 'udd'}, 'rate exceeds unity'], ['negative deaths rejected', {'deaths': -1, 'exposure': [100, 1], 'method': 'udd'}, 'invalid'], ['negative deaths actuarial', {'deaths': -2, 'exposure': [100, 1], 'method': 'actuarial'}, 'invalid'], ['zero exposure rejected', {'deaths': 1, 'exposure': [0, 1], 'method': 'cfm'}, 'invalid'], ['unknown method', {'deaths': 1, 'exposure': [10, 1], 'method': 'balducci'}, 'unknown method']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Converted mortality rates are too low and turn negative for high central rates.

Input deaths, exposure [num, den] central person-years, method udd|cfm|actuarial. m = deaths/exposure. UDD q=m/(1+m/2); constant force q=1-exp(-m); actuarial q=deaths/(exposure+deaths). exposure<=0 or deaths<0 -> 'invalid'; q>1 -> 'rate exceeds unity'; other method -> 'unknown method'. Return [m, q] rounded to 8.

split: open-access