Skip to content

Instantly share code, notes, and snippets.

@arimitramaiti
Last active October 8, 2020 13:07
Show Gist options
  • Save arimitramaiti/87c24c4842386561341b92cbebef5ee4 to your computer and use it in GitHub Desktop.
Save arimitramaiti/87c24c4842386561341b92cbebef5ee4 to your computer and use it in GitHub Desktop.
#Import basic modules
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
import scipy.stats as stats
import math
import statsmodels.api as sm
#Generate Series-1
np.random.seed(123)
mu, sigma = 0, 1
series1 = np.random.normal(mu, sigma, 10000)
#Generate Series-2
np.random.seed(32)
series2 = np.append(np.random.normal(0.9, 0.2, 5000), np.random.normal(0, 1, 5000))
##Create the grid
fig, axes = plt.subplots(2, 2, figsize=(12,8))
fig.subplots_adjust(top=0.7)
axes[0,0].plot(series1);
axes[0,0].set_title("Series-1")
axes[0,0].spines['top'].set_visible(False)
axes[0,0].set_xlabel('Time', fontsize=11, weight='bold')
axes[0,0].set_ylabel('Values', fontsize=11, weight='bold')
axes[0,0].axhline(y=0, color='black', linestyle='dashdot', linewidth=1)
sm.graphics.tsa.plot_acf(series1.squeeze(), lags=40, ax=axes[0,1])
axes[0,1].set_title("ACF-Series-1")
axes[0,1].set_xlabel('Lag', fontsize=11, weight='bold')
axes[0,1].set_ylabel('ACF', fontsize=11, weight='bold')
axes[1,0].plot(series2);
axes[1,0].set_title("Series-2")
axes[1,0].spines['top'].set_visible(False)
axes[1,0].set_xlabel('Time', fontsize=11, weight='bold')
axes[1,0].set_ylabel('Values', fontsize=11, weight='bold')
axes[1,0].axhline(y=0, color='black', linestyle='dashdot', linewidth=1)
sm.graphics.tsa.plot_acf(series2.squeeze(), lags=40, ax=axes[1,1])
axes[1,1].set_title("ACF-Series-2")
axes[1,1].set_xlabel('Lag', fontsize=11, weight='bold')
axes[1,1].set_ylabel('ACF', fontsize=11, weight='bold')
fig.tight_layout()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment