# Binning¶

This page explains the mathematics behind the binning functionality found in
`bins`

. The binning functions are purely mathematical in nature though
they do have application in other parts of pyne that deal more directly physics
with physics.

## Pointwise Linear Collapse¶

The `pointwise_linear_collapse()`

function takes an array of pointwise
data that has the independent variable and collapses this into
groups as defined by the bin boundaries where
indexes . Both and must be monotonic and in the
same direction. Say that there are points in and .
Let index . Then for all points internal to a group, the
collapsed value is:

The term is the center (average) value of a linear interpolation between the two points. Therefore, is the -weighted average of over the entire group.

In the event that the line between and crosses either the lower or upper bin boundary (or both) then their values are adjusted via a linear interpolation to the value at the bin boundary.

For a lower boundary crossing, the following substitutions are made to the equation above:

For an upper boundary crossing: