sns distplot fit

Solutions on MaxInterview for sns distplot fit by the best coders in the world

showing results for - "sns distplot fit"
Melvin
10 Jan 2018
1from scipy import stats
2
3ax = sns.distplot(e_t_hat, bins=20, kde=False, fit=stats.norm);
4plt.title('Distribution of Cointegrating Spread for Brent and Gasoil')
5
6# Get the fitted parameters used by sns
7(mu, sigma) = stats.norm.fit(e_t_hat)
8print "mu={0}, sigma={1}".format(mu, sigma)
9
10# Legend and labels 
11plt.legend(["normal dist. fit ($\mu=${0:.2g}, $\sigma=${1:.2f})".format(mu, sigma)])
12plt.ylabel('Frequency')
13
14# Cross-check this is indeed the case - should be overlaid over black curve
15x_dummy = np.linspace(stats.norm.ppf(0.01), stats.norm.ppf(0.99), 100)
16ax.plot(x_dummy, stats.norm.pdf(x_dummy, mu, sigma))
17plt.legend(["normal dist. fit ($\mu=${0:.2g}, $\sigma=${1:.2f})".format(mu, sigma),
18           "cross-check"])
19
similar questions
queries leading to this page
sns distplot fit