public VarTensor getMarginal ( VarSet vars , boolean normalize ) { VarSet margVars = new VarSet ( this . vars ) ; margVars . retainAll ( vars ) ; VarTensor marg = new VarTensor ( s , margVars , s . zero ( ) ) ; if ( margVars . size ( ) == 0 ) { return marg ; } IntIter iter = margVars . getConfigIter ( this . vars ) ; for ( int i = 0 ; i < this . values . length ; i ++ ) { int j = iter . next ( ) ; marg . values [ j ] = s . plus ( marg . values [ j ] , this . values [ i ] ) ; } if ( normalize ) { marg . normalize ( ) ; } return marg ; }
Gets the marginal distribution over a subset of the variables in this factor optionally normalized .