I have an array of 1024x1024 values between 0 and 1 and I want to divide them into bins of size 0.05 (with first bin centered at 0, second centered at 0.05 ecc...) to compute the PDF for my data set. I'm having problems with calculating the number of data in each bin. I've tried using np.histogram but I get an array for counts that has a different size than my actual number of bins.
I've also tried to calculate the PDF with a for loop but I don't think I'm using a correct approach to that as well, I would appreciate any suggestions that may help.
My code at the moment looks something like this:
bins = np.arange(-0.025, 1.05, .05)
bin_width = bins[1]-bins[0]
num_bins = 22
counts, bin_edges = np.histogram(Flux, bins=bins,
range=(-0.025, bin_width*num_bins), density=False)
PDF = counts / (np.sum(counts)*Delta_F) #Delta_F = 0.05 is a normalisation factor
Any help would be really much appreciated, thank you. :)