Chi2fit.Statistics.make_histogram

You're seeing just the function make_histogram, go back to Chi2fit.Statistics module for more information.
Link to this function

make_histogram(list, binsize \\ 1.0, offset \\ 0.0)

View Source

Specs

make_histogram([number()], number(), number()) :: [
  {non_neg_integer(), pos_integer()}
]

Converts a list of numbers to frequency data.

The data is divided into bins of size binsize and the number of data points inside a bin are counted. A map is returned with the bin's index as a key and as value the number of data points in that bin.

The function returns a list of 2-tuples. Each tuple contains the index of the bin and the value of the count of the number of items in the bin. The index of the bins start at 1 in the following way:

  • [0..1) has index 1 (including 0 and excludes 1),
  • [1..2) has index 2,
  • etc.

When an offset is used, the bin starting from the offset, i.e. [offset..offset+1) gets index 1. Values less than the offset are gathered in a bin with index 0.

Examples

iex> make_histogram [1,2,3]
[{2, 1}, {3, 1}, {4, 1}]

iex> make_histogram [1,2,3], 1.0, 0
[{2, 1}, {3, 1}, {4, 1}]

iex> make_histogram [1,2,3,4,5,6,5,4,3,4,5,6,7,8,9]
[{2, 1}, {3, 1}, {4, 2}, {5, 3}, {6, 3}, {7, 2}, {8, 1}, {9, 1}, {10  , 1}]

iex> make_histogram [1,2,3,4,5,6,5,4,3,4,5,6,7,8,9], 3, 1.5
[{0, 1}, {1, 6}, {2, 6}, {3, 2}]

iex> make_histogram [0,0,0,1,3,4,3,2,6,7],1
[{1,3},{2,1},{3,1},{4,2},{5,1},{7,1},{8,1}]

iex> make_histogram [0,0,0,1,3,4,3,2,6,7],1,0.5
[{0,3},{1,1},{2,1},{3,2},{4,1},{6,1},{7,1}]