Metrics#

compute_PAPR(x_data, unit='natural', axis=None)#

Compute the Peak-to-Average Power Ratio (PAPR) of the input data.

Parameters#

x_datanp.ndarray

Input data for which PAPR needs to be calculated.

unitstr, optional

The unit for PAPR calculation. It can be either “natural” for natural units or “dB” for logarithmic units. Default is “natural”.

axisint or None, optional

The axis along which to compute the PAPR. If None, the PAPR is computed over the entire array. Default is None.

Returns#

float or np.ndarray

The computed PAPR value(s). If axis is specified, returns an array of PAPR values.

Raises#

NotImplementedError

If the specified unit is not supported.

Notes#

The PAPR is computed using the formulas:

  • For natural units:

\[\text{PAPR} = \frac{x_{\text{max}}}{\sqrt{P_{\text{moy}}}}\]
  • For dB units:

\[\text{PAPR} = 10 \log_{10} \left( \frac{x_{\text{max}}^2}{P_{\text{moy}}} \right)\]

where:

  • \(x_{\text{max}}\) is the maximum power value in x_data,

  • \(P_{\text{moy}}\) is the mean power value in x_data.

Examples#

>>> import numpy as np
>>> data = np.array([1, 2, 3, 4])
>>> compute_PAPR(data, unit="natural")
2.0
>>> compute_PAPR(data, unit="dB")
6.0206...
>>> data_2d = np.array([[1, 2], [3, 4]])
>>> compute_PAPR(data_2d, unit="natural", axis=0)
array([1.63299316, 1.41421356])