uvex_transients.phase_space.sampling.base#
The core of the sampling infrastructure: the sampler contract, its products and the stopping rule.
This module knows nothing about surveys. The samplers that simulate one are in
core and breakout.
Products: the quantities of a map, each of which owns how it is made.
A fitted map is of one thing, the success fraction \(f\) over the space. Everything else a figure or a table shows
is made from it and from the point: the fraction times a volume-time is an expected yield, the fraction times a rate on
top of that is an expected count, and a redshift limit does not involve the fraction at all. A
Product is one of those quantities. It is a callable that takes the
points and the map”s Estimate of the success fraction there and
returns the columns it creates, so it is free to combine them however the quantity needs. Nothing else has to know what
a volume-time or a rate is.
A sampler supplies its own products (products), which are
built around whatever machinery of the sampler they need. Scale and
Weighted cover the two common cases, a quantity of the point alone
and the success fraction times one.
The sampler: how many detections in n tries at a point of the space.
A phase-space map asks one question of the world, again and again: at this point x, of n independent tries, how
many succeed? A Sampler answers it, and nothing else. It does not
decide how many tries to make (that is the
StoppingRule) and it does not know about the Gaussian process that
models the answers (that is the map). What it does know is the physics of one kind of experiment:
Sampler.spaceis theSpacethe experiment is over, with its axes and their default ranges;Sampler.drawmakes n tries at a point and returns the number of successes;Sampler.productsare the quantities of its map beyond the success fraction (a redshift limit, a recovered volume-time), each aProductthat owns how it is made.
Every sampler has a kind, a name under which it is registered, so that a file can record which sampler made it and
get_sampler() can find the class again without importing it by path. A
subclass registers itself by naming its kind in the class statement,
class MySampler(Sampler, kind="my_sampler"): ...
and an abstract intermediate class leaves it out.
Everything beyond those four members is an optional hook with a default, so that the code that consumes a sampler (the
experiment, the stages that write and draw a map, the CLI) never has to ask what kind it is:
Sampler.rate_products and
Sampler.table_meta extend the table of the map,
Sampler.describe titles its figure,
Sampler.draw_map draws it and
Sampler.annotate_map decorates it,
Sampler.HAS_OVERLAY and
Sampler.measure_overlay supply a population
to shade on it, and Sampler.from_run_config
builds the sampler from a run-config. A sampler that has something to say overrides the hook; one that does not inherits
an answer that says nothing. The default figure is of a plane, so a map over more than two axes is not drawn.
The stopping rule: how many tries a point gets.
A sampler makes however many tries it is asked for. How many to ask for is a question of statistics, not of physics: a
point where the success fraction is high needs few tries to pin it down, and one where it is small needs many, so a
point is sampled in chunks until it has enough successes or has used its budget.
StoppingRule is that rule, and it is a separate object because two
parties need it: the campaign applies it, and the map”s acquisition predicts from it the noise of a point it has not
measured yet.
Attributes
a product that carries one names them |
Functions
Return the kinds of every registered sampler. |
|
|
Return the registered sampler class of a kind. |
Classes
|
The map's estimate of the success fraction at points: a value with an interval. |
|
The result of sampling one point: k successes of n tries, and whatever else was worth recording. |
|
A quantity of the map, and how it is made from the points and the estimate of the success fraction. |
|
Answer "how many detections in n tries at a point?" for one kind of experiment. |
|
A quantity of the point alone, which does not involve the success fraction. |
|
Sample a point in chunks of tries until it has k_target successes or has used n_max tries. |
|
The success fraction times a quantity of the point, with its interval. |