# Constraints in Pyro

Hello, I am working on creating a model to invert 36Cl data to recover seismic sequence for my Phd.
In short 36Cl is created in a the fault scarp and the concentration depend on the duration of exposure (time between earthquakes) and the exhumation due to earthquakes (slip).
So basically, my forward function takes as arguments two arrays : one for the duration and one for the slip.

My first question is there a command to tell pyro to construct a pooled array instead on defining multiple variables, stacking those into an array?
My second question : if it is possible to pool an array, is it possible to set a constraint on the sum of the element of the array? The sum of the element of the slip array cannot exceed the height of the fault scarp.
Coming from the geoscience field I am very new to mcmc techniques and ppl, so I apologize if my question is very naive and if I do not use the correct vocabulary.

Here is my current definition of my model :

``````def model(obs):

""" Ages are inversed"""

age1 = pyro.sample('age1', dist.Uniform(2, 30*1e3))
age2 = pyro.sample('age2', dist.Uniform(2, 30*1e3))
age3 = pyro.sample('age3', dist.Uniform(2, 30*1e3))
ages = torch.hstack((age1, age2, age3))
seismic_scenario['SR'] = 0.1
seismic_scenario['preexp'] = 150*1e3
slips = torch.tensor([200, 370, 450])
seismic_scenario['ages'] = ages
seismic_scenario['slips'] = slips

t = forward.mds_no_scale(seismic_scenario, scaling_factors)

return pyro.sample('obs', dist.Normal(t, 0.5), obs=obs)

""" usage MCMC """

kernel = NUTS(model)
mcmc = MCMC(kernel, warmup_steps=20, num_samples=60)

mcmc.run(obs=Data)
print(mcmc.diagnostics())
``````

Thanks for you help in advance !

Yes, Pyro supports batched distributions. More on it in this tutorial. In your case the easiest way to do it is to use `.expand` and `.to_event`:

``````ages = pyro.sample('ages', dist.Uniform(2, 30*1e3).expand([3]).to_event(1))
``````