I can’t get Cvaluespace to output the correct values, identical to table 3.

I think it has to do with reshape, notebook is below.

https://github.com/hpoit/DFactor.jl/blob/master/function%20DFmultiply.ipynb

Thanks

I can’t get Cvaluespace to output the correct values, identical to table 3.

I think it has to do with reshape, notebook is below.

https://github.com/hpoit/DFactor.jl/blob/master/function%20DFmultiply.ipynb

Thanks

Please don’t reproduce copyrighted material without acknowledging the source.

It is impossible to run your notebook without the `BN`

module.

This seems to be a rather strange mathematical operation; I don’t even know the name for it.

Writing it in index notation, if `A`

and `B`

are the objects on the left and `M`

the object on the right, we have

```
M[i, j, k] = A[i, j] * B[j, k]
```

Now we translate that to Julia:

```
julia> v1 = [0.5, 0.8, 0.1, 0, 0.3, 0.9]; # raw data
julia> v2 = [0.5, 0.7, 0.1, 0.2];
julia> A = reshape(v1, 2, 3)'
3×2 Array{Float64,2}:
0.5 0.8
0.1 0.0
0.3 0.9
julia> B = reshape(v2, 2, 2)'
2×2 Array{Float64,2}:
0.5 0.7
0.1 0.2
julia> M = [A[i, j] * B[j, k] for i in 1:size(A,1), j in 1:size(A,2), k in 1:size(B,2)]
3×2×2 Array{Float64,3}:
[:, :, 1] =
0.25 0.08
0.05 0.0
0.15 0.09
[:, :, 2] =
0.35 0.16
0.07 0.0
0.21 0.18
```

Thanks @dpsanders. The figure is from Prof. Daphne Koller’s Bayesian Networks, and the original code is from Wang Lei’s DiscreteFactor.jl.

Keep in mind it needs to work for tables of arbitrary size. @hpoit should check that this works for tables with more variables and varied cardinalities.

There is a new discrete factor implementation in BayesNets.jl that may be of use.