首页 > 编程知识 正文

单变量分析模型,单变量分析方法

时间:2023-05-04 20:35:45 阅读:193805 作者:4954

seaborn提供5中主题风格:

darkgrid

whitegrid

dark

white

ticks

 

 

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from scipy import stats, integrate
import pandas as pd

 

sns.set(color_codes=True)               #内置颜色集

利用np.random.seed()函数设置相同的seed,每次生成的随机数相同。

如果不设置seed,则每次会生成不同的随机数

np.random.seed(sum(map(ord, distributions)))

 

x = np.random.normal(size=100)          #设置100个wsdbl数(正态分布)

sns.distplot(x, kde=True)                       #为True就有下面的曲线

 

sns.distplot(x, bins=20, kde=True)                         #bins为柱形图的数量

x = np.random.gamma(6, size=200)         #设置伽马图,元素个数为200个

sns.distplot(x, kde=False, fit=stats.gamma)

mean, cov = [0,1], [(1, .5), (.5, 1)]            #均值和协方差

data = np.random.multivariate_normal(mean, cov, 200)    #产生200个数据

df = pd.DataFrame(data, columns=["x", "y"])

sns.jointplot(x="x", y="y", data=df)

x,y = np.random.multivariate_normal(mean, cov, 1000).T

with sns.axes_style("dark"):

          sns.jointplot(x=x, y=y, kind="hex", color=k)

 

 

 

 

 

 

 

 

 

 

 

 

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。