class sdr.ErrorRate

A class for measuring bit error rates (BER) or symbol error rates (SER).

Examples

Create a new bit error rate measurement object.

In [1]: ber = sdr.ErrorRate()

In [2]: x = [1, 1, 1, 1, 1]  # Reference bit vector

Measure and accumulate bit errors from the first received bit vector containing 1 bit error at 10 dB SNR. The bit error rate of the first received bit vector is 0.2.

In [3]: x_hat = [1, 0, 1, 1, 1]

In [4]: ber.add(10, x, x_hat)
Out[4]: (np.int64(1), 5, np.float64(0.2))

Measure and accumulate bit errors from the second received bit vector containing 2 bit errors at 10 dB SNR. The bit error rate of the second received bit vector is 0.4.

In [5]: x_hat = [1, 0, 1, 0, 1]

In [6]: ber.add(10, x, x_hat)
Out[6]: (np.int64(2), 5, np.float64(0.4))

The total errors are 3, total bits 10, and average bit error rate 0.3.

In [7]: ber.errors(10), ber.counts(10), ber.error_rate(10)
Out[7]: (np.int64(3), 10, np.float64(0.3))

Average bit error rates for every SNR can be obtained as follows.

In [8]: ber.error_rates()
Out[8]: (array([10]), array([0.3]))

Constructors

ErrorRate()

Creates a new error rate tabulation object.

Methods

add(snr: float, x: ArrayLike, x_hat) tuple[int, int, int]

Measures the number of bit or symbol errors at the given signal-to-noise ratio (SNR).

errors(snr: float) int

Returns the number of errors at the specified signal-to-noise ratio (SNR).

counts(snr: float) int

Returns the number of counts at the specified signal-to-noise ratio (SNR).

error_rate(snr: float) float

Returns the error rate at the specified signal-to-noise ratio (SNR).

error_rates() tuple[NDArray[float64], NDArray[float64]]

Returns all signal-to-noise ratios (SNRs) in ascending order and their corresponding error rates.