# Distributional do-operator?

**URL:** <https://discourse.pymc.io/t/distributional-do-operator/12915>\
**Category:** v5\
**Tags:** modeling\
**Created:** [September 15, 2023, 7:59pm UTC](https://discourse.pymc.io/t/distributional-do-operator/12915 "2023-09-15T19:59:32Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ricardoV94](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ricardov94/32/5775_2.png) [@ricardoV94](https://discourse.pymc.io/u/ricardoV94)\
**Post date:** [September 16, 2023, 1:46am UTC](https://discourse.pymc.io/t/distributional-do-operator/12915/2 "2023-09-16T01:46:50Z")

</div>

It’s already possible just not described. You can pass an arbitrary expression that depends on existing model variables:

```python
with pm.Model() as m:
  x = pm.Normal("x")
  y = pm.Normal("y", x)

do_m = pm.do(m, {x: pm.math.switch(x > 0, x, 0})

```

You can also introduce new variables but they can’t be “named” model variables. You need to use dist.

```python
with pm.Model() as m:
  x = pm.Normal("x")
  y = pm.Normal("y", x)

do_m = pm.do(m, {x: pm.Beta.dist()})

```

You can also add the variable to the model and then use it in the do intervention if for instance you want to sample it

```python
with pm.Model() as m:
  x = pm.Normal("x")
  y = pm.Normal("y", x)

 
with m:
  new_x = pm.Beta("new_x")

do_m = pm.do(m, {x: new_x})

```

---

_[View the full topic](https://discourse.pymc.io/t/distributional-do-operator/12915)._
