import numpy as np
import pandas as pd
from scipy import stats,integrate
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(color_codes=True)
np.random.seed(sum(map(ord,"distribution")))
x=np.random.normal(size=100)
sns.distplot(x,kde=True)
<matplotlib.axes._subplots.AxesSubplot at 0x1f61c2f6cf8>

sns.distplot(x,kde=True,bins=20)
<matplotlib.axes._subplots.AxesSubplot at 0x1f61c2f64a8>

sns.distplot(x,kde=False,bins=20,rug=20)
<matplotlib.axes._subplots.AxesSubplot at 0x1f61cf39400>

''''有什么用呢?待定系数法求概率密度函数~
核密度估计的步骤:
* 每一个观测附近用一个正态分布曲线近似
* 叠加所有观测的正太分布曲线
* 归一化
File "<ipython-input-7-675869d1e240>", line 3
有什么用呢?待定系数法求概率密度函数~
^
SyntaxError: invalid character in identifier
sns.kdeplot(data=x)
<matplotlib.axes._subplots.AxesSubplot at 0x1f61c8b05c0>

sns.kdeplot(x,c="green",shade=True)
sns.kdeplot(x,bw=.2,label="bw:0.2",c="red")
sns.kdeplot(x,bw=2,label="bw:2",c="purple")
plt.legend()
D:\ano\lib\site-packages\matplotlib\cbook\__init__.py:2400: UserWarning: Saw kwargs ['c', 'color'] which are all aliases for 'color'. Kept value from 'color'
seen=seen, canon=canonical, used=seen[-1]))
<matplotlib.legend.Legend at 0x1f61d0d37f0>

x=np.random.gamma(6,size=200)
sns.distplot(x,kde=False,fit=stats.gamma,axlabel="XX",color="red",label="yy")
<matplotlib.axes._subplots.AxesSubplot at 0x1f61e312ba8>

mean,cov=[0,1],[(1,.5),(.5,1)]
data=np.random.multivariate_normal(mean,cov,200)
df=pd.DataFrame(data,columns=["x","y"])
sns.jointplot(x="x",y="y",data=df)
<seaborn.axisgrid.JointGrid at 0x1f61e806fd0>

x,y=np.random.multivariate_normal(mean,cov,1000).T
with sns.axes_style("ticks"):
sns.jointplot(x=x,y=y,kind="hex")

sns.jointplot(x="x",y="y",data=df,kind="kde")
<seaborn.axisgrid.JointGrid at 0x1f61e93b3c8>

f,ax=plt.subplots(figsize=(6,6))
sns.kdeplot(df.x,df.y,ax=ax)
sns.rugplot(df.x,df.y,color="g",ax=ax)
sns.rugplot(df.y,vertical=True,ax=ax)

f,ax=plt.subplots(figsize=(6,6))
cmap=sns.cubehelix_palette(as_cmap=True,dark=1,light=0)
sns.kdeplot(df.x,df.y,cmap=cmap,n_levels=60,shade=True)
<matplotlib.axes._subplots.AxesSubplot at 0x1f61e68d908>
