/** * Sets the distribution of a normal variable with multinomial and normal parents in the Hugin model from the * corresponding distribution in the AMIDST model. * @param dist the AMIDST distribution to be converted. * @throws ExceptionHugin */ private void setNormal_MultinomialNormalParents(Normal_MultinomialNormalParents dist) throws ExceptionHugin { List<Variable> multinomialParents = dist.getMultinomialParents(); int numParentAssignments = MultinomialIndex.getNumberOfPossibleAssignments(multinomialParents); for(int i=0;i<numParentAssignments;i++) { this.setNormal_NormalParents(dist.getNormal_NormalParentsDistribution(i),i); } }
/** * Sets the distribution of a normal variable with normal and multinomial parents in the AMIDST model from the * corresponding distribution in the Hugin model. * For each assignment of the multinomial parents, a CLG distribution is set. * @param huginVar the Hugin variable with the distribution to be converted. * @throws ExceptionHugin */ private void setNormal_MultinomialNormalParents(Node huginVar) throws ExceptionHugin { int indexNode = this.huginBN.getNodes().indexOf(huginVar); Variable amidstVar = this.amidstBN.getVariables().getVariableById(indexNode); Normal_MultinomialNormalParents dist = this.amidstBN.getConditionalDistribution(amidstVar); List<Variable> multinomialParents = dist.getMultinomialParents(); int numParentAssignments = MultinomialIndex.getNumberOfPossibleAssignments(multinomialParents); for(int i=0;i<numParentAssignments;i++) { ConditionalLinearGaussian normalNormal = dist.getNormal_NormalParentsDistribution(i); double huginIntercept = ((ContinuousChanceNode)huginVar).getAlpha(i); normalNormal.setIntercept(huginIntercept); List<Variable> normalParents = dist.getNormalParents(); int numParents = normalParents.size(); double[] coefficients = new double[numParents]; for(int j=0;j<numParents;j++){ String nameAmidstNormalParent = normalParents.get(j).getName(); ContinuousChanceNode huginParent = (ContinuousChanceNode)this.huginBN.getNodeByName(nameAmidstNormalParent); coefficients[j]= ((ContinuousChanceNode)huginVar).getBeta(huginParent,i); } normalNormal.setCoeffParents(coefficients); double huginVariance = ((ContinuousChanceNode)huginVar).getGamma(i); normalNormal.setVariance(huginVariance); } }