gpt4 book ai didi

python - 初学者问题: Python scatter plot with normal distribution not plotting

转载 作者:行者123 更新时间:2023-12-01 08:52:21 25 4
gpt4 key购买 nike

我有一个随机整数数组,我已为其计算了平均值std(标准差)。接下来,我有一个正态分布内的随机数数组(平均值,标准差)。

我现在想使用 matplotlib 绘制正态分布数组的散点图。你能帮忙吗?

代码:

random_array_a = np.random.randint(2,15,size=75)  #random array from [2,15) 
mean = np.mean(random_array_a)
std = np.std(random_array_a)
sample_norm_distrib = np.random.normal(mean,std,75)

散点图需要 x 和 y 轴...但是应该是什么?

最佳答案

我认为您可能想要的是正态分布的直方图:

import matplotlib.pyplot as plt
%matplotlib inline

plt.hist(sample_norm_distrib)

enter image description here

关于python - 初学者问题: Python scatter plot with normal distribution not plotting,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53029208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com