Description
Multiply supplied probabilities through log space and distinguish true zero factors from floating-point underflow; logProduct zero is unused when zeroFactor=true.
Products of small probabilities can round to zero in floating-point arithmetic. Natural logarithms turn products into sums, and centering or expm1-based expressions can reduce avoidable numerical loss. A finite log weight is different from a raw probability and cannot directly represent an exact zero probability.
Multiply supplied probabilities through log space and distinguish true zero factors from floating-point underflow; logProduct zero is unused when zeroFactor=true.
When to use this tool
Use Probability: Probability Product Log Under Flow Check when you need the stated natural-log contribution or stable conversion between a finite log representation and an ordinary value.
How to use the tool and how it works
- Enter probabilities. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read result. Expand result to inspect the returned fields.
Validate every probability within zero through one. If any factor is zero return zeroFactor=true, product=0, logProduct=0, and underflow=false; otherwise sum natural logs, exponentiate the sum, and flag underflow when the product becomes zero. Outputs are inside result.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| probabilities | Probabilities | Required. Array of finite number. Implementation limit: 128 items. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| result | Object containing the calculated result members described below. | Required. Object. |
| result.zeroFactor | Zero Factor | Calculated result member: boolean. |
| result.logProduct | Natural log product, except zero when zeroFactor marks the log(0) placeholder. | Calculated result member: number. |
| result.product | Product | Calculated result member: number. |
| result.underflow | Underflow | Calculated result member: boolean. |
{
"input": {
"probabilities": [
1e-200,
1e-200
]
},
"output": {
"result": {
"zeroFactor": false,
"logProduct": -921.0340371976183,
"product": 0,
"underflow": true
}
}
} Limitations and assumptions
- The zero logProduct on the zero-factor branch is a placeholder rather than log(0). An empty list gives the multiplicative identity product=1 and logProduct=0.
- Outputs are nested inside result. Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
- Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Signed zero is exported as zero.
Alternative or Complementary methods
Keep long products or normalizations in the log domain when feasible. Check whether exact zeros need a separate flag and whether the final ordinary-scale result is representable.
References
Similar or alternative tools
- Log Probability Weight Centering Offset
For a nonempty finite logWeights list take offset=max(logWeights) and return centered values logWeights-offset.
- Log Probability Logsum Two Weights
Set max=max(left,right) and return logSum=max+ln(exp(left-max)+exp(right-max)).