Package edu.gmu.seor.prognos.unbbayesplugin.jt.prs.hybridbn

Examples of edu.gmu.seor.prognos.unbbayesplugin.jt.prs.hybridbn.CNNormalDistribution$NormalDistributionFunction


      
      //5. add new scripts of BN
     //  CPS.getInstance().setScript(cNode, eq.getData()); 
    }else
    if( type.equalsIgnoreCase("Continuous") ){ 
      CNNormalDistribution normalDistribution = ((ContinuousNode)uNode).getCnNormalDistribution();
     
      // Make sure all the structure is created and that the parents are in the right order.
      normalDistribution.refreshParents();
      getProbFromEquation( cpt, eq, normalDistribution );
        
      //normalDistribution.setMean(function.getMean(), function.getIndex());
      //normalDistribution.setVariance(function.getVariance(), function.getIndex());
      //normalDistribution.setConstantAt(constant.getIndex(), constant.getValue(), function.getIndex());
View Full Code Here


      if (no.getType() == Node.CONTINUOUS_NODE_TYPE) {
        System.out.println("Now working on node "+no.getDescription());
        double mean,Sigma, SD;
        double g;
        ContinuousNode cn = (ContinuousNode) no;
        CNNormalDistribution CNNormalDist = cn.getCnNormalDistribution();
        NormalDistributionFunction[] ndf = cn.getCnNormalDistribution()
            .getNDF();
        /* Has no parents */
        if (hasNoParents(cn)) {
          //initialize ghk potential table
          GHKPotentialTable ghk = new GHKPotentialTable();
          ghk.getContinuousNodeList().add(cn);
         
          mean = ndf[0].getMean();
          SD = Math.sqrt(ndf[0].getVariance());
          Sigma = ndf[0].getVariance();
          System.out.println("Mean and Variance is: "+mean+" and "+ Sigma);
          /* since it contains a single ghk value and no descrete state table, we store it in a GHKPotential class instead of the Table*/
         
          // setup G
          g= calculateG2(mean, SD);
         
          //Setup H
          HComponent hc = new HComponent();
          hc.setComponent1((1 / (SD * SD)) * mean);
          hc.buildMatrix();

          //Setup K
          KComponent kc = new KComponent();
          kc.setComponent1(1 / (SD * SD));
          kc.buildMatrix();
         
          ghk.setGhkPot(new GHKPotential(g, hc, kc));
          ghk.hasNoDescreteStates = true;
          cn.setGHK(ghk);

        }
        /* Has continuous parents only */
        else if (hasContinuousParentsOnly(cn)) {
          mean = ndf[0].getMean();
          SD = Math.sqrt(ndf[0].getVariance());
         
          /* since it contains a single ghk value and no descrete state table, we store it in a GHKPotential class instead of the Table*/
         
          // setup G
          g= calculateG(mean, SD);
         
          //Setup H
          HComponent hc = new HComponent();
          hc.setComponent1(mean * (1 / (SD * SD)));
          double[] weights = ndf[0].getConstantList();
          System.out.println("The weights I get is");
          for(int i=0;i< weights.length;i++) System.out.println(weights[i]);
          if (weights.length > 1)
            hc.setComponent2(multiplyNx1(weights, -mean
                * (1 / (SD * SD))), false);
          else
            hc.setComponent2(multiplyNx1(weights, -mean
                * (1 / (SD * SD))), true);
          hc.buildMatrix();
         
          //Setup K
          KComponent kc = new KComponent();
          kc.setComponent1(1 / (SD * SD));
          kc.setComponent2(multiplyNx1(weights, -1 / (SD * SD)),
              false);
          kc.setComponent3(multiply1xN(weights, -1 / (SD * SD)),
              false);
          kc.setComponent4(multiplyNxN(multiplyNx1(weights,
              1 / (SD * SD)), multiply1xN(weights, 1)), false);
          kc.buildMatrix();
         
          //initialize ghk potential table
          GHKPotentialTable ghk = new GHKPotentialTable();
          ghk.setGhkPot(new GHKPotential(g, hc, kc));
          ghk.hasNoDescreteStates = true;
          ghk.getContinuousNodeList().add(cn);
          for(Node n:removeDuplicates(getContinuousNodes(cn.getParents())))
            ghk.getContinuousNodeList().add(n);
          cn.setGHK(ghk);
        }
        /* Has descrete parents only */
        else if (hasDescreteParentsOnly(cn)) {
         
          /* Since we need to represent a ghk potential at every combination descrete state we will use the GHKPotential Table*/
          //initialize ghk potential table
          GHKPotentialTable ghk = new GHKPotentialTable();
          ghk.getContinuousNodeList().add(cn);
         
          //Now insert the rest of the descrete variables
          for(int i=0;i<CNNormalDist.getDiscreteParentList().size();i++)
            ghk.setVariableAtVariableList(CNNormalDist.getDiscreteParentList().get(i));
         
          for (int i = 0; i < ndf.length; i++) {
            mean = ndf[i].getMean();
            SD = Math.sqrt(ndf[i].getVariance());
           
            // setup G
            g= calculateG2(mean, SD);
           
            //Setup H
            HComponent hc = new HComponent();
            hc.setComponent1((1 / (SD * SD)) * mean);
            hc.buildMatrix();
           
            //Setup K
            KComponent kc = new KComponent();
            kc.setComponent1(1 / (SD * SD));
            kc.buildMatrix();
           
            // get the corresponding reformed co-ord and set the value
            ghk.setGHK(CNNormalDist.getMultidimensionalCoord(i),g, hc, kc);
          }
          cn.setGHK(ghk);

        }
        /* Has both continuous and descrete parents */
        else if (hasContinuousAndDescreteParents(cn)) {
         
          /* Since we need to represent a ghk potential at every combination descrete state we will use the GHKPotential Table*/
          //initialize ghk potential table
          GHKPotentialTable ghk = new GHKPotentialTable();
         
          //Now insert the rest of the descrete variables
          for(int i=0;i<CNNormalDist.getDiscreteParentList().size();i++)
            ghk.setVariableAtVariableList(CNNormalDist.getDiscreteParentList().get(i));
         
          for (int i = 0; i < ndf.length; i++) {
            mean = ndf[i].getMean();
            SD = Math.sqrt(ndf[i].getVariance());
           
            // setup G
            System.out.println("calculating g sending "+mean+" and "+SD);
            g= calculateG(mean, SD);
           
            //Setup H
            HComponent hc = new HComponent();
            hc.setComponent1(mean * (1 / (SD * SD)));
            double[] weights = ndf[i].getConstantList();
            System.out.println("The weights I get is");
            for(int k=0;k< weights.length;k++) System.out.println(weights[k]);
            if (weights.length > 1)
              hc.setComponent2(multiplyNx1(weights, -mean
                  * (1 / (SD * SD))), false);
            else
              hc.setComponent2(multiplyNx1(weights, -mean
                  * (1 / (SD * SD))), true);
            hc.buildMatrix();
           
            //Setup K
            KComponent kc = new KComponent();
            kc.setComponent1(1 / (SD * SD));
            kc.setComponent2(multiplyNx1(weights, -1 / (SD * SD)),
                false);
            kc.setComponent3(multiply1xN(weights, -1 / (SD * SD)),
                false);
            kc.setComponent4(multiplyNxN(multiplyNx1(weights,
                1 / (SD * SD)), multiply1xN(weights, 1)), false);
            kc.buildMatrix();
           
          // get the corresponding reformed co-ord and set the value
          ghk.setGHK(CNNormalDist.getMultidimensionalCoord(i),g, hc, kc);
          ghk.getContinuousNodeList().add(cn);
          for(Node n:removeDuplicates(getContinuousNodes(cn.getParents())))
            ghk.getContinuousNodeList().add(n);
        }
        cn.setGHK(ghk);
View Full Code Here

TOP

Related Classes of edu.gmu.seor.prognos.unbbayesplugin.jt.prs.hybridbn.CNNormalDistribution$NormalDistributionFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.