Factor count¶
lzsuite.complexity ¶
Count completed LZ76 phrases along an array axis.
Parameters:
-
data(array_like) –Real numeric, boolean, Unicode-string, or byte-string array. Each position outside
axisidentifies 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.
Returns:
-
counts(int or ndarray) –Python int for a 1D input; otherwise an integer array with
axisremoved. Counts follow the backend's completed-phrase convention.
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
Constant sequences have count 1. A final copied tail can appear in
factor boundaries without adding to the count. Raw counts depend on
sequence length and encoding; h provides entropy-rate normalization.
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
factorization : Factor count and boundary positions. h : Normalized entropy density.
Examples: