Q-Q plot
Statsmodels and manual coding
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_excel('Normal data.xlsx', sheet_name = 'Normal')
# df = pd.read_excel('Normal data.xlsx', sheet_name = 'Skewed')
# df = pd.read_excel('Normal data.xlsx', sheet_name = 'Bimodal')
# df
fig, ax = plt.subplots(figsize=(10, 8))
plt.hist(sorted(df.data), bins=40)
m = df.data.mean()
st = df.data.std()
# Standardize the data
for i in range(0,df.shape[0],1):
df.data.iloc[i] = (df.data.iloc[i]-m)/st
dfn = pd.read_excel('Normal data.xlsx', sheet_name = 'Standard')
q = []
j=0
for i in range(1,dfn.shape[0]+1,1):
j=i/df.shape[0]
q_temp = np.quantile(dfn['data'], j)
q.append(q_temp)
fig, ax = plt.subplots(figsize=(10, 8))
plt.hist(sorted(dfn.data), bins=40)
fig, ax = plt.subplots(figsize=(10, 8))
plt.plot(q,sorted(df.data),'o')
plt.xlabel("Quantile of standard normal distribution")
plt.ylabel("Sample Z-score")
plt.grid()
import statsmodels.api as sm
sm.qqplot(df.data, line ='45')