rohitg00/ai-engineering-from-scratch · error · ValueError
x out of [0, 1]
Error message
x out of [0, 1]
What it means
Error "x out of [0, 1]" thrown in rohitg00/ai-engineering-from-scratch.
Source
Thrown at phases/19-capstone-projects/53-result-evaluator/code/main.py:129
aa = -(a + m) * (qab + m) * x / ((a + m2) * (qap + m2))
d = 1.0 + aa * d
if abs(d) < eps:
d = eps
c = 1.0 + aa / c
if abs(c) < eps:
c = eps
d = 1.0 / d
delta = d * c
h *= delta
if abs(delta - 1.0) < eps:
return h
return h
def regularised_incomplete_beta(a: float, b: float, x: float) -> float:
"""I_x(a, b) via the standard Lentz continued fraction, symmetric in x."""
if x < 0.0 or x > 1.0:
raise ValueError("x out of [0, 1]")
if x == 0.0:
return 0.0
if x == 1.0:
return 1.0
log_bt = (
math.lgamma(a + b) - math.lgamma(a) - math.lgamma(b)
+ a * math.log(x) + b * math.log(1.0 - x)
)
bt = math.exp(log_bt)
if x < (a + 1.0) / (a + b + 2.0):
return bt * _lentz_betacf(a, b, x) / a
return 1.0 - bt * _lentz_betacf(b, a, 1.0 - x) / b
def two_sided_t_p_value(t_stat: float, df: int) -> float:
"""Two sided p value for a t statistic with df degrees of freedom."""
if df <= 0:
return 1.0View on GitHub (pinned to 39ea8a1c6d)
When it happens
Trigger: Thrown at phases/19-capstone-projects/53-result-evaluator/code/main.py:129 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26).
Data as JSON: /api/errors/a31d6f3a8215ab12.
Report an issue: GitHub.