I was just thinking how does plt.hist() draws the histogram as we only pass it 1 list , I tried to search on google but i couldn’t make ou;t anything ?
How does plt.hist() work?
Hello Anshu,
Just how the plot function will plot any list that is passed to it along the indexes in the list, for example, if you pass a list [0,2,4,6,8,10] then the plot function would directly make a y=2*x line on the graph.
That’s what must be happening here as well. The list elements which represent the accuracy/loss are being plotted against the number of epochs (which is nothing but the indexes of the list).
I hope this clears your doubt.
I am still having some difficulty in understanding how does plt.hist() works .
u=0
sigma=1
vals = u+sigma*np.random.randn(1000)
plt.hist(vals,50)
plt.show()
if i run above code i get the output as
In the normal distribution video , prateek bhaiya said that on the x-axis we have vals and on the y-axis we have probability i.e, the number of times a particular value occurs , i don’t see indexes being used ?
I was drawing an analogy between plt.plot function and plt.hist function. In the former also we pass only a list and line gets plotted. It draws a line between the values in the list and the indexes of the elements.
In the hist function, we pass it a list again and its job is to represent the data in form of a histogram. So, just as you quotes Bhaiya, the x-axis represents the range of values in which the entire data is present and the y-axis represents the number of points (the probability, in a way) corresponding to the values on the x-axis.
I hope you’re able to visualize it.