bundles / scipy latest / scipy / stats / _distribution_infrastructure / log
function
scipy.stats._distribution_infrastructure:log
source: build-install/usr/lib/python3.14/site-packages/scipy/stats/_distribution_infrastructure.py:5782
Signature
def log(X, /)Summary
Natural logarithm of a non-negative random variable.
Parameters
X: `ContinuousDistribution`The random variable with positive support.
Returns
Y: `ContinuousDistribution`A random variable .
Examples
Suppose we have a gamma distributed random variable :math:`X`:import numpy as np from scipy import stats Gamma = stats.make_distribution(stats.gamma) X = Gamma(a=1.0)✓
Y = stats.log(X)
✓import matplotlib.pyplot as plt rng = np.random.default_rng(435383595582522) y = Y.sample(shape=10000, rng=rng) ax = plt.gca()✓
ax.hist(np.exp(y), bins=50, density=True) X.plot(ax=ax) plt.legend(('PDF of `X`', 'histogram of `exp(y)`'))✗
<matplotlib.legend.Legend object at 0x7f3f68269400>
plt.show()
✓
Aliases
scipy.stats.log