Collapse¶
CollapseHandler sums or integrates a conjugate parent out of the joint
(Bernardo and Smith, 1994). The parent adds nothing to the joint, and its child is scored at the run's
observation under the closed-form marginal that the pair's conjugacy gives. In a
Beta and Bernoulli model, for instance, the observations
are scored with the success probability integrated out, which removes that latent from the
inference problem.
collapse
¶
Collapse handler: integrate a conjugate parent out of the joint.
CollapseHandler takes parent-to-child site pairs. The parent is drawn
from its prior so the program downstream of it runs, but contributes
nothing to the joint; the child is answered with the run's observation
for it and scored under the closed-form marginal the pair's conjugacy
gives, with the parent integrated out. The joint the run accumulates is
therefore the marginal joint, exactly, for the identity-link pairs of
:mod:quivers.effects.conjugate. Each collapsed parent site is annotated
with metadata["collapse"] naming its child in every trace of the run.
CollapseHandler
¶
Bases: EffectHandler
Integrate conjugate parents out of the joint.
| PARAMETER | DESCRIPTION |
|---|---|
pairs
|
Parent site name to child site name.
TYPE:
|
Source code in src/quivers/effects/collapse.py
install
¶
install(run: RunContext) -> tuple[Installation, ...]
Install the collapsing handler of the random instance.
| PARAMETER | DESCRIPTION |
|---|---|
run
|
The run being prepared, whose observations supply each child's value.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Installation, ...]
|
The handler, which draws parents without scoring them and scores children under the pair's marginal. |
Source code in src/quivers/effects/collapse.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
collapse
¶
collapse(pairs: dict[str, str] | None = None) -> CollapseHandler
Return a CollapseHandler for the given parent-child pairs.
| PARAMETER | DESCRIPTION |
|---|---|
pairs
|
Parent site name to child site name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CollapseHandler
|
The handler. |
Source code in src/quivers/effects/collapse.py
Cited sources¶
José M. Bernardo and Adrian F. M. Smith. Bayesian Theory. Wiley, 1994. URL: https://onlinelibrary.wiley.com/doi/book/10.1002/9780470316870, doi:10.1002/9780470316870.