Accounting for sample selection in Bayesian analyses
  Astronomers are often confronted with funky populations and distributions of
objects: brighter objects are more likely to be detected; targets are selected
based on colour cuts; imperfect classification yields impure samples. Failing
to account for these effects leads to biased analyses. In this paper we present
a simple overview of a Bayesian consideration of sample selection, giving
solutions to both analytically tractable and intractable models. This is
accomplished via a combination of analytic approximations and Monte Carlo
integration, in which dataset simulation is efficiently used to correct for
issues in the observed dataset. This methodology is also applicable for data
truncation, such as requiring densities to be strictly positive. Toy models are
included for demonstration, along with discussions of numerical considerations
and how to optimise for implementation. We provide sample code to demonstrate
the techniques. The methods in this paper should be widely applicable in fields
beyond astronomy, wherever sample selection effects occur.
