# Collecting the results from two processes

**URL:** https://discourse.julialang.org/t/collecting-the-results-from-two-processes/36342
**Category:** General Usage
**Tags:** parallel
**Created:** [March 22, 2020, 11:49am UTC](https://discourse.julialang.org/t/collecting-the-results-from-two-processes/36342 "2020-03-22T11:49:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![marouane1994](https://avatars.discourse-cdn.com/v4/letter/m/74df32/32.png) [@marouane1994](https://discourse.julialang.org/u/marouane1994)
#### Post date: [March 22, 2020, 11:49am UTC](https://discourse.julialang.org/t/collecting-the-results-from-two-processes/36342/1 "2020-03-22T11:49:41Z")

</div>

i want to know how can we collect two results from two workers that have different dimension fro example an mcmc problem and we save the results in an array the results and we’re using two workers `a=@spawn mcmc(arguments)` and `b=@spawn mcmc(arguments)` , how can we combine the two results using `fetch()` to clarify more suppose that the length of `fetch(a)=50` elements and the length of `fetch(b)=20` elements if we use the `+` we’ll get a dimension mismatch

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [March 22, 2020, 2:16pm UTC](https://discourse.julialang.org/t/collecting-the-results-from-two-processes/36342/2 "2020-03-22T14:16:40Z")

</div>

The simplest method would be to hcat the two arrays. The fastest for lots of simple types of Monte Carlo problems will often be to reduce them separately and combine them using a weighted average (or something similar depending on what your measurement is).

---

<div class="post-metadata">

### Author: ![marouane1994](https://avatars.discourse-cdn.com/v4/letter/m/74df32/32.png) [@marouane1994](https://discourse.julialang.org/u/marouane1994)
#### Post date: [March 23, 2020, 3:19pm UTC](https://discourse.julialang.org/t/collecting-the-results-from-two-processes/36342/3 "2020-03-23T15:19:36Z")

</div>

can you please clarify the second way or a link where i can understand it

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [March 23, 2020, 4:34pm UTC](https://discourse.julialang.org/t/collecting-the-results-from-two-processes/36342/4 "2020-03-23T16:34:29Z")

</div>

If you were trying to compute the mean for example, it would be `(len(arr1)*mean(arr1)+len(arr2)*mean(arr2))/(len(arr1)+len(arr2))`
