Reference / binference.Measure
binference.Measure¶
- class binference.Measure(name, forward, inverse, key, table=None)[source]¶
A strictly increasing map
u = T(z)of one bin axis.Build one with
linear(),log(),transform()(a function and its inverse),density()(a positive densityg(z), whose cumulative integral is the map) ortabulated(). Strings"linear"and"log"are accepted wherever a measure is.Methods
__init__(name, forward, inverse, key[, table])coerce(measure)A
Measurefrom a measure or one of the names"linear"and"log".density(g, lo, hi[, n])The map whose derivative is the positive density
gon[lo, hi].forward(z)u = T(z).inverse(u)z = T^{-1}(u).linear()u = z: flat within bins in the bin coordinate itself.log()u = log z(z > 0): flat within bins in the logarithm.log_jacobian(z)log dT/dz: the log of the within-bin population density inz, up to a constant.tabulated(z, u[, name])A piecewise-linear map through the points
(z, u), both strictly increasing.transform(forward, inverse[, name])A user map
u = forward(z)with its inverse; both take and return arrays.Attributes
nameWhether this is one of the built-in measures
"linear"and"log".- classmethod coerce(measure)[source]¶
A
Measurefrom a measure or one of the names"linear"and"log".- Parameters:
- measureMeasure or {“linear”, “log”}
A measure or its name.
- classmethod density(g, lo, hi, n=4097)[source]¶
The map whose derivative is the positive density
gon[lo, hi].T(z) = integral of g from lo to z, computed by the trapezoidal rule onnpoints and interpolated linearly, as is its inverse.- Parameters:
- gcallable
Positive density, evaluated on an array of
z.- lo, hifloat
Range of
zthe map covers.- nint, optional
Points of the trapezoidal rule that tabulates the map.
- property is_named¶
Whether this is one of the built-in measures
"linear"and"log".
- log_jacobian(z)[source]¶
log dT/dz: the log of the within-bin population density inz, up to a constant.Exact for linear, log and tabulated measures; a central difference for
transform().- Parameters:
- zarray_like
Values of the bin coordinate.