I am not sure if this is the right place to post this, if not please kindly guide me to the right place. Thanks
By accident I found a small error on this page:
In the code example, the line
centers = 0.5 * (bin_edges + np.roll(bin_edges, 1))[:-1]
should actually be one of the following two:
centers = 0.5 * (bin_edges + np.roll(bin_edges, -1))[:-1] #or centers = 0.5 * (bin_edges + np.roll(bin_edges, 1))[1:]
Explanation: bin_edges contains the edges of the bins. It is a linspace, which is basically a range(a,b,c), for instance [0,1,2,3,4]. The centers of the bars corresponding to the bins should be the means of two adjacent values, in this example [0.5, 1.5, 2.5, 3.5]. However, the expression in the current code gives [2.0, 0.5, 1.5, 2.5], because the “direction of np.roll” and the “side of trimming” do not align. This is why either of my corrections works.
Interestingly, this is why we get the “lonely” upper green block in the output plot which is not present when inspecting the corresponding numpy array in binned_data_sets: it actually belongs at the bottom.
What steps can I take to further help getting this fixed?