如何解决测试以比较python中的多维分布
我有以下数据集:
import random
import pandas as pd
A = pd.DataFrame({'x':[random.uniform(0,1) for i in range(0,100)],'y':[random.uniform(0,100)]})
B = pd.DataFrame({'x':[random.uniform(0,100)]})
从这两个数据集中,我可以生成以下图
import matplotlib.pyplot as plt
import scipy.stats as st
def plot_2d_kde(df):
# Extract x and y
x = df['x']
y = df['y']
# Define the borders
deltaX = (max(x) - min(x))/10
deltaY = (max(y) - min(y))/10
xmin = min(x) - deltaX
xmax = max(x) + deltaX
ymin = min(y) - deltaY
ymax = max(y) + deltaY
# Create meshgrid
xx,yy = np.mgrid[xmin:xmax:100j,ymin:ymax:100j]
# We will fit a gaussian kernel using the scipy’s gaussian_kde method
positions = np.vstack([xx.ravel(),yy.ravel()])
values = np.vstack([x,y])
kernel = st.gaussian_kde(values)
f = np.reshape(kernel(positions).T,xx.shape)
fig = plt.figure(figsize=(13,7))
ax = plt.axes(projection='3d')
surf = ax.plot_surface(xx,yy,f,rstride=1,cstride=1,cmap='coolwarm',edgecolor='none')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('PDF')
ax.set_title('Surface plot of Gaussian 2D KDE')
fig.colorbar(surf,shrink=0.5,aspect=5) # add color bar indicating the PDF
ax.view_init(60,35)
plot_2d_kde(A)
plot_2d_kde(B)
是否有一种方法可以测试A
的多维PDF与python中B
的多维PDF是否不同?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。