# import libraries
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as sc
import seaborn as sns
# generate different distributions
sample_size = 10000
standard_norm = np.random.normal(size=sample_size)
cauchy_dist = sc.cauchy.rvs(loc=1, scale=10, size=sample_size)
logistic_dist = np.random.logistic(size=sample_size)
uniform_dist = np.random.uniform(size= sample_size)
beta_dist = np.random.beta(a=1, b=1, size=sample_size)
# Normal Distribution
fig, ax = plt.subplots(1, 2, figsize=(12, 7))
sns.histplot(standard_norm,kde=True, color ='blue',ax=ax[0])
sc.ppcc_plot(standard_norm, -5,5, plot=ax[1])
shape_param_normal = sc.ppcc_max(standard_norm)
ax[1].vlines(shape_param_normal,0,1, colors='red')
print("shape parameter of normal distribution is ", shape_param_normal)
# Cauchy Distribution
fig, ax = plt.subplots(1, 2, figsize=(12, 7))
sns.histplot(cauchy_dist, color ='blue',ax=ax[0])
ax[0].set_xlim(-40,40)
sc.ppcc_plot(cauchy_dist, -5,5, plot=ax[1])
shape_param_cauchy = sc.ppcc_max(cauchy_dist)
ax[1].vlines(shape_param_cauchy,0,1, colors='red')
print('shape parameter of cauchy distribution is ',shape_param_cauchy)
# Logistic Distribution
fig, ax = plt.subplots(1, 2, figsize=(12, 7))
sns.histplot(logistic_dist, color ='blue',ax=ax[0])
sc.ppcc_plot(logistic_dist, -5,5, plot=ax[1])
shape_param_logistic = sc.ppcc_max(logistic_dist)
ax[1].vlines(shape_param_logistic,0,1, colors='red')
print("shape parameter of logistic is ",shape_param_logistic)
# Uniform Distribution
fig, ax = plt.subplots(1, 2, figsize=(12, 7))
sns.histplot(uniform_dist, color ='green',ax=ax[0])
sc.ppcc_plot(uniform_dist, -5,5, plot=ax[1])
shape_para_uniform =sc.ppcc_max(uniform_dist)
ax[1].vlines(shape_para_uniform,0,1, colors='red')
print("shape parameter of uniform distribution is ",shape_para_uniform)
# Beta Distribution
fig, ax = plt.subplots(1, 2, figsize=(12, 7))
sns.histplot(beta_dist, color ='blue',ax=ax[0])
sc.ppcc_plot(beta_dist, -5,5, plot=ax[1])
shape_para_beta =sc.ppcc_max(beta_dist)
ax[1].vlines(shape_para_beta,0,1, colors='red')
print("shape parameter of beta distribution is :",shape_para_beta)