So, I tried to create the CUM shown in Fig. 2. I am not sure if it is correct, so I would appreciate it if you could point out any mistakes.
#Declaration
from scipy.stats import norm
import numpy as np
import matplotlib.pyplot as plt
#Create data
np.random.seed(19680803)
mu = 200
sigma = 3
x = np.random.normal(mu, sigma, size=100)
#Assign the inverse of the cumulative distribution function to x
norm_arr = list()
for no in range(1,len(x)+1):
norm_arr.append(norm.ppf((no)/(len(x)+1))-norm.ppf(1/(len(x)+1)))
norm_arr=norm_arr/max(norm_arr)#Normalization
x.sort()#Sort x in ascending order
#Change y-axis display
scale =[]
list_axis =[0.0001,0.001,0.01,0.05,0.1,0.2,0.3,0.5,0.7,0.8,0.9,0.95,0.99,0.999,0.9999]
for no in list_axis:
scale.append(norm.ppf(no)-norm.ppf(0.0001))
scale=scale/max(scale)
#drawing
fig, ax = plt.subplots(figsize=(8, 4))
linestyles = '-'
ax.grid(True)
ax.legend(loc='right')
ax.set_title('Cumulative step histograms')
ax.set_xlabel('data')
ax.set_ylabel('Percentage')
plt.yticks(scale,list_axis)
ax.plot(x,norm_arr,label='linear',marker='o',markersize=1.0,linewidth=0.1,linestyle=linestyles)
plt.show()
When executed, the above Figure 2 will be output as it is.
Recommended Posts