Skip to content

Full LZ76 analysis

lzsuite.lz76

lz76(
    data,
    *,
    axis=0,
    discretization=None,
    discretization_kwargs=None,
    n_jobs=4,
    log_base=None,
    max_block_size=-1,
    method="chao-shen",
)

Calculate the complete LZ76 analysis for each sequence.

Parameters:

  • data (array_like) –

    Real numeric, boolean, Unicode-string, or byte-string array. Each position outside axis identifies one sequence. Floats default to per-sequence mean binarization; other supported dtypes are symbols.

  • axis (int, default: 0 ) –

    Axis containing successive observations. Negative axes are accepted.

  • discretization (str or callable, default: None ) –

    Registered method name or function applied to each numeric sequence. Overrides automatic mean binarization. Strings cannot be discretized.

  • discretization_kwargs (mapping of str to object, default: None ) –

    Keyword arguments passed to the selected discretizer. Custom methods receive an input copy and may return a different sequence length.

  • n_jobs (int, default: 4 ) –

    Maximum worker processes, capped by available CPUs and calculation count. Use 1 for inline execution or -1 for all available CPUs.

  • log_base (int, default: None ) –

    Logarithm base, at least 2. Defaults to the distinct-symbol count in each prepared sequence, with a minimum of 2 for constant data.

  • max_block_size (int, default: -1 ) –

    Maximum byte-window range for E. Nonpositive values select the backend's automatic range; a positive value keeps that full range.

  • method (('chao-shen', 'shuffle'), default: 'chao-shen' ) –

    E estimator. This option is independent of discretization.

Returns:

  • result ( dict or ndarray ) –

    Dictionary for 1D input; otherwise an object array of dictionaries, with axis removed. Keys are complexity, h, factors, emc, epsilon, factors_stddev, normal_error, poison_error, and extras. The emc dictionary records method, value, summands, max_block_size, and multi_information. Backend field names are preserved.

Raises:

  • TypeError –

    If the dtype, discretizer output, or parameter type is unsupported.

  • ValueError –

    If the sequence axis is empty, values are nonfinite, the axis or settings are invalid, or a custom discretizer returns no labels.

Warns:

  • RuntimeWarning –

    If more than 256 categories must be reduced to the byte alphabet. Categories then merge and results no longer faithfully represent the original alphabet.

Notes

The backend reuses the whole-sequence factorization for several measures and also analyzes two halves for the extras. Diagnostic fields are algebraic formulas, not general confidence intervals. Estimate sampling uncertainty from suitable repeated observations or resampling. Use targeted functions when you only need one measure.

Preparation and discretization run in the caller. Native calculations use reusable joblib processes, with one Rayon thread per worker. The caller's Rayon configuration is unchanged. A single calculation runs inline. Use n_jobs=1 when process overhead outweighs useful work.

See Also

h : Entropy density only. complexity : Factor count only. emc : E and its increments only.

Examples:

>>> import lzsuite as lzs
>>> result = lzs.lz76([0, 1] * 128, max_block_size=4)
>>> result["complexity"] == lzs.complexity([0, 1] * 128)
True
>>> result["emc"]["method"]
'chao-shen'