uvex_transients.simulation.rates.estimate_yield#

uvex_transients.simulation.rates.estimate_yield(events: QTable, mask=None, confidence: float | None = None, transient_types: list[str] | None = None) → QTable[source]#

Estimate the expected number of real UVEX events in a selection of events, per transient type.

For each type, with \(n\) the number of events generated, \(k\) the number of selected rows and \(\mu_0\) the intrinsic number of events the survey could see, the fraction is \(\hat\epsilon=k/n\) and the expected number of real events is \(\hat\lambda=\mu_0\hat\epsilon\). Two uncertainties are reported separately: a Clopper-Pearson interval on \(k/n\) for the finite Monte Carlo sample (binom), and the type’s rate-normalization factors applied to \(\hat\lambda\) (rate).

Parameters:
  • events (QTable) – A table from ~uvex_transients.simulation.core.SurveySimulator.run_event_summary_action, or a row slice of one. Its meta must hold n_pre_cut (\(n\)), expected_events (\(\mu_0\)) and rate_ci, each keyed by transient type.

  • mask (array-like of bool, optional) – True for the rows to count, one per row of events. The default counts every row, which gives the efficiency of the cuts the table was built from.

  • confidence (float, optional) – Confidence level of the Clopper-Pearson interval. The default is config["simulation.default_confidence"].

  • transient_types (list of str, optional) – Report only these types. The default is every type generated, including any with no selected rows.

Returns:

One row per transient type, with columns transient_type, n_pre_cut, n_selected, fraction, fraction_lower, fraction_upper, intrinsic_events, expected_events, expected_events_binom_lower/_upper and expected_events_rate_lower/_upper. Types are not summed, since that would mix independent Monte Carlo errors with a shared rate uncertainty.

Return type:

QTable

Raises:

ValueError – If events lacks a required meta entry, mask is not a boolean array with one entry per row, a requested type was not generated, or a type has more selected rows than generated events.

Examples

estimate_yield(
    events
)  # the cuts the table was built from, per type

delay = (
    events["t_first_det"]
    - events["t_last_nondet"]
).to_value("hr")
estimate_yield(
    events, mask=delay <= 6
)  # first detected within 6 h of a non-detection