BackgroundCountsPosterior#

class jinwu.background.BackgroundCountsPosterior(a_total: float, b: float, area_ratio: float)[source]#

Bases: object

背景区域计数后验(聚合到选择能段之后)。

基于 Gamma-Poisson 共轭:以 OFF 区域“计数率” λ_off ~ Gamma(a_total, b) (shape=a_total, rate=b),则: - OFF 区域在曝光 t 的后验预测 n_off ~ Poisson-Gamma 混合,等价于 NB(r=a_total, p=b/(b+t)); - ON 区域在曝光 t 的后验预测 n_on,bkg ~ NB(r=a_total, p=b/(b+area_ratio*t)),

其中 area_ratio=A_on/A_off。

我们通过 Gamma-Poisson 的层次采样实现采样(避免不同库对 NB 参数化差异)。

属性#

a_totalfloat

选择能段内所有能道的先验 shape 之和(更新后为后验 shape)。

bfloat

先验/后验的 rate 参数(单位:秒),通常为 t_ref + sum(t_obs_off)。

area_ratiofloat

A_on / A_off,用于把 OFF 计数率映射到 ON 背景计数率。

Methods Summary

expected_off(t)

expected_on(t)

sample_off(t[, size, rng])

采样 OFF 区域在曝光 t 的后验预测计数。

sample_on(t[, size, rng])

采样 ON 区域(仅背景)在曝光 t 的后验预测计数。

update_with_off_counts(n_off, t_off, *[, ...])

用额外的 OFF 观测(总计数与曝光)进行一次共轭更新。

update_with_on_bg_counts(n_on_bg, t_on_bg, *)

用额外的 ON 背景-only 观测进行更新(等效 OFF 曝光为 area_ratio*t_on_bg)。

Methods Documentation

expected_off(t: float) float[source]#
expected_on(t: float) float[source]#
sample_off(t: float, size: int = 1, rng: Generator | None = None) ndarray[source]#

采样 OFF 区域在曝光 t 的后验预测计数。

sample_on(t: float, size: int = 1, rng: Generator | None = None) ndarray[source]#

采样 ON 区域(仅背景)在曝光 t 的后验预测计数。

update_with_off_counts(n_off: float, t_off: float, *, inplace: bool = False) BackgroundCountsPosterior[source]#

用额外的 OFF 观测(总计数与曝光)进行一次共轭更新。

update_with_on_bg_counts(n_on_bg: float, t_on_bg: float, *, inplace: bool = False) BackgroundCountsPosterior[source]#

用额外的 ON 背景-only 观测进行更新(等效 OFF 曝光为 area_ratio*t_on_bg)。