0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PythonでCDFのグラフを書く

Posted at

CDFはNumpyのcumsum関数を使うと書ける
numpy.cumsum — NumPy v1.20 Manual

import numpy as np
from scipy.stats import norm
import matplotlib.pyplot as plt

# 正規分布の作成
x = np.linspace(-10,10,100)
y = norm.pdf(x,0,1)

# CDFの作成
CDF = np.cumsum(y) / np.sum(y) # sumで割ることで0~1に収まる

# グラフの描画
fig = plt.figure(figsize=(6,4))
ax = plt.subplot(111)
ax.plot(x,y,label='PDF')
ax.plot(x,CDF,label='CDF')
plt.legend(loc='upper left',fontsize=12, fancybox=False,edgecolor='black')
fig.show()

CDF.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?