binny.binning package#
Bin-edge construction, binning schemes, and assignment models.
- binny.binning.apply_response_matrix(bins: Mapping[int, NDArray[float64]], matrix: NDArray[float64]) dict[int, NDArray[float64]]#
Applies a bin-response matrix to a set of tomographic bin distributions.
Treats the input bins as a stacked array with shape
(n_bins, ...)and returns the mixed binsobs = M @ true. The response matrix is expected to be column-stochastic and compatible with the number of bins and array shapes.- Parameters:
bins – Mapping from bin index to bin distribution arrays. Must contain exactly keys
0..n_bins-1and all arrays must share the same shape.matrix – Response matrix of shape
(n_bins, n_bins).
- Returns:
Dict mapping observed bin index to the mixed bin distribution.
- Raises:
ValueError – If keys/shapes are inconsistent or the matrix is invalid.
- binny.binning.available_binning_schemes() tuple[str, ...]#
Return registered binning scheme names and aliases.
- binny.binning.build_bins(z: NDArray[float64], nz: NDArray[float64], edges: NDArray[float64], assignment: Callable[[NDArray[float64], NDArray[float64]], NDArray[float64]], *, selection_kind: Literal['probability', 'weight'] = 'probability', normalize_bins: bool = False, norm_method: Literal['trapezoid', 'simpson'] = 'trapezoid', return_integrals: bool = False) dict[int, NDArray[float64]] | tuple[dict[int, NDArray[float64]], dict[int, float], float]#
Build tomographic bins using a selection function.
- Parameters:
z – Parent redshift grid.
nz – Parent redshift distribution.
edges – Bin edges in the selection coordinate.
assignment – Function returning selections of shape
(n_bins, n_z).selection_kind – Whether selections are probabilities in
[0, 1]or non-negative weights.normalize_bins – Whether to normalize each bin.
norm_method – Integration method for normalization and population integrals.
return_integrals – Whether to return raw bin integrals and the parent integral.
- Returns:
Dictionary of bin distributions, optionally accompanied by bin integrals and the parent integral.
- Raises:
ValueError – If the selection type, shape, or values are invalid.
- binny.binning.build_specz_response_matrix(n_bins: int, *, catastrophic_frac: Sequence[float] | float = 0.0, leakage_model: Literal['uniform', 'neighbor', 'gaussian'] = 'neighbor', leakage_sigma: Sequence[float] | float = 1.0, response_matrix: NDArray[float64] | None = None) NDArray[float64]#
Constructs a bin-to-bin response matrix for catastrophic reassignment.
Builds a column-stochastic matrix
Mwith entriesM[i, j] = P(i_obs|j_true)that describes reassignment of a fraction of objects in each true bin to other observed bins. If an explicitresponse_matrixis provided, it is validated and returned directly.- Parameters:
n_bins – Number of tomographic bins.
catastrophic_frac – Per-bin catastrophic fraction(s) in [0, 1].
leakage_model – Redistribution rule for the catastrophic fraction.
leakage_sigma – Width parameter for Gaussian leakage in bin-index space.
response_matrix – Optional explicit response matrix overriding the model.
- Returns:
A float array of shape
(n_bins, n_bins)that is column-stochastic.- Raises:
ValueError – If inputs are invalid or the resulting matrix fails validation.
- binny.binning.chebyshev_edges(x_min: float, x_max: float, n_bins: int) ndarray#
Construct bin boundaries using Chebyshev-Lobatto nodes.
Bin boundaries are generated using
binny.axes.grids.chebyshev_grid().The boundaries are distributed symmetrically and concentrate near both endpoints of the interval. This produces narrower bins near the boundaries and wider bins around the interval midpoint.
- Parameters:
x_min – Lower endpoint of the binning interval.
x_max – Upper endpoint, greater than
x_min.n_bins – Number of bins, at least one.
- Returns:
One-dimensional array of
n_bins + 1strictly increasing bin boundaries, including both endpoints.- Raises:
ValueError – If the interval or number of bins is invalid.
- binny.binning.deterministic_assignment(z: NDArray[float64], edges: NDArray[float64], *, completeness: Sequence[float] | float = 1.0, response_matrix: NDArray[float64] | None = None) NDArray[float64]#
Return deterministic bin selections with optional mixing.
- Parameters:
z – Grid of the binning coordinate.
edges – Bin edges in the same coordinate.
completeness – Scalar or per-bin completeness.
response_matrix – Optional response matrix mapping true bins to observed bins.
- Returns:
Selection array with shape
(n_bins, n_z).
- binny.binning.equal_information_edges(x: Any, info_density: Any, n_bins: int) ndarray#
Return bin edges with equal integrated information per bin.
This is the same construction as
equal_number_edges(), but the supplied weights represent an information density rather than counts. Each bin contains the same integral ofinfo_densityoverx.- Parameters:
x – 1D axis values (must be strictly increasing).
info_density – 1D information density defined on
x.n_bins – Number of bins.
- Returns:
1D array of bin edges with shape
(n_bins + 1,).- Raises:
ValueError – If inputs are invalid or the total integrated information is non-positive.
- binny.binning.equal_number_edges(x: Any, weights: Any, n_bins: int) ndarray#
Returns bin edges with equal integrated weight per bin.
This constructs edges along
xsuch that each bin encloses the same integrated weight overx. Whenweightsrepresent galaxy counts or number density, this yields equal-number (equipopulated) bins.- Parameters:
x – 1D axis values (must be strictly increasing).
weights – 1D weights defined on
x(e.g. counts, number density).n_bins – Number of bins.
- Returns:
1D array of bin edges with shape
(n_bins + 1,).- Raises:
ValueError – If inputs are not 1D, have mismatched shapes, contain non-finite values, are not strictly increasing in
x, or if the total integrated weight is non-positive.
- binny.binning.equidistant_chi_edges(z: Any, chi: Any, n_bins: int) ndarray#
Returns bin edges uniform in comoving distance, expressed in
z.Requires
chi(z)is monotonic andzandchiare matched 1D arrays. Useful for cosmological applications where uniform spacing in comoving distance is desired.- Parameters:
z – 1D array of redshift values.
chi – 1D array of comoving distance values corresponding to
z.n_bins – Number of bins.
- Returns:
Array of bin edges in redshift of shape (n_bins + 1,), uniform in comoving distance.
- Raises:
ValueError – If
chiis not strictly increasing.
- binny.binning.equidistant_edges(x_min: float, x_max: float, n_bins: int) ndarray#
Returns uniformly spaced bin edges between
x_minandx_max.This method includes both endpoints. Works for any 1D axis: redshift, ell, k, etc. Useful for linear scales.
- Parameters:
x_min – Minimum value of the axis.
x_max – Maximum value of the axis.
n_bins – Number of bins.
- Returns:
Array of bin edges of shape (n_bins + 1,), uniformly spaced.
- binny.binning.generalized_tomographic_edges(axis: NDArray[float64], density: NDArray[float64], n_bins: int, *, alpha: float = 0.0, beta: float = 0.0, comoving_distance: Any | None = None, derivative_method: Literal['analytic', 'numerical'] = 'analytic') NDArray[float64]#
Construct generalized tomographic bin edges.
Bin edges are chosen to contain equal integrated weight, where
\[w(x) = \rho(x)^\alpha \left(\frac{\mathrm{d}\chi}{\mathrm{d}x}\right)^\beta.\]Here
xis the sampling axis,rho(x)its density, andchi(x)a monotonically increasing distance coordinate.- Special cases:
alpha=beta=0: Uniform spacing along the axis.alpha=1, beta=0: Equal integrated density.alpha=0, beta=1: Uniform spacing in distance.
- Parameters:
axis – Strictly increasing one-dimensional sampling axis.
density – Non-negative density evaluated on
axis.n_bins – Number of bins.
alpha – Exponent applied to the density.
beta – Exponent applied to the distance derivative.
comoving_distance – Increasing distance values evaluated on
axis. Required whenbetais nonzero.derivative_method –
"analytic"differentiates the cubic spline interpolant directly."numerical"uses DerivKit to estimate its derivative.
- Returns:
One-dimensional array of
n_bins + 1bin edges.- Raises:
ValueError – If inputs or computed weights are invalid.
- binny.binning.geometric_edges(x_min: float, x_max: float, n_bins: int) ndarray#
Returns geometrically spaced bin edges between
x_minandx_max.Geometric spacing means the ratio between successive edges is constant, i.e.
edges[k+1] / edges[k]is the same for allk. The returned edges include both endpoints.Notes
Geometric spacing is the multiplicative analogue of linear spacing. It is effectively the same as “log-spaced edges” (equal spacing in
log(x)), just expressed in ratio form (vianp.geomspace) rather than via a chosen log base (vianp.logspace).- Parameters:
x_min – Lower endpoint of the axis (must be > 0).
x_max – Upper endpoint of the axis (must be > 0 and > x_min).
n_bins – Number of bins.
- Returns:
Array of bin edges with shape
(n_bins + 1,).
- binny.binning.get_binning_scheme(name: str) Callable[[...], NDArray[float64]]#
Retrieve a registered bin-edge generation function.
- binny.binning.load_binning_recipe(path: str) list[dict[str, Any]]#
Load a mixed-binning recipe from a YAML file.
Expected YAML structure:
name: "y10_mixed_scheme" n_bins: 5 segments: - method: "eq" # alias for equidistant n_bins: 3 params: x_min: 0.0 x_max: 1.0 - method: "equal_number" n_bins: 2
paramsis optional; any keys in params are passed through to mixed_edges. Arrays like x, weights, z, chi are NOT stored in YAML; they are provided at runtime tomixed_edges.
- binny.binning.log_edges(x_min: float, x_max: float, n_bins: int) ndarray#
Returns logarithmically spaced bin edges between
x_minandx_max.The returned edges are equally spaced in
log10(x)and include both endpoints.Notes
The edges are equally spaced in
log10(x)(vianp.logspace). For positive endpoints, this produces the same spacing as geometric spacing (constant ratio between successive edges), up to floating-point rounding.- Parameters:
x_min – Lower endpoint of the axis (must be > 0).
x_max – Upper endpoint of the axis (must be > 0 and > x_min).
n_bins – Number of bins.
- Returns:
Array of bin edges with shape
(n_bins + 1,).
- binny.binning.mixed_edges(segments: Sequence[Any], *, total_n_bins: int | None = None, atol: float = 1e-12) ndarray#
Combine adjacent sets of bin boundaries into one array.
Each segment contains an independently constructed, strictly increasing array of boundaries. Adjacent segments must share a common endpoint. The shared boundary is included only once in the combined result.
This function does not construct boundaries or interpret binning schemes. Any edge-construction method can be used to generate the input segments.
- Parameters:
segments – Ordered sequence of one-dimensional arrays of bin boundaries. Each array must contain at least two values.
total_n_bins – Optional expected number of bins across all segments. If provided, it must match the combined result.
atol – Absolute tolerance used to compare adjacent segment endpoints. Must be finite and nonnegative.
- Returns:
One-dimensional float64 array of strictly increasing bin boundaries. Its length is the total number of bins plus one.
- Raises:
ValueError – If no segments are supplied, a segment contains invalid boundaries, adjacent segments do not share an endpoint, or the total number of bins is inconsistent.
- binny.binning.mixed_edges_from_segments(segments: Sequence[Mapping[str, Any]], *, axis: Any, density: Any, selection_axis: Any | None = None, selection_density: Any | None = None, info_density: Any | None = None, equal_number_axis: Any | None = None, equal_number_weights: Any | None = None, norm_method: Literal['trapezoid', 'simpson'] = 'trapezoid', normalize_equal_number_weights: bool = True) ndarray#
Construct bin boundaries from adjacent, independently defined segments.
Each segment specifies a coordinate interval, a registered binning scheme, and the number of bins to construct within that interval.
Every segment is resolved through the same scheme registry used for ordinary binning. The resulting boundaries are combined using
binny.axes.mixed_edges.mixed_edges().Density-dependent schemes use the primary distribution unless an independent selection distribution is provided. Equal-number segments may also use explicitly supplied independent population weights.
Adjacent segments must share a boundary. The shared boundary is included only once in the final result.
- Parameters:
segments – Ordered segment specifications containing
scheme,n_bins, interval boundaries, and optionalparams.axis – Strictly increasing primary sampling coordinates.
density – Nonnegative primary density sampled on
axis.selection_axis – Optional independent sampling coordinates for density-dependent mixed segments. Requires
selection_density.selection_density – Density sampled on
selection_axis. If omitted, the primary distribution is used.info_density – Optional information-density samples evaluated on the selected sampling axis.
equal_number_axis – Optional independent coordinates for equal-number binning. Requires
equal_number_weights.equal_number_weights – Population weights sampled on
equal_number_axis.norm_method – Integration method used when normalizing equal-number weights.
normalize_equal_number_weights – Whether to normalize equal-number weights before constructing boundaries.
- Returns:
Strictly increasing array of combined bin boundaries, with length equal to the total number of bins plus one.
- Raises:
ValueError – If the sampling arrays, segment specifications, scheme parameters, or combined boundaries are invalid.
- binny.binning.photoz_assignment(z: NDArray[float64], edges: NDArray[float64], *, scatter_scale: Sequence[float] | float = 0.0, mean_offset: Sequence[float] | float = 0.0, mean_scale: Sequence[float] | float = 1.0, outlier_frac: Sequence[float] | float = 0.0, outlier_scatter_scale: Sequence[float] | float | None = None, outlier_mean_offset: Sequence[float] | float = 0.0, outlier_mean_scale: Sequence[float] | float = 1.0) NDArray[float64]#
Return photo-z bin-assignment probabilities.
Model parameters may be specified globally or independently for each tomographic bin.
- Parameters:
z – True-redshift grid.
edges – Bin edges in observed photo-z space.
scatter_scale – Core Gaussian scatter scale.
mean_offset – Core Gaussian mean offset.
mean_scale – Core Gaussian mean scale.
outlier_frac – Outlier mixture fraction.
outlier_scatter_scale – Outlier Gaussian scatter scale.
outlier_mean_offset – Outlier Gaussian mean offset.
outlier_mean_scale – Outlier Gaussian mean scale.
- Returns:
Selection probabilities with shape
(n_bins, n_z).
- binny.binning.photoz_assignment_probability(z: NDArray[float64], bin_min: float, bin_max: float, scatter_scale: float, mean_offset: float, *, mean_scale: float = 1.0, outlier_frac: float = 0.0, outlier_scatter_scale: float | None = None, outlier_mean_offset: float = 0.0, outlier_mean_scale: float = 1.0) NDArray[float64]#
Compute the probability of assignment to one photo-z bin.
- Parameters:
z – True-redshift grid.
bin_min – Lower observed photo-z edge.
bin_max – Upper observed photo-z edge.
scatter_scale – Core Gaussian scatter scale.
mean_offset – Core Gaussian mean offset.
mean_scale – Core Gaussian mean scale.
outlier_frac – Outlier mixture fraction.
outlier_scatter_scale – Outlier Gaussian scatter scale.
outlier_mean_offset – Outlier Gaussian mean offset.
outlier_mean_scale – Outlier Gaussian mean scale.
- Returns:
Bin-assignment probabilities evaluated on the true-z grid.
- Raises:
ValueError – If the photo-z parameters are invalid.
- binny.binning.power_edges(x_min: float, x_max: float, n_bins: int, *, power: float = 2.0) ndarray#
Construct power-law spaced bin boundaries.
Bin boundaries are generated using
binny.axes.grids.power_grid(). The spacing followsx = x_min + (x_max - x_min) * t**power,where
tis uniformly spaced between zero and one.Values of
powergreater than one concentrate boundaries nearx_min, while values below one concentrate them nearx_max. A value of one produces uniformly spaced boundaries.- Parameters:
x_min – Lower endpoint of the binning interval.
x_max – Upper endpoint, greater than
x_min.n_bins – Number of bins, at least one.
power – Positive stretching exponent.
- Returns:
One-dimensional array of
n_bins + 1strictly increasing bin boundaries, including both endpoints.- Raises:
ValueError – If the interval, number of bins, or stretching exponent is invalid.
- binny.binning.register_binning_scheme(name: str, *, aliases: tuple[str, ...] = ()) Callable[[Callable[[...], NDArray[float64]]], Callable[[...], NDArray[float64]]]#
Register a bin-edge generation function under one or more names.
- binny.binning.resolve_bin_edges(*, axis: NDArray[float64], density: NDArray[float64], bins: Mapping[str, Any], equal_number_axis: Any | None = None, equal_number_weights: Any | None = None, selection_axis: Any | None = None, selection_density: Any | None = None, norm_method: Literal['trapezoid', 'simpson'] = 'trapezoid', normalize_equal_number_weights: bool = True) NDArray[float64]#
Construct bin boundaries from a declarative binning specification.
Supports explicitly supplied boundaries, registered binning schemes, and combinations of different schemes over adjacent intervals.
The sampling coordinate may represent redshift, magnitude, mass, luminosity, or another numerical quantity.
Density-dependent schemes use the supplied density by default. Independent distributions can be provided for equal-number binning or mixed-segment selection without modifying the primary density.
- Parameters:
axis – Strictly increasing one-dimensional sampling coordinates.
density – Nonnegative density sampled on
axis. Normalization is not required.bins – Binning specification. Supported forms are
{"edges": [...]}for explicit boundaries,{"scheme": name, "n_bins": n, "range": (lo, hi), "params": {...}}for generated boundaries, and{"segments": [...]}for mixed binning.equal_number_axis – Optional independent coordinates for equal-number binning. Requires
equal_number_weights.equal_number_weights – Population weights sampled on
equal_number_axis.selection_axis – Optional independent coordinates for mixed binning. Requires
selection_density.selection_density – Density sampled on
selection_axis.norm_method – Integration method for normalizing equal-number weights, either
"trapezoid"or"simpson".normalize_equal_number_weights – Whether to normalize equal-number weights before constructing boundaries.
- Returns:
Finite, strictly increasing one-dimensional bin boundaries.
- Raises:
ValueError – If the sampling arrays, specification, scheme parameters, or resulting boundaries are invalid.
- binny.binning.segments_to_axes(segments: Sequence[Mapping[str, Any]]) list[dict[str, Any]]#
Convert mixed-segment specifications to generic axis descriptions.
Each segment specifies a registered binning scheme, a number of bins, and a coordinate interval. Generic
x_minandx_maxboundaries are preferred, while legacyz_minandz_maxkeys remain supported.The returned specifications use the same numerical coordinate convention regardless of the physical meaning of the axis.
- Parameters:
segments – Ordered segment mappings containing
scheme,n_bins, and interval boundaries. Optional scheme parameters may be supplied throughparams.- Returns:
List of segment dictionaries containing
method,n_bins, andparamswith generic interval boundaries.- Raises:
ValueError – If a segment is missing a required field, has invalid boundaries, or contains an incomplete interval.
- binny.binning.sinh_edges(x_min: float, x_max: float, n_bins: int, *, strength: float = 3.0, concentration: Literal['midpoint', 'endpoints'] = 'midpoint') ndarray#
Construct sinh-stretched bin boundaries.
Bin boundaries are generated using
binny.axes.grids.sinh_grid().The
concentrationparameter controls where boundaries accumulate:"midpoint"concentrates boundaries near the interval midpoint, producing narrower central bins."endpoints"concentrates boundaries near both endpoints, producing narrower outer bins.
Larger
strengthvalues increase the concentration of boundaries. Settingstrength=0produces uniformly spaced boundaries for either concentration mode.- Parameters:
x_min – Lower endpoint of the binning interval.
x_max – Upper endpoint, greater than
x_min.n_bins – Number of bins, at least one.
strength – Nonnegative stretching parameter. Defaults to 3.0.
concentration – Boundary concentration mode, either
"midpoint"or"endpoints". Defaults to"midpoint".
- Returns:
One-dimensional array of
n_bins + 1strictly increasing bin boundaries, including both endpoints.- Raises:
ValueError – If the interval, number of bins, stretching strength, or concentration mode is invalid.
- binny.binning.specz_assignment(z: NDArray[float64], edges: NDArray[float64], *, completeness: Sequence[float] | float = 1.0, catastrophic_frac: Sequence[float] | float = 0.0, leakage_model: Literal['uniform', 'neighbor', 'gaussian'] = 'neighbor', leakage_sigma: Sequence[float] | float = 1.0, response_matrix: NDArray[float64] | None = None, specz_scatter: Sequence[float] | float | None = None, specz_scatter_model: Literal['sigma0_plus_sigma1_1pz'] = 'sigma0_plus_sigma1_1pz', sigma0: float = 0.0, sigma1: float = 0.0) NDArray[float64]#
Returns spectroscopic-redshift selection probabilities for each observed bin.
Constructs true-redshift top-hat selection functions with optional per-bin completeness factors and applies the combined catastrophic reassignment and Gaussian measurement-scatter response matrix.
The resulting selection probabilities are evaluated on the supplied true-redshift grid and are independent of the parent redshift distribution.
- Parameters:
z – True-redshift grid.
edges – True-redshift bin edges.
completeness – Per-bin selection completeness.
catastrophic_frac – Per-bin catastrophic reassignment fraction.
leakage_model – Catastrophic reassignment prescription.
leakage_sigma – Gaussian leakage width in bin-index space.
response_matrix – Optional explicit catastrophic response matrix.
specz_scatter – Optional spectroscopic measurement scatter.
specz_scatter_model – Scatter parameterization.
sigma0 – Constant scatter component.
sigma1 – Redshift-dependent scatter component.
- Returns:
Selection probabilities with shape
(n_bins, n_z).- Raises:
ValueError – If completeness, response matrix, or scatter settings are invalid.
- binny.binning.specz_gaussian_response_matrix(*, z_arr: NDArray[float64], bin_edges: NDArray[float64], specz_scatter: Sequence[float] | float | None, model: Literal['sigma0_plus_sigma1_1pz'] = 'sigma0_plus_sigma1_1pz', sigma0: float = 0.0, sigma1: float = 0.0) NDArray[float64]#
Builds a Gaussian measurement-scatter response matrix for spec-z binning.
Constructs a column-stochastic matrix that maps true bins to observed bins under a Gaussian measurement model.
Response probabilities are averaged continuously over each true-bin interval, assuming uniform weighting in true redshift. The resulting matrix is independent of the sampling resolution and spacing of the redshift grid.
The scatter scale may be provided explicitly as a scalar or per-bin sequence, or derived from the redshift-dependent parameterization
sigma(z) = sigma0 + sigma1 * (1 + z).Numerical integration is performed over a dimensionless coordinate within each true-bin interval. Additional integration points near the bin boundaries improve resolution of narrow Gaussian scatter.
Columns are normalized to conserve the population within the modeled tomographic bins. Probability outside the modeled redshift range is therefore excluded through column renormalization rather than treated as a loss of objects.
- Parameters:
z_arr – True-redshift grid. Retained as an input for consistency with the spectroscopic binning interface. The response calculation does not depend on the grid sampling.
bin_edges – True-redshift bin edges defining true and observed bins.
specz_scatter – Optional scalar or per-bin constant scatter scale.
model – Scatter parameterization used when specz_scatter is None. The supported model is
"sigma0_plus_sigma1_1pz".sigma0 – Additive scatter component.
sigma1 – Redshift-dependent scatter component.
- Returns:
A column-stochastic float array of shape
(n_bins, n_bins).- Raises:
ValueError – If bin edges or scatter settings are invalid, or if the resulting response matrix cannot be normalized or validated.
- binny.binning.specz_selection_in_bin(z: NDArray[float64], bin_min: float, bin_max: float, completeness: float = 1.0, *, inclusive_right: bool = False) NDArray[float64]#
Evaluate a deterministic selection window.
- Parameters:
z – Redshift or other selection-coordinate grid.
bin_min – Lower bin edge.
bin_max – Upper bin edge.
completeness – Selection completeness in [0, 1].
inclusive_right – Whether to include the upper edge.
- Returns:
Selection weights evaluated on the input grid.
- Raises:
ValueError – If completeness is outside [0, 1].
- binny.binning.true_redshift_distribution(z: NDArray[float64], nz: NDArray[float64], bin_min: float, bin_max: float, scatter_scale: float, mean_offset: float, *, mean_scale: float = 1.0, outlier_frac: float = 0.0, outlier_scatter_scale: float | None = None, outlier_mean_offset: float = 0.0, outlier_mean_scale: float = 1.0) NDArray[float64]#
Computes the true-redshift distribution for a single photo-z bin.
The photo-z-selected true-redshift distribution is
n_bin(z) = n(z) * P(bin | z), wheren(z)is the parent distribution andP(bin | z)` is the probability that an object at true redshift ``zfalls into the photo-z bin. The probability is modeled with a Gaussian core photo-z relation, with an optional Gaussian outlier component controlled by outlier_frac and the corresponding outlier parameters.- Parameters:
z – True-redshift grid.
nz – Parent distribution evaluated on
z.bin_min – Lower photo-z edge for the bin.
bin_max – Upper photo-z edge for the bin.
scatter_scale – Core photo-z scatter scale.
mean_offset – Core photo-z mean offset.
mean_scale – Core photo-z mean scale.
outlier_frac – Outlier mixture fraction.
outlier_scatter_scale – Outlier scatter scale.
outlier_mean_offset – Outlier mean offset.
outlier_mean_scale – Outlier mean scale.
- Returns:
Photo-z-selected true-redshift distribution evaluated on
z.- Raises:
ValueError – If
outlier_fracis outside [0, 1], if required outlier parameters are missing, or if any active scale parameter is invalid.
- binny.binning.validate_bin_edges(bin_edges: Any, *, require_within: tuple[float, float] | None = None) NDArray[float64]#
Validate a sequence of one-dimensional bin boundaries.
The boundaries must be finite, strictly increasing, and define at least one bin. An optional interval can constrain their range.
- Parameters:
bin_edges – Candidate bin boundaries.
require_within – Optional inclusive interval containing all boundaries, specified as
(minimum, maximum).
- Returns:
Validated one-dimensional float64 array.
- Raises:
ValueError – If the boundaries are not one-dimensional, contain fewer than two values, are non-finite, are not strictly increasing, or lie outside the required interval.