bundles / scipy 1.17.1 / scipy / stats / _distribution_infrastructure / abs
function
scipy.stats._distribution_infrastructure:abs
Signature
def abs ( X , / ) Summary
Absolute value of a random variable
Parameters
X: `ContinuousDistribution`The random variable .
Returns
Y: `ContinuousDistribution`A random variable .
Notes
Array API Standard Support
abs has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ⛔ PyTorch ⛔ ⛔ JAX ⛔ ⛔ Dask ⛔ n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
Examples
Suppose we have a normally distributed random variable :math:`X`:import numpy as np from scipy import stats X = stats.Normal()✓
Y = stats.abs(X)
✓import matplotlib.pyplot as plt x = np.linspace(0, 5, 300) ax = plt.gca()✓
Y.plot(x='x', y='pdf', t=('x', -1, 5), ax=ax) plt.plot(x, 2 * X.pdf(x), '--') plt.legend(('PDF of `Y`', 'Doubled PDF of `X`'))✗
plt.show()
✓
Aliases
-
scipy.stats.abs