bartz.testing.ScaledBernoulli¶
- class bartz.testing.ScaledBernoulli(pi)[source]¶
Bernoulli(
pi) scales, rescaled toE[s ** 2] = 1.The scale is
1/sqrt(pi)with probabilitypiand 0 otherwise. This is hard variable selection: a fractionpiof the predictors is active, the others are exactly inert. With continuous coefficient families, the scales act as the indicators of a spike-and-slab prior.- classmethod from_peff(peff, p)[source]¶
Set the scale dispersion from an effective number of active predictors.
peffis the participation ratio of the squared scales,\[p_{\mathrm{eff}} = \frac{(\sum_j s_j^2)^2}{\sum_j s_j^4} \;\xrightarrow{\,p \to \infty\,}\; \frac p{E[s^4]},\]an effective count that ranges in
[1, p]:pwhen all predictors are equally important (Constant), shrinking towards 1 as the importance concentrates on fewer predictors. The deterministic large-plimitp / E[s ** 4]is the analytic target inverted here; forScaledBernoulliit equals the expected number of nonzero scales exactly.- Parameters:
- Returns:
ScaleDistr– A member of the family withfourth_momentequal top / peff.