# Compute frequencies with pgfplots

On the page 480 of this doc http://pgfplots.sourceforge.net/pgfplots.pdf of the pgfplots package, it talks about of how we can construct histograms from data, and says that "Then, it creates the N + 1 coordinates (xi; yi)... where yi=bincount([xi; xi+1))"... The points (xi; yi) determines the rectangles of the histogram.

So my question is :

What's the procedure used to define the intervals [xi; xi+1), and after compute the frequencies of each one of these intervals ?

More precisely, on the first example given, how this command

``````\addplot+[hist={bins=3}]
table[row sep=\\,y index=0] {
data\\
1\\ 2\\ 1\\ 5\\ 4\\ 10\\
7\\ 10\\ 9\\ 8\\ 9\\ 9\\
};
``````

determines the intervals 1-4,4-7,7-10 with the respective frequencies 3,2,7?

I searched for this command "bincount", and it seems that it's a python command, which I'm not a user, so I'm searching for a solution using only Latex.

To be more precise, I want an output in form of tabular: for the example cited, it will be in this form:

• @FaouziBellalouna: What do you mean by "algorithm"? It's really straightforward: PGFPlots finds the min and max of all values provided in the data, that's the range. It then splits that range into a number of bins, provided by the `bins` parameter. These bins have equal widths, so the width of a single bin is just range/number_of_bins. It then goes through all data points, checks into which bin that point falls, and increases the count of that bin by 1. The code can be found at sourceforge.net/p/pgfplots/code/ci/master/tree/tex/generic/…. – Jake May 11 '16 at 12:26