将阵列转换为分布的更简单方法?

2024-06-21 20:13:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个数组,vox_betas,它包含21600个浮点数(范围从~0到~2),当按数组、特征排序时,您可以看到数据有一个结构(参见第一张图片)

我希望有一个反映这种结构的数组——本质上我希望调用sns.distplot(),并使其生成与第一张图片相同的绘图。现在sns.distplot(vox_betas)描述了第二张图片,这不是我想要的

在第三幅图中,我可以通过创建数组dist来实现这一点,但是我实现这一点的方式很草率,甚至丢失了一些信息(我的代码如下)

您将如何将vox_Beta和功能转换为dist?有人有什么想法吗

plt.scatter(features,vox_betas)

enter image description here

sns.distplot(vox_betas)

enter image description here

dist=[]
for f in np.unique(features):
    dist = np.concatenate((dist,
                np.repeat(f,
                np.sum(
                [vox_betas[j]*10 for j in np.where(features==f)[0]]))))

sns.distplot(dist)

enter image description here


Tags: infor排序distnp图片特征数组