Skip to content

Commit efa8cde

Browse files
committed
Add fix() and unfix() functions for parameter fixing and unfixing
1 parent 82e1e4a commit efa8cde

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/abstractprobprog.jl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,46 @@ should hold for generative models `m` and arbitrary `obs`.
6262
"""
6363
function condition end
6464

65+
"""
66+
fix(model, params)
67+
68+
Fix the values of parameters specified in `params` within the probabilistic model `model`.
69+
This operation is equivalent to treating the fixed parameters as being drawn from a point mass
70+
distribution centered at the values specified in `params`.
71+
72+
Conceptually, this is similar to Pearl's do-operator in causal inference, where we intervene
73+
on variables by setting them to specific values, effectively cutting off their dependencies
74+
on their usual causes in the model.
75+
76+
The invariant
77+
78+
```
79+
m == unfix(fix(m, params))
80+
```
81+
82+
should hold for any model `m` and parameters `params`.
83+
"""
84+
function fix end
85+
86+
87+
"""
88+
unfix(model)
89+
90+
Remove any fixed parameters from the model `model`, returning a new model without the fixed parameters.
91+
92+
This function reverses the effect of `fix()` by removing parameter constraints that were previously set.
93+
It returns a new model where all previously fixed parameters are allowed to vary according to their
94+
original distributions in the model.
95+
96+
The invariant
97+
98+
```
99+
m == unfix(fix(m, params))
100+
```
101+
102+
should hold for any model `m` and parameters `params`.
103+
"""
104+
function unfix end
65105

66106
"""
67107
rand([rng=Random.default_rng()], [T=NamedTuple], model::AbstractProbabilisticProgram) -> T

0 commit comments

Comments
 (0)