Skip to content
Snippets Groups Projects
Commit 6ab1632a authored by Ulrich Kerzel's avatar Ulrich Kerzel
Browse files

notebook for powerintegral tranform

parent d3c33f7e
Branches
Tags
No related merge requests found
%% Cell type:code id: tags:
```
import scipy.stats as stats
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
```
%% Cell type:code id: tags:
```
n_samples = 100000
x_space = np.linspace(-4,4, 500)
mu = 0
sigma = 1
gauss_dist = stats.norm(mu, sigma)
samples = gauss_dist.rvs(size=n_samples)
y = gauss_dist.pdf(x_space)
```
%% Cell type:code id: tags:
```
x_space = np.linspace(0, 30, 500)
moyal_dist = stats.moyal(loc=6.0, scale = 1.5)
moyal_dist2 = stats.moyal(loc=6.3, scale = 1.5)
samples = moyal_dist.rvs(size=n_samples)
y = moyal_dist.pdf(x_space)
```
%% Cell type:code id: tags:
```
fig, ax = plt.subplots(nrows=2, ncols=1, sharex=True)
sns.histplot(samples, ax=ax[0], bins = 50, stat='density', cumulative=False, label='Simulation')
ax[0].fill_between(x_space, y, color='red', alpha=0.2, label='True Distrib.')
ax[0].set_title('Probability Distribution')
sns.histplot(samples, ax=ax[1], bins = 50, stat='density', cumulative=True)
ax[1].set_title('Cumulative Distribution')
lines_labels = [ax.get_legend_handles_labels() for ax in fig.axes]
lines, labels = [sum(lol, []) for lol in zip(*lines_labels)]
fig.legend(lines, labels)
plt.show()
```
%% Output
%% Cell type:code id: tags:
```
transformed_gaussian = moyal_dist2.cdf(samples)
uniform_dist = stats.uniform()
x_space = np.linspace(0,1,500)
y = uniform_dist.pdf(x_space)
fig, ax = plt.subplots(nrows=1, ncols=1)
sns.histplot(transformed_gaussian,bins = 50, stat='density', cumulative=False)
ax.plot(x_space, y, color='black')
plt.show()
```
%% Output
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment