I have an 1 dimensional array of values. I did plot a histogram of the data in python (using the hist function), and it turned out great. But now I want to plot the histogram with a log-log scale. So I thought I should bin the data myself in C++ and then plot it (the usual way) in python. But I'm a beginner in C++, so I was wondering if someone knows a simple way of explaining to me what to do.
So basicly - I have an array (size 1e8) which I want to divide into equally spaced logarithm (base 10) bins.
I'll post the header file with the code that creates the array itself:
(E_phot[i] is the array of values that should be binned)
since you are using a vector you can actually do most of the work here. I dunno what python's function does, but you can use sort on the vector of logs to order them and then iterate over it once to count how many per bucket. You could even write just the count file out (it will be tiny) .. that is the # of items in each bucket .... very easily, and you can plot that from anything (excel, python, maple/matlab, whatever). If python does all the work, you don't need this, but if you want to plot it in something else, it might be useful, and going from 1e8 values to 10 or 20 values or whatever makes dealing with the data a little easier. You can even do a sideways cheeze histogram by writing a file with like one * for every 10 or 100 values in a bucket in a text file, if you just want to LOOK at it once and get a sense of the data.