scipy.stats.
exp#
- scipy.stats.exp(X, /)[Quelle]#
Natürlicher Exponential einer Zufallsvariablen
- Parameter:
- XContinuousDistribution
Die Zufallsvariable \(X\).
- Rückgabe:
- YContinuousDistribution
Eine Zufallsvariable \(Y = \exp(X)\).
Beispiele
Angenommen, wir haben eine normalverteilte Zufallsvariable \(X\)
>>> import numpy as np >>> from scipy import stats >>> X = stats.Normal()
Wir möchten eine log-normalverteilte Zufallsvariable \(Y\) haben, eine Zufallsvariable, deren natürlicher Logarithmus \(X\) ist. Wenn \(X\) der natürliche Logarithmus von \(Y\) sein soll, dann müssen wir \(Y\) als den natürlichen Exponential von \(X\) nehmen.
>>> Y = stats.exp(X)
Um zu zeigen, dass
Xden Logarithmus vonYdarstellt, plotten wir ein normalisiertes Histogramm des Logarithmus von Beobachtungen vonYgegen die zugrunde liegende Dichtefunktion vonX.>>> import matplotlib.pyplot as plt >>> rng = np.random.default_rng() >>> y = Y.sample(shape=10000, rng=rng) >>> ax = plt.gca() >>> ax.hist(np.log(y), bins=50, density=True) >>> X.plot(ax=ax) >>> plt.legend(('PDF of `X`', 'histogram of `log(y)`')) >>> plt.show()