# -*- coding: utf-8 -*-
"""
Created on Fri Nov 19 15:25:31 2021

@author: Sim
"""
import scipy.stats as st
import statsmodels.api as sm
import matplotlib.pyplot as plt
import numpy as np


fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2,2, figsize=(10, 6))

x = st.distributions.norm.rvs(size=300)
ax1.hist(x, edgecolor='white')
ax1.set_title('N(0,1)')
sm.qqplot(x, dist=st.norm, line='q', ax=ax2)

x = st.distributions.norm.rvs(size=300, loc=10, scale=4)
ax3.hist(x,  edgecolor='white')
ax3.set_title('N(10,2^2)')
sm.qqplot(x, dist=st.norm, line='q', ax=ax4)

plt.show()

fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2,2, figsize=(10, 6))
x = st.distributions.uniform.rvs(size=300, loc=0, scale=np.sqrt(3))
# var(U(-3,3)) = 3
ax1.hist(x, edgecolor='white')
ax1.set_title('U(-3,3)')
sm.qqplot(x, dist=st.norm, line='q', ax=ax2)

x = st.distributions.cauchy.rvs(size=300, scale=4)
ax3.hist(x,  edgecolor='white')
ax3.set_title('Cauchy')
sm.qqplot(x, dist=st.norm, line='q', ax=ax4)


plt.show()

fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2,2, figsize=(10, 6))
x = st.distributions.chi2.rvs(size=300, df=3)
ax1.hist(x, edgecolor='white')
ax1.set_title('Chi square (3)')
sm.qqplot(x, dist=st.norm, line='q', ax=ax2)

x = st.distributions.chi2.rvs(size=300, df=3)
x = np.max(x)-x
ax3.hist(x,  edgecolor='white')
ax3.set_title('-Chi square (3)')
sm.qqplot(x, dist=st.norm, line='q', ax=ax4)


