quantize_pdf_to_rans_cdf

Function quantize_pdf_to_rans_cdf 

Source
pub fn quantize_pdf_to_rans_cdf(pdf: &[f64]) -> Vec<u32>
Expand description

Quantize PDF to rANS CDF table with guaranteed minimum frequencies.

This implements a robust quantization algorithm that ensures:

  1. All symbols with p > 0 get freq >= 1
  2. The total equals ANS_TOTAL exactly
  3. Monotonicity is preserved (cdf[i+1] >= cdf[i])

Uses error diffusion to distribute rounding errors across symbols.

§Arguments

  • pdf - Probability distribution (must sum to ~1.0)

§Returns

CDF table where cdf[i] = cumulative probability up to symbol i