# Combining multiple traces

**URL:** <https://discourse.pymc.io/t/combining-multiple-traces/4017>\
**Category:** version agnostic\
**Tags:** arviz\
**Created:** [October 24, 2019, 1:45pm UTC](https://discourse.pymc.io/t/combining-multiple-traces/4017 "2019-10-24T13:45:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorian821](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/dorian821/32/2090_2.png) [@dorian821](https://discourse.pymc.io/u/dorian821)\
**Post date:** [October 24, 2019, 1:45pm UTC](https://discourse.pymc.io/t/combining-multiple-traces/4017/1 "2019-10-24T13:45:11Z")

</div>

Hi all,

I’m training on a relatively large dataset, 20000+ data points, and I’ve noticed that sampling time significantly improves if I can bring the dataset down around ~1000 points. So naturally I’m looking for ways to batch the sampling. I have two questions to this end:

1. Assuming that the distributions of the training data in each of the batches are sufficiently similar, what are any theoretical issues sampling in this way?

2. On the practical side of things, I would like to combine the traces, as in append/concatenate them together successively, and I don’t see any builtin methods for doing this. Is there a recommended or easy way to do this? It seems as if assignment is prohibited.

`trace['coeff',:] = np.concatenate((trace['coeff',:],trace1['coeff',:]))`  
---------------------------------------------------------------------------  
TypeError Traceback (most recent call last)  
 in   
----\> 1 trace[‘coeff’,:] = np.concatenate((trace[‘coeff’,:],trace[‘coeff’,:]))

```
TypeError: 'MultiTrace' object does not support item assignment
```

---

<div class="post-metadata">

**Author:** ![j\_catulo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/j_catulo/32/4892_2.png) [@j\_catulo](https://discourse.pymc.io/u/j_catulo)\
**Post date:** [May 17, 2022, 4:00pm UTC](https://discourse.pymc.io/t/combining-multiple-traces/4017/2 "2022-05-17T16:00:51Z")

</div>

Hi!

It has been some time since you asked this question, but I have the same doubts. Is it possible to combine several traces?

---

<div class="post-metadata">

**Author:** ![OriolAbril](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/oriolabril/32/2497_2.png) [@OriolAbril](https://discourse.pymc.io/u/OriolAbril)\
**Post date:** [May 17, 2022, 5:40pm UTC](https://discourse.pymc.io/t/combining-multiple-traces/4017/3 "2022-05-17T17:40:23Z")

</div>

yes, having the traces as InferenceData (you can use the `return_inferencedata` argument of `pm.sample`) use [arviz.concat](https://python.arviz.org/en/latest/api/generated/arviz.concat.html#arviz.concat) to combine multiple traces.
