Install and run¶
Python 3.9+.
Choose your symbols¶
| Input | Analyzed as |
|---|---|
"ACGT" |
UTF-8 bytes. |
b"ACGT" |
Raw bytes, unchanged. |
bytes([0, 1, 10]) |
Three symbols: 0, 1, 10. |
["AC", "GT"] |
Joined text: "ACGT". |
[0, 1, 10] |
Decimal text: "0110". |
For state codes 0–255, use bytes(labels); for a NumPy uint8 array,
use labels.tobytes(). Input guide.
Continuous signals → symbols¶
Threshold, bin, or encode a signal before analysis:
signal = [-0.2, 0.5, 0.1, -0.7,
0.8, 0.4, -0.1, -0.3]
symbols = bytes(x > 0 for x in signal)
h = lz.h(symbols, log_base=2)
Here nonpositive → 0, positive → 1.
Factorization¶
count, boundaries = lz.factorization(
"1000110011101"
)
# count: 5
# boundaries: [0, 1, 2, 5, 9, 13]
Use the returned count. Slice encoded bytes using boundaries.
Worked example.
Entropy density h¶
log_base=2 selects bits per input byte. Returns float.
E · effective measure complexity¶
Unpack (E, increments). max_block_size sets the maximum range.
NID · compare sequences¶
Returns float. Use the same symbol encoding for both inputs.
Get the complete result¶
Two useful controls¶
| Setting | Effect |
|---|---|
log_base=2 |
h in bits per input byte. |
max_block_size=16 |
E includes ranges up to 16 bytes. |
Omit these controls for automatic settings. max_block_size belongs to
emc and lz76.