# Convert 2 variable of Gaussian into a bivariate Gaussian? • ### Question

• I have 2 variable of Gaussian formed from some factors, and I would like to form a Variable of bivariate Gaussian from them.

let a = Variable.GaussianFromMeanAndVariance(0.01.0)
let b = Variable.GaussianFromMeanAndVariance(1.02.0)
let range = Range 2
let x = Variable.Array range
x. <- a
x. <- b
printfn "%A" (engine.Infer x)
let y = Variable.Vector(x)
printfn "%A" (engine.Infer y)

The above doesn't work.

I know if I have a VariableArray<double>, then I can simply use Variable.Vector.

But here I have 2 Variables instead of a Variable Array

Update:

I got a workaround, it is quite ugly, and maybe very inefficient.

let a = Variable.GaussianFromMeanAndVariance(0.01.0)
let b = Variable.GaussianFromMeanAndVariance(1.02.0)
let range = Range 2
let x = Variable.Array<double> range
using(Variable.ForEach range) (fun rangeBlock -> (Variable.IfBlock (rangeBlock.Index == 0)) (fun _ -> x.[range] <- a) (fun _ -> x.[range] <- b))
printfn "%A" (engine.Infer x)
let y = Variable.Vector(x)
printfn "%A" (engine.Infer y)

• Edited by Friday, October 24, 2014 5:06 PM
Friday, October 24, 2014 4:19 PM

### Answers

• You must use Variable.Copy when making a copy of a variable:

```    x. <- Variable.Copy(a)
x. <- Variable.Copy(b)
```

• Marked as answer by Friday, October 24, 2014 7:25 PM
Friday, October 24, 2014 5:37 PM