private boolean willBeNaN (Factor product, Factor otherMsg) { Factor p2 = product.duplicate (); p2.divideBy (otherMsg); return p2.isNaN (); }
private boolean willBeNaN (Factor product, Factor otherMsg) { Factor p2 = product.duplicate (); p2.divideBy (otherMsg); return p2.isNaN (); }
private boolean willBeNaN (Factor product, Factor otherMsg) { Factor p2 = product.duplicate (); p2.divideBy (otherMsg); return p2.isNaN (); }
Factor msgProduct (RegionEdge edge) { Factor product = new LogTableFactor (edge.from.vars); for (Iterator it = edge.neighboringParents.iterator (); it.hasNext ();) { RegionEdge otherEdge = (RegionEdge) it.next (); Factor otherMsg = oldMessages.getMessage (otherEdge.from, otherEdge.to); product.multiplyBy (otherMsg); } for (Iterator it = edge.loopingMessages.iterator (); it.hasNext ();) { RegionEdge otherEdge = (RegionEdge) it.next (); Factor otherMsg = newMessages.getMessage (otherEdge.from, otherEdge.to); product.divideBy (otherMsg); } return product; } }
Factor msgProduct (RegionEdge edge) { Factor product = new LogTableFactor (edge.from.vars); for (Iterator it = edge.neighboringParents.iterator (); it.hasNext ();) { RegionEdge otherEdge = (RegionEdge) it.next (); Factor otherMsg = oldMessages.getMessage (otherEdge.from, otherEdge.to); product.multiplyBy (otherMsg); } for (Iterator it = edge.loopingMessages.iterator (); it.hasNext ();) { RegionEdge otherEdge = (RegionEdge) it.next (); Factor otherMsg = newMessages.getMessage (otherEdge.from, otherEdge.to); product.divideBy (otherMsg); } return product; } }
public Factor joint (JunctionTree jt) { Factor joint = TableFactor.multiplyAll (jt.clusterPotentials ()); for (Iterator it = jt.sepsetPotentials().iterator(); it.hasNext();) { TableFactor pot = (TableFactor) it.next(); joint.divideBy (pot); } joint.normalize(); return joint; }
public Factor joint (JunctionTree jt) { Factor joint = TableFactor.multiplyAll (jt.clusterPotentials ()); for (Iterator it = jt.sepsetPotentials().iterator(); it.hasNext();) { TableFactor pot = (TableFactor) it.next(); joint.divideBy (pot); } joint.normalize(); return joint; }
Factor msgProduct (RegionEdge edge) { Factor product = new LogTableFactor (edge.from.vars); for (Iterator it = edge.neighboringParents.iterator (); it.hasNext ();) { RegionEdge otherEdge = (RegionEdge) it.next (); Factor otherMsg = oldMessages.getMessage (otherEdge.from, otherEdge.to); product.multiplyBy (otherMsg); } for (Iterator it = edge.loopingMessages.iterator (); it.hasNext ();) { RegionEdge otherEdge = (RegionEdge) it.next (); Factor otherMsg = newMessages.getMessage (otherEdge.from, otherEdge.to); product.divideBy (otherMsg); } return product; } }
public Factor joint (JunctionTree jt) { Factor joint = TableFactor.multiplyAll (jt.clusterPotentials ()); for (Iterator it = jt.sepsetPotentials().iterator(); it.hasNext();) { TableFactor pot = (TableFactor) it.next(); joint.divideBy (pot); } joint.normalize(); return joint; }
/** * This sends a sum-product message, normalized to avoid * underflow. */ public void sendMessage (JunctionTree jt, VarSet from, VarSet to) { Collection sepset = jt.getSepset (from, to); Factor fromCpf = jt.getCPF (from); Factor toCpf = jt.getCPF (to); Factor oldSepsetPot = jt.getSepsetPot (from, to); Factor lambda = fromCpf.marginalize (sepset); lambda.normalize (); jt.setSepsetPot (lambda, from, to); toCpf = toCpf.multiply (lambda); toCpf.divideBy (oldSepsetPot); toCpf.normalize (); jt.setCPF (to, toCpf); }
/** * This sends a sum-product message, normalized to avoid * underflow. */ public void sendMessage (JunctionTree jt, VarSet from, VarSet to) { Collection sepset = jt.getSepset (from, to); Factor fromCpf = jt.getCPF (from); Factor toCpf = jt.getCPF (to); Factor oldSepsetPot = jt.getSepsetPot (from, to); Factor lambda = fromCpf.marginalize (sepset); lambda.normalize (); jt.setSepsetPot (lambda, from, to); toCpf = toCpf.multiply (lambda); toCpf.divideBy (oldSepsetPot); toCpf.normalize (); jt.setCPF (to, toCpf); }
/** * This sends a sum-product message, normalized to avoid * underflow. */ public void sendMessage (JunctionTree jt, VarSet from, VarSet to) { Collection sepset = jt.getSepset (from, to); Factor fromCpf = jt.getCPF (from); Factor toCpf = jt.getCPF (to); Factor oldSepsetPot = jt.getSepsetPot (from, to); Factor lambda = fromCpf.marginalize (sepset); lambda.normalize (); jt.setSepsetPot (lambda, from, to); toCpf = toCpf.multiply (lambda); toCpf.divideBy (oldSepsetPot); toCpf.normalize (); jt.setCPF (to, toCpf); }
/** * This sends a max-product message. */ public void sendMessage (JunctionTree jt, VarSet from, VarSet to) { // System.err.println ("Send message "+from+" --> "+to); Collection sepset = jt.getSepset (from, to); Factor fromCpf = jt.getCPF (from); Factor toCpf = jt.getCPF (to); Factor oldSepsetPot = jt.getSepsetPot (from, to); Factor lambda = fromCpf.extractMax (sepset); lambda.normalize (); jt.setSepsetPot (lambda, from, to); toCpf = toCpf.multiply (lambda); toCpf.divideBy (oldSepsetPot); toCpf.normalize (); jt.setCPF (to, toCpf); }
/** * This sends a max-product message. */ public void sendMessage (JunctionTree jt, VarSet from, VarSet to) { // System.err.println ("Send message "+from+" --> "+to); Collection sepset = jt.getSepset (from, to); Factor fromCpf = jt.getCPF (from); Factor toCpf = jt.getCPF (to); Factor oldSepsetPot = jt.getSepsetPot (from, to); Factor lambda = fromCpf.extractMax (sepset); lambda.normalize (); jt.setSepsetPot (lambda, from, to); toCpf = toCpf.multiply (lambda); toCpf.divideBy (oldSepsetPot); toCpf.normalize (); jt.setCPF (to, toCpf); }
/** * This sends a max-product message. */ public void sendMessage (JunctionTree jt, VarSet from, VarSet to) { // System.err.println ("Send message "+from+" --> "+to); Collection sepset = jt.getSepset (from, to); Factor fromCpf = jt.getCPF (from); Factor toCpf = jt.getCPF (to); Factor oldSepsetPot = jt.getSepsetPot (from, to); Factor lambda = fromCpf.extractMax (sepset); lambda.normalize (); jt.setSepsetPot (lambda, from, to); toCpf = toCpf.multiply (lambda); toCpf.divideBy (oldSepsetPot); toCpf.normalize (); jt.setCPF (to, toCpf); }