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 X den Logarithmus von Y darstellt, plotten wir ein normalisiertes Histogramm des Logarithmus von Beobachtungen von Y gegen die zugrunde liegende Dichtefunktion von X.

>>> 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()
../../_images/scipy-stats-exp-1.png