Common Errors
This page lists the most frequent error messages in ToFUL, explains what causes each one, and gives concrete fixes.
Validation Errors
“PMF sums to X ≠ 1.0”
What it means: ToFUL evaluated your probability mass function over the given support and the total came out to a value other than 1.
Common causes and fixes:
Wrong parameter value
# Bug — probabilities sum to 0.7, not 1.0
0.3 * (0.4 ** x) if x >= 0 else 0
# Fix — use the correct base: q = 1 - p
0.3 * (0.7 ** x) if x >= 0 else 0
Forgotten normalising constant
# Bug — unnormalised Poisson
(3 ** x) / factorial(x) if x >= 0 else 0
# Fix — include exp(-lambda)
(exp(-3) * 3**x) / factorial(x) if x >= 0 else 0
PMF defined only on a subset of the given range
If your range is 1,2,3,4,5 but the PMF returns 0 for some values,
ensure probabilities over the non-zero values still sum to 1.
Finite range too narrow for an infinite-support distribution
If you entered a finite range like 0,1,2,3,4,5 for a Geometric
distribution, only the probability in that window is summed — the
tail is excluded. Use the infinite notation 0,1,2,3,... instead.
“Negative probabilities detected at x = […]”
What it means: The PMF returned a negative value at one or more support points.
Common causes:
Sign error in the formula — check for an extra minus sign.
Condition in the
ifguard is inverted, causing the negative branch to fire when the positive one was intended.
# Bug — returns negative for x > 0
-0.3 * (0.7 ** x) if x >= 0 else 0
# Fix
0.3 * (0.7 ** x) if x >= 0 else 0
“PDF integrates to X ≠ 1.0”
What it means: Numerical integration of your PDF over the given bounds did not return 1.0 within the precision tolerance.
Common causes and fixes:
Wrong bounds
# Bug — Exponential(2) integrated only to 5, missing most of the tail
Lower: 0 Upper: 5
# Fix
Lower: 0 Upper: inf
Missing guard
# Bug — evaluates e^x for x > 0, which grows without bound
PDF: exp(-x)
# Fix — restrict to the correct support
PDF: exp(-x) if x >= 0 else 0
Wrong normalising constant
Use the validation step to read off the actual integral, then divide your PDF by that value and recompute.
“Negative PDF value at x ≈ […]”
ToFUL spot-checks 100 test points before integrating. If any evaluate negative, validation stops immediately.
Ensure the PDF is non-negative everywhere on the support. If you are modelling a signed function for other purposes, ToFUL is not the right tool for that calculation.
Syntax Errors
“Syntax error: invalid syntax (position N)”
The expression could not be parsed as valid Python after auto-correction.
Most common causes:
What was typed |
Fix |
|---|---|
|
Not an error — auto-corrected to |
|
Not an error — auto-corrected to |
|
Remove |
|
Use round brackets: |
|
Enter just the value: |
|
Write: |
|
|
Unmatched brackets
Count opening and closing brackets. Each ( must have a matching )
and vice versa.
# Bug — unmatched bracket
exp(-2*x if x >= 0 else 0
# Fix
exp(-2*x) if x >= 0 else 0
Range Errors
“Cannot parse range ‘…’”
The range string could not be converted to a list of numbers.
Common causes:
Spaces without commas:
1 2 3→ use1,2,3Non-numeric characters:
x=0,1,2→ use0,1,2Decimal comma instead of decimal point (locale issue):
1,5as “one point five” → use1.5
“Lower bound must be strictly less than upper bound”
The lower and upper bounds you entered are equal or in the wrong order. Enter the smaller value as Lower and the larger as Upper.
Computation Errors
“Computation error: OverflowError”
A value exceeded the float64 range (approximately \(1.8 \times 10^{308}\)).
This typically happens when computing high-order moments of heavy-tailed distributions, or when a PMF formula produces very large intermediate values.
Fixes:
Reduce the maximum moment order.
Use the
gammafunction instead offactorialfor large arguments.Reformulate the expression to avoid intermediate large numbers:
# Bug — computes 100! internally, overflows
factorial(100) / (factorial(x) * factorial(100-x))
# Fix — use log-space or gamma
exp(log(gamma(101)) - log(gamma(x+1)) - log(gamma(101-x)))
“Computation error: ZeroDivisionError”
Division by zero in the PMF or PDF expression.
Check for a denominator that can be zero at any support point:
# Bug — divides by x, which is 0 for the first support value
1 / x if x > 0 else 0.5
# Fix — guard the denominator
1 / x if x > 0 else 0
See also
Debugging Functions — step-by-step function debugging
Convergence Issues — convergence-specific problems
Input Syntax Guide — complete syntax reference