Skip to main content

Module source

Module source 

Source
Expand description

Sources of bits and symbols (OptiCommPy optic.comm.sources).

  • bits: independent fair bits from a seeded generator, and qpsk, one unit-energy QPSK point (the pilots and preambles drawn from a seed);
  • prbs: maximal-length pseudo-random binary sequences with the polynomials of ITU-T O.150 (orders 9, 11, 15, 20, 23, 29, 31, and 7), produced by a Fibonacci linear-feedback shift register from any register state: the sequence of order n has period 2ⁿ - 1 and contains every non-zero n-bit word exactly once per period;
  • O150Sequence: the eight test sequences of ITU-T O.150 (05/96), Sec. 5, exactly: the polynomial, the inversion of the output (Sec. 4), the zero suppression of the second sequence of period $2^{20} - 1$ (Sec. 5.5) and the starting phase of the 511-bit sequence (Sec. 5.1), the sequences of the error-rate test sets;
  • symbols: random symbols of a constellation with a given probability mass function, uniform by default, or Maxwell–Boltzmann shaped with maxwell_boltzmann (probabilistic shaping, p(x) ∝ exp(-λ|x|²)).

§Examples

use comnum_mapping::source;
use comnum_core::rng::Rng;
let b = source::bits(1000, &mut Rng::new(3));
assert!(b.iter().all(|&v| v <= 1));
let p = source::prbs(7, 127 * 2, 1).unwrap();
assert_eq!(&p[..127], &p[127..]);           // period 2⁷ - 1
assert_eq!(p[..127].iter().filter(|&&v| v == 1).count(), 64);
// the 2¹⁵ − 1 sequence of the O.151 test sets: inverted, it starts with 15 zeros
let t = source::O150Sequence::Prbs15.bits(16);
assert_eq!(&t[..15], &[0; 15]);
assert_eq!(t[15], 1);

§References

  1. ITU-T Recommendation O.150 (05/96), General requirements for instrumentation for performance measurements on digital transmission equipment, Sec. 3 to 5 and Table 1.

Structs§

O150Bits
The bits of an O150Sequence (O150Sequence::iter).

Enums§

O150Sequence
The pseudo-random test sequences of ITU-T O.150 (05/96), Sec. 5 and Table 1.

Functions§

bits
n independent fair bits (0 or 1).
maxwell_boltzmann
Maxwell–Boltzmann probabilities p_i ∝ exp(-λ |x_i|²) over the points of c.
prbs
length bits of the PRBS of order order, from the register state seed.
qpsk
One unit-energy QPSK point $e^{j\pi(2i + 1)/4}$, $i$ uniform in 0..4 (one draw of Rng::below): the pilots and preambles drawn from a seed.
symbols
n random symbols of c drawn with the probabilities px (uniform if None, normalised to a sum of 1 otherwise, as Constellation::priors).