# UserWarning: RNG Variable RandomGeneratorSharedVariable has multiple clients

**URL:** <https://discourse.pymc.io/t/userwarning-rng-variable-randomgeneratorsharedvariable-has-multiple-clients/15990>\
**Category:** General\
**Created:** [October 17, 2024, 2:39pm UTC](https://discourse.pymc.io/t/userwarning-rng-variable-randomgeneratorsharedvariable-has-multiple-clients/15990 "2024-10-17T14:39:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yamaguchi](https://avatars.discourse-cdn.com/v4/letter/y/c2a13f/32.png) [@Yamaguchi](https://discourse.pymc.io/u/Yamaguchi)\
**Post date:** [October 17, 2024, 2:39pm UTC](https://discourse.pymc.io/t/userwarning-rng-variable-randomgeneratorsharedvariable-has-multiple-clients/15990/1 "2024-10-17T14:39:19Z")

</div>

Hi all,

I ran the following code and got a UserWarning.  
Is there a solution to avoid this User Warning?

```python
import numpy as np
import pymc as pm
import pytensor
from pymc.pytensorf import collect_default_updates

with pm.Model() as model:
    t = pm.Beta("t", alpha=2, beta=1, shape=3)
    
    def loop(symbol, t):
        symbol_new = pm.Categorical.dist(t)
        return (symbol_new), collect_default_updates([symbol_new])
    
    symbol = np.array(0, dtype=int)
    results, updates = pytensor.scan(
        fn=loop,
        outputs_info=[symbol],
        non_sequences=[t],
        n_steps=10,
        strict=True
        )
    
    pm.Deterministic("final_symbol", results[-1])
    
    idata = pm.sample_prior_predictive(10)

```

```auto
UserWarning: RNG Variable RandomGeneratorSharedVariable(<Generator(PCG64) at 0x14F69B300>) has multiple clients. This is likely an inconsistent random graph.
  warnings.warn(
Sampling: [t]

```

---

<div class="post-metadata">

**Author:** ![daniel-saunders-phil](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/daniel-saunders-phil/32/5615_2.png) [@daniel-saunders-phil](https://discourse.pymc.io/u/daniel-saunders-phil)\
**Post date:** [October 19, 2024, 1:27am UTC](https://discourse.pymc.io/t/userwarning-rng-variable-randomgeneratorsharedvariable-has-multiple-clients/15990/2 "2024-10-19T01:27:41Z")

</div>

Hi Yamaguchi, could you say a little bit about why you want a scan function here? It doesn’t look like you are doing any recursive computation. The result of each loop doesn’t depend on the previous `symbol`. In that case, you can just specify you want 10 draws from a categorical distribution with something like:

```auto
with pm.Model():
    t = pm.Beta('t',alpha=2, beta=1, shape=3)
    symbol = pm.Categorical('symbol',t,shape=10)
    pm.Deterministic("final_symbol", symbol[-1])
    idata = pm.sample_prior_predictive(10)

```

If I was a bit more clear on your intentions, I think it would be easier to clean up the scan function.
