I want to plot a graph b/w a
on x-axis and probability on y-axis.
First I calculate probability using numpy.histogram command. n
gives me probability.
But the number of terms in n
depends on how many bins I choose.
If I choose 5 bins then there will be 5 terms when I print n
.
Using these probability value I can pick y-axis values.
But my goal is to plot a graph between a
vs probability, whereas in array a
there are 9 terms and in n
there are 5 terms.
So how I will convert probabilities of histogram into simple curve plot?
a=np.array([1,1,1,2,2,2,3,3,5])
n,bins = np.histogram(a,bins=5,density=True)
print(n)
plt.plot(?,n)
plt.xlabel("a")
plt.ylabel("probability")
如果我理解正确,那应该可以
plt.plot(bins, np.append(n[0], n))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.