General Math Utilities

Channel math utilities for PyBERT.

Original author: David Banas <capn.freako@gmail.com>

Original date: June 16, 2024

Copyright (c) 2024 David Banas; all rights reserved World wide.

A partial extraction of the old pybert/utility.py, as part of a refactoring.

pybert.utility.math.all_combs(xss: list[list[T]]) list[list[T]][source]

Generate all combinations of input.

Parameters:

xss – The lists of candidates for each position in the final output.

Returns:

All possible combinations of inputs.

pybert.utility.math.gaus_pdf(x: numpy.typing.NDArray.~Real, mu: float, sigma: float) numpy.typing.NDArray.~Real[source]

Gaussian probability density function.

pybert.utility.math.lfsr_bits(taps: list[int], seed: int) Iterator[int][source]

Given a set of tap indices and a seed, generate a PRBS.

Parameters:
  • taps – The set of fed back taps. (Largest determines order of generator.)

  • seed – The initial value of the shift register.

Returns:

A PRBS generator object with a next() method for retrieving the next bit in the sequence.

pybert.utility.math.make_bathtub(centers: numpy.typing.NDArray.~Real, jit_pdf: numpy.typing.NDArray.~Real, min_val: float = 0, rj: float = 0, mu_r: float = 0, mu_l: float = 0, extrap: bool = False) tuple[numpy.typing.NDArray.~Real, tuple[int, int]][source]

Generate the “bathtub” curve associated with a particular jitter PDF.

Parameters:
  • centers – List of uniformly spaced bin centers (s). Note: First and last elements are exceptions.

  • jit_pdf – PDF of jitter.

Keyword Arguments:
  • min_val – Minimum value allowed in returned bathtub vector. Default: 0

  • rj – Standard deviation of Gaussian PDF characterizing random jitter. Default: 0

  • mu_r – Mean of Gaussian PDF best fit to right tail. Default: 0

  • mu_l – Mean of Gaussian PDF best fit to left tail. Default: 0

  • extrap – Extrapolate bathtub tails, using rj, if True. Default: False

Returns:

The vector of probabilities forming the bathtub curve.

pybert.utility.math.safe_log10(x)[source]

Guards against pesky ‘Divide by 0’ error messages.