Description
Compute -ln(probability)/ln(radix) for idealLength, ceil it for integerLength, and return their gap.
A prefix-free code prevents any distinct codeword from beginning with another complete codeword. Kraft terms describe length budgets, while actual prefix relationships depend on the codewords themselves.
Compute -ln(probability)/ln(radix) for idealLength, ceil it for integerLength, and return their gap.
When to use this tool
Use Information: Ideal Codeword Length Integer Gap when you need one prefix relationship or code-length contribution.
How to use the tool and how it works
- Enter probability, radix. 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.
Compute -ln(probability)/ln(radix) for idealLength, ceil it for integerLength, and return their gap.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| probability | Probability in the stated interval; zero handling follows the calculation above. | Required. Finite number. |
| radix | Radix | Required. Safe integer. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| result | Result | Required. Object. |
| result.idealLength | Ideal Length | Calculated result member: number. |
| result.integerLength | Integer Length | Calculated result member: number. |
| result.roundingGap | Rounding Gap | Calculated result member: number. |
{
"input": {
"probability": 0.25,
"radix": 2
},
"output": {
"result": {
"idealLength": 2,
"integerLength": 2,
"roundingGap": 0
}
}
} Limitations and assumptions
- Probability is in (0, 1] and radix at least two; rounding one length does not construct a valid complete codebook.
- 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. Numeric signed-zero results are exported as zero.
Alternative or Complementary methods
Validate the complete codebook and alphabet before making a decoding or feasibility claim.
References
Similar or alternative tools
- Information: Code Redundancy Per Symbol
Return their difference and 1 - entropy/averageCodeLength, or relativeRedundancy zero at a zero average.
- Information: Kraft Single Codeword Term
Return exp(-length × ln(radix)) for integer length 0-1000 and radix at least two.