[英]How do I solve numpy.ndarray' object has no attribute 'histogram' on python
I want to randomly select numbers with the probability acording to the sum of 2 normal/gaussian distributions and make a histogram.我想随机 select 数字与概率根据 2 个正态/高斯分布的总和并制作直方图。
basicaly基本上
import numpy as np
u, vth = 0,1 # mean and standard deviation
v= np.random.normal(u, vth, 1000)+np.random.normal(-u, vth, 1000)
v.histogram()
However I get the error numpy.ndarray' object has no attribute 'histogram'.但是我收到错误 numpy.ndarray' object has no attribute 'histogram'。 Another problem is that this isn't normalized so my results shouldn't be right...
另一个问题是这没有标准化,所以我的结果不应该是正确的......
I think what you are looking for is to make a histogram plot of a normal distribution.我认为您正在寻找的是制作正态分布的直方图 plot。 Have you tried using matplotlib library's histogram function?
您是否尝试过使用 matplotlib 库的直方图 function? It can be done easily like so:
它可以像这样轻松完成:
import numpy as np
u, vth = 0,1 # mean and standard deviation
v= np.random.normal(u, vth, 1000)+np.random.normal(-u, vth, 1000)
import matplotlib.pyplot as plt
plt.hist(v)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.