Closed GiggleLiu closed 1 year ago
Merging #61 (6266d7c) into main (a066560) will increase coverage by
3.00%
. The diff coverage is66.66%
.
@@ Coverage Diff @@
## main #61 +/- ##
==========================================
+ Coverage 81.61% 84.61% +3.00%
==========================================
Files 10 10
Lines 533 533
==========================================
+ Hits 435 451 +16
+ Misses 98 82 -16
Files Changed | Coverage Δ | |
---|---|---|
src/mar.jl | 94.54% <66.66%> (ø) |
The updated docstring
Query the marginals of the variables in a
TensorNetworkModel
. The returned value is a dictionary of variables and their marginals, where a marginal is a joint probability distribution over the associated variables. By default, the marginals of all individual variables are returned. The marginal variables to query can be specified when constructingTensorNetworkModel
as its fieldmars
. It will affect the contraction order of the tensor network.Arguments
tn
: theTensorNetworkModel
to query.usecuda
: whether to use CUDA for tensor contraction.rescale
: whether to rescale the tensors during contraction.Example
The following example is from
examples/asia/main.jl
.In this example, we first set the evidence of variable 1 to 0, then we query the marginals of all individual variables. The returned values is a dictionary, the key are query variables, and the value are the corresponding marginals. The marginals are vectors, with its entries corresponding to the probability of the variable taking the value 0 and 1, respectively. For evidence variable 1, the marginal is always
[1.0]
, since it is fixed to 0.Then we set the marginal variables to query to be variable 2 and 3, and variable 3 and 4, respectively. The joint marginals may or may not increase the contraction time and space. Here, the contraction space complexity is increased from 2^2.0 to 2^5.0, and the contraction time complexity is increased from 2^5.977 to 2^7.781. The output marginals are joint probabilities of the query variables represented by tensors.