u++の備忘録

べき分布の対数を取る(ヒストグラムで可視化)

はじめに

べき分布の対数を取ると、ヒストグラムの形がどのように変わるか見てみた。やってみた後に気付いたが、数式的に当たり前の結果。

github.com

Jupyter Notebook

# 参考:https://qiita.com/tibigame/items/fa746573fbaf4666bc33
import numpy as np
import scipy
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set(style="whitegrid")
# 指数分布
# 平均して10分に1度起こる現象の発生間隔
rand_exp_scale = 10.0
rand_exp_size = 10000
rand_exp = np.random.exponential(scale=rand_exp_scale, size=rand_exp_size)

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
plt.title('Histgram of np.random.exponential')
ax.set_ylabel('Frequency')
sns.distplot(rand_exp, kde=False, rug=False, bins=50)

f:id:upura:20180105090838p:plain

log_rand_exp = np.log(rand_exp )
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
plt.title('Histgram of Log(np.random.exponential)')
ax.set_ylabel('Frequency')
sns.distplot(log_rand_exp, kde=False, rug=False, bins=50)

f:id:upura:20180105091600p:plain

pareto = np.random.pareto(a=2.718281828, size=10000)

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.set_ylabel('freq')
sns.distplot(pareto, kde=False, rug=False, bins=50)

f:id:upura:20180105091644p:plain

#  パレート分布
log_pareto = np.log(pareto)

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.set_ylabel('freq')
sns.distplot(log_pareto, kde=False, rug=False, bins=50)

f:id:upura:20180105091716p:plain