Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

sns.distplot fit

from scipy import stats

ax = sns.distplot(e_t_hat, bins=20, kde=False, fit=stats.norm);
plt.title('Distribution of Cointegrating Spread for Brent and Gasoil')

# Get the fitted parameters used by sns
(mu, sigma) = stats.norm.fit(e_t_hat)
print "mu={0}, sigma={1}".format(mu, sigma)

# Legend and labels 
plt.legend(["normal dist. fit ($mu=${0:.2g}, $sigma=${1:.2f})".format(mu, sigma)])
plt.ylabel('Frequency')

# Cross-check this is indeed the case - should be overlaid over black curve
x_dummy = np.linspace(stats.norm.ppf(0.01), stats.norm.ppf(0.99), 100)
ax.plot(x_dummy, stats.norm.pdf(x_dummy, mu, sigma))
plt.legend(["normal dist. fit ($mu=${0:.2g}, $sigma=${1:.2f})".format(mu, sigma),
           "cross-check"])
Comment

PREVIOUS NEXT
Code Example
Python :: specify dtype when creating array 
Python :: Programmatically determining programming languages based on file extensions in python 
Python :: Distace between two object on a sky map in degress using Ra and Dec 
Python :: discord.py find channel by id 
Python :: python library automatic sort 
Python :: dtype cannot be bool python 
Python :: how to make a dashboard with data representation using python free dash 
Python :: Recursively find the factorial of a natural number. 
Python :: how to have framer read json timestamps 
Python :: decimal to ascii python 
Python :: fforeveer loop python 
Python :: how to create list python 
Python :: To obtain the latest released version of statsmodels using pip: 
Python :: what does 0 for in array mean python 
Python :: autoscrapper import 
Python :: python code to fetch all the files with txt extension from a folder 
Python :: python how to geather and spread using pandas 
Python :: del no of elements in lis 
Python :: python read text file to list 
Python :: for loop pattern in python stack overflow 
Python :: python code checker and corrector 
Python :: wait_for_message definition 
Python :: optimal alpha jupyter 
Python :: drawmolecule rdkit 
Python :: 2D array questions python 
Python :: selenium python login instagram 
Python :: python inline web server 
Python :: how to run a seaborn plot on pycharm 
Python :: Python downsampling 
Python :: pandas ta quick start example 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =