Reference / binference.Basis
binference.Basis¶
- class binference.Basis(bins, order=0, resolution=1, oversample=None)[source]¶
Components of the population model over reporting bins.
- Parameters:
- binsBins
The reporting bins (a grid, not categories).
- order{0, 1}
B-spline order of the components: 0 flat in
uon each cell, 1 linear (hats). See the module documentation.- resolutionint or sequence of int
Components per reporting bin along each axis (default 1).
- oversampleint, optional
Quadrature cells per component and axis. They integrate likelihoods and selection functions against the components (default 1 for order 0, where the integrals are exact; for order 1, 8 in 1-D, 4 in 2-D and 2 in more dimensions).
- Attributes:
- binsBins
The reporting bins.
- componentsBins
The component cells (the bins refined
resolutiontimes); priors are placed on these.- gridBins
The quadrature cells (the components refined
oversampletimes).- grid_to_binsndarray (grid.K,)
The reporting bin of each quadrature cell.
- matrixsparse array (K, C)
\(A_{jk}\), the mass of component k in reporting bin j; each column sums to one.
Examples
>>> import binference >>> basis = binference.Basis(binference.Bins.linear(0, 3, 10), order=1) >>> basis.K, basis.C (10, 10)
Methods
__init__(bins[, order, resolution, oversample])axis_masses(grid)Per-axis masses of the components' factors in
grid's intervals (no mask).height(k, d, u)Height (at most one) along axis
dof the unnormalised componentskatu;uhask's shape, or one more trailing axis of points per component.masses(grid)(grid.K, C)sparse masses \(M_{qk} = \int_{B_q} \phi_k\,du\).support(k)(lo, hi)inuof the supports of componentsk, each(n, ndim).to_bins(weights)Map component weights
(..., C)to reporting-bin fractions(..., K).Attributes
Number of components.
Number of reporting bins.
masses(grid): the components' masses in the quadrature cells (cached).True when the components are the bins themselves (order 0, resolution 1).
(C, K): each component's mass in each reporting bin (rows sum to one; cached).- property C¶
Number of components.
- property K¶
Number of reporting bins.
- axis_masses(grid)[source]¶
Per-axis masses of the components’ factors in
grid’s intervals (no mask).On an unmasked grid
masses()is their Kronecker product, so separable inputs can be projected one axis at a time.- Parameters:
- gridBins
Grid covering the components’ range with the same measures.
- property grid_masses¶
masses(grid): the components’ masses in the quadrature cells (cached).
- height(k, d, u)[source]¶
Height (at most one) along axis
dof the unnormalised componentskatu;uhask’s shape, or one more trailing axis of points per component.A component’s shape is the product of its heights over the axes (one for flat components inside their cell).
- Parameters:
- kint or array_like of int
Component indices.
- dint
Axis.
- uarray_like
Points in
ualong axisd.
- property is_identity¶
True when the components are the bins themselves (order 0, resolution 1).
- masses(grid)[source]¶
(grid.K, C)sparse masses \(M_{qk} = \int_{B_q} \phi_k\,du\).gridmust cover the components’ range with the same measures (the reporting bins, the components or any refinement of them). Each column sums to one over the active cells ofgrid.- Parameters:
- gridBins
Grid covering the components’ range with the same measures.
(C, K): each component’s mass in each reporting bin (rows sum to one; cached).