comnum.Ccdm#
- class comnum.Ccdm(composition)#
Constant-composition distribution matching (Schulte & Böcherer 2016):
kuniform bits to a sequence ofnsymbols of a fixed composition, by enumerative coding.- Parameters:
composition (list[int]) – occurrences of every symbol in a block.
- Raises:
ValueError – for an invalid parameter (the message names it).
Examples
>>> import comnum, numpy as np >>> m = comnum.Ccdm([2, 1, 1]) >>> b = np.zeros(m.k, dtype=np.uint8) >>> m.dematch(m.match_bits(b)).tolist() == b.tolist() True
- static from_distribution(p, n)#
The matcher of blocks of
nsymbols nearest to a distribution.- Parameters:
p (array_like) – the target distribution of the symbols.
n (int) – symbols per block.
- Returns:
the matcher.
- Return type:
- Raises:
ValueError – for an invalid parameter or input (the message names it).
- dematch(symbols)#
The bits of a block of symbols (a used-up symbol is replaced by the nearest available one).
- Parameters:
symbols (array_like) –
nsymbol indices.- Returns:
kbits (uint8).- Return type:
- Raises:
ValueError – for an invalid parameter or input (the message names it).
- match_bits(bits)#
The symbols of one block of bits.
- Parameters:
bits (array_like) –
kbits.- Returns:
nsymbol indices (int64).- Return type:
- Raises:
ValueError – for an invalid parameter or input (the message names it).
- composition#
Occurrences of every symbol in a block (int64).
- Type:
- distribution#
The distribution of the symbols,
composition / n(float64).- Type: