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. Categories take only the identity basis (the defaults).
- 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(bins)Per-axis masses of the components' factors in the intervals of
bins(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(bins)(bins.K, C)sparse masses \(A_{qk} = \int_{B_q} \psi_k\,du\) of the components in the cells \(B_q\) ofbins(\(A\) whenbinsare the reporting bins).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(self.grid): the components' masses in the quadrature cells (cached).True when the components are the bins themselves (order 0, resolution 1).
True for the plain bins themselves: the identity with no finer quadrature cells (order 0, resolution 1, oversample 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(bins)[source]¶
Per-axis masses of the components’ factors in the intervals of
bins(no mask).On unmasked bins
masses()is their Kronecker product, so separable inputs can be projected one axis at a time.- Parameters:
- binsBins
A grid covering the components’ range with the same measures: the reporting bins, the components, the quadrature grid or a refinement of them.
- property grid_masses¶
masses(self.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).
- property is_plain¶
True for the plain bins themselves: the identity with no finer quadrature cells (order 0, resolution 1, oversample 1).
- masses(bins)[source]¶
(bins.K, C)sparse masses \(A_{qk} = \int_{B_q} \psi_k\,du\) of the components in the cells \(B_q\) ofbins(\(A\) whenbinsare the reporting bins).binsmust 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 ofbins.- Parameters:
- binsBins
A grid covering the components’ range with the same measures.
(C, K): each component’s mass in each reporting bin (rows sum to one; cached).