Skip to content

Commit

Permalink
Add fix() and unfix() functions for parameter fixing and unfixing
Browse files Browse the repository at this point in the history
  • Loading branch information
sunxd3 committed Oct 25, 2024
1 parent 82e1e4a commit efa8cde
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/abstractprobprog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,46 @@ should hold for generative models `m` and arbitrary `obs`.
"""
function condition end

"""
fix(model, params)
Fix the values of parameters specified in `params` within the probabilistic model `model`.
This operation is equivalent to treating the fixed parameters as being drawn from a point mass
distribution centered at the values specified in `params`.
Conceptually, this is similar to Pearl's do-operator in causal inference, where we intervene
on variables by setting them to specific values, effectively cutting off their dependencies
on their usual causes in the model.
The invariant
```
m == unfix(fix(m, params))
```
should hold for any model `m` and parameters `params`.
"""
function fix end


"""
unfix(model)
Remove any fixed parameters from the model `model`, returning a new model without the fixed parameters.
This function reverses the effect of `fix()` by removing parameter constraints that were previously set.
It returns a new model where all previously fixed parameters are allowed to vary according to their
original distributions in the model.
The invariant
```
m == unfix(fix(m, params))
```
should hold for any model `m` and parameters `params`.
"""
function unfix end

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

0 comments on commit efa8cde

Please sign in to comment.