繁体   English   中英

初学者问题:未绘制正态分布的 Python 散点图

[英]Beginner question: Python scatter plot with normal distribution not plotting

我有我所计算出的随机的整数数组meanstd ,标准偏差。 接下来,我在这个(平均值,标准差)的正态分布内有一个随机数数组。

我现在想使用 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)

在此处输入图片说明

您可以做的最接近可视化一维输出分布的事情是在 x & y 相同的地方进行分散。 这样你就可以看到高概率区域的更多数据积累。 例如:

import numpy as np
import matplotlib.pyplot as plt

mean = 0    
std = 1 
sample_norm_distrib = np.random.normal(mean,std,7500)

plt.figure()
plt.scatter(sample_norm_distrib,sample_norm_distrib)

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM