Reference / binference.simulate.mock_1d

binference.simulate.mock_1d

binference.simulate.mock_1d(n_objects=2000, bins=None, *, density='bimodal', noise=(0.05, 0.2), interim=None, n_samples=0, selection=None, measured_range=None, outlier_fraction=0.0, rng=None)[source]

A 1-D mock catalogue with heteroscedastic Gaussian measurement errors.

Parameters:
n_objectsint

Number of observed objects (after selection).

binsBins, optional

Bins of the mock; None gives 30 equal bins on [0, 3].

densitystr, callable, or array_like (K,)

True population: a named density (“bimodal”, “gaussian”, “uniform”, “steep”), a callable density, or bin fractions (values then uniform within bins).

noisefloat or (lo, hi)

Measurement standard deviation, fixed or drawn uniformly per object.

interimstr, callable or array_like, optional

If given, also return per-object posteriors on the bins computed under this interim prior ("gaussian" gives a broad Gaussian), as mock.posteriors with masses mock.interim.

n_samplesint

If positive, also return n_samples posterior samples per object (under the interim prior, flat if not given) as mock.samples.

selectionarray_like (K,), optional

Per-bin detection probability depending on the true bin (selection on the truth): objects are thinned accordingly.

measured_range(lo, hi), optional

Selection on the measurement: only objects whose measured value lies in [lo, hi] are observed (either end may be None).

outlier_fractionfloat

Fraction of measurements replaced by uniform draws over the range (the likelihoods ignore this: a misspecification test).

rngint, Generator or None

Notes

The matching Selection is attached to mock.likelihoods: "on_truth" with selection, "on_measurement" with measured_range (the population-weighted bin average of the probability that the measured value passes, over the noise distribution), and Selection.combined() with both (DECISIONS #48).

With a named or callable density the true values follow that continuous density, whereas the histogram model assumes the population is flat within each bin. For coarse bins, measurement errors comparable to the bin width and many objects, this binning bias can exceed the statistical errors. Pass bin fractions (e.g. density=population(bins, "bimodal")) to draw values uniformly within bins, for which the model is exactly right.