# Concatenation of chains

**URL:** <https://discourse.julialang.org/t/concatenation-of-chains/102344>\
**Category:** New to Julia\
**Tags:** question, turing\
**Created:** [August 1, 2023, 8:33am UTC](https://discourse.julialang.org/t/concatenation-of-chains/102344 "2023-08-01T08:33:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sahil\_Khan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sahil_khan/32/47573_2.png) [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Post date:** [August 1, 2023, 8:33am UTC](https://discourse.julialang.org/t/concatenation-of-chains/102344/1 "2023-08-01T08:33:53Z")

</div>

Can we use cat to catenate chains one after another rather than alongside?

So in this given case i would like to have chains one after another as a single continuous chain which will make it 2000 rather than two.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/6/66a8f5b9eb6f65e44d0a4c24e5b7a40b9369ab91.png)

---

<div class="post-metadata">

**Author:** ![p-gw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/p-gw/32/210518_2.png) [@p-gw](https://discourse.julialang.org/u/p-gw)\
**Post date:** [August 1, 2023, 9:02am UTC](https://discourse.julialang.org/t/concatenation-of-chains/102344/2 "2023-08-01T09:02:50Z")

</div>

I’m not sure if it makes a lot of sense, but you can in principle construct a new `Chains` object like this:

```julia
using MCMCChains

chain = Chains(randn(2000, 10, 2)) # 2000 iterations, 10 parameters, 2 chains
size(chain) # (2000, 10, 2)

new_chain = Chains(Array(chain))
size(new_chain) # (4000, 10, 1)

```

---

<div class="post-metadata">

**Author:** ![Sahil\_Khan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sahil_khan/32/47573_2.png) [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Post date:** [August 1, 2023, 9:41am UTC](https://discourse.julialang.org/t/concatenation-of-chains/102344/3 "2023-08-01T09:41:03Z")

</div>

i managed to do what I wanted 🙂 here first chain is from 1:1000 and same was for second chain thats why I couldn’t catenate them in continuous manner. so I had change iteration range and then it worked.

And yeah its not same chain as above…but that doesn’t matter

```julia
chain_reloaded1 = setrange(chain_reloaded1, 1001:2000)

chainn = cat(chain_reloaded,chain_reloaded1;dims=1)

```

![image](https://global.discourse-cdn.com/julialang/original/3X/d/7/d7053cda14ae7ccee8b6d12ae8010105673b062e.png)
