Package

Source Code of ContinuousDistribution_Test


import unbbayes.util.Debug;
import edu.gmu.seor.prognos.unbbayesplugin.cps.CPSCompilerMain;
import edu.gmu.seor.prognos.unbbayesplugin.cps.datastructure.EDB;

/*
* discretizing for continuous nodes
*/
public class ContinuousDistribution_Test extends Test{

  public ContinuousDistribution_Test() {
    Debug.setDebug(true);
     EDB.This().printSet(true);
  }
  
  //*** This works well at 6/16/2011 ***
  public void test1() {
    CPSCompilerMain cpsCompiler = new CPSCompilerMain();
        cpsCompiler.InitCompiler();
    cpsCompiler.compile(
        "defineNode(C1, DescriptionC0);"+
        "{defineState(Continuous, 1, 2, 3, 4, 5, 6, 7 ,8, 9);" +
        "p( C1 ) = NormalDist( 5,1 );"+
        "}"    +
        "createCPT( C1 );"
       
      );
       
      EDB.This().print("ROOT");
    }
 
  //*** This works well at 6/16/2011 ***
  public void test2() {
    CPSCompilerMain cpsCompiler = new CPSCompilerMain();
        cpsCompiler.InitCompiler();
    cpsCompiler.compile(
        "defineNode(C0, DescriptionC0);"+
        "{defineState(Discrete, 7, 8 );" +
        "p( C0 ) = PoissonDist( 2 );"+
        "}"+
       
        "defineNode(C1, DescriptionC0);"+
        "{defineState(Continuous, 1, 2, 3, 4, 5, 6);" +
        "p( C1 ) = NormalDist( 5,1 );"+
        "}"+
               
        "defineNode(C2, DescriptionC0);"+
        "{defineState(Discrete, 1, 2, 3, 4, 5, 6);" +
        "p( C2 | C0, C1 ) = if ( C0 == 7 && C1 == 1 ){ 1: 0.3; 2: 0.1; 3: 0.1; 4: 0.3; 5: 0.1; 6: 0.1;  } " +
        "else if ( C0 == 7 && C1 == 2 ) { PoissonDist( 3 ) + 1; } " +
        "else if ( C0 == 7 && C1 == 3 ) { PoissonDist( 4 ); } " +
        "else if ( C0 == 7 && C1 == 4 ) { PoissonDist( 5 ); } " +
        "else if ( C0 == 7 && C1 == 5 ) { PoissonDist( 6 ); } " +
         //
        "else if ( C0 == 8 && C1 == 1 ){ 1: 0.3; 2: 0.1; 3: 0.1; 4: 0.3; 5: 0.1; 6: 0.1;  } " +
        "else if ( C0 == 8 && C1 == 2 ) { PoissonDist( 13 ); } " +
        "else if ( C0 == 8 && C1 == 3 ) { PoissonDist( 12 ); } " +
        "else if ( C0 == 8 && C1 == 4 ) { PoissonDist( 15 ); } " +
        "else if ( C0 == 8 && C1 == 5 ) { PoissonDist( 16 ); } " +
         "}" +
       
        "createCPT( C0, C1, C2 );"
      );
       
      EDB.This().print("ROOT");
    }
  //*** This works well at 6/16/2011 ***
  public void test3() {
    CPSCompilerMain cpsCompiler = new CPSCompilerMain();
        cpsCompiler.InitCompiler();
    cpsCompiler.compile(
        "defineNode(C0, DescriptionC0);"+
        "{defineState(Discrete, 1, 2, 3, 4, 5, 6, 7, 8 );" +
        "p( C0 ) = PoissonDist( 2 );"+
        "}"+
       
        "defineNode(C1, DescriptionC0);"+
        "{defineState(Continuous, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);" +
        "p( C1 ) = NormalDist( 5,1 );"+
        "}"+
               
        "defineNode(C2, DescriptionC0);"+
        "{defineState(Continuous, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);" +
        "p( C2 | C0, C1 ) = if ( C0 == 7 && C1 == 1 ){ NormalDist( 3, 1 );} " +
        "else if ( C0 == 7 && C1 == 2 ) { NormalDist( 3, 1 ); } " +
        "else if ( C0 == 7 && C1 == 3 ) { NormalDist( 4, 1 ); } " +
        "else if ( C0 == 7 && C1 == 4 ) { NormalDist( 5, 1 ); } " +
        "else if ( C0 == 7 && C1 == 5 ) { NormalDist( 6, 1 ); } " +
         //
        "else if ( C0 == 8 && C1 == 1 ){ NormalDist( 3, 1 ); } " +
        "else if ( C0 == 8 && C1 == 2 ) { NormalDist( 3, 1 ); } " +
        "else if ( C0 == 8 && C1 == 3 ) { NormalDist( 2, 1 ); } " +
        "else if ( C0 == 8 && C1 == 4 ) { NormalDist( 3, 1 ); } " +
        "else if ( C0 == 8 && C1 == 5 ) { NormalDist( 2, 1 ); } " +
         "}" +
       
        "createCPT( C0, C1, C2  );" 
       
        //"defineEvidence( C0, 8 );"+
        //"run( DMP );"
      );
       
      EDB.This().print("ROOT.NODES.C2");
    }
 
  //*** This works well at 6/16/2011 ***
  public void test4() {
    CPSCompilerMain cpsCompiler = new CPSCompilerMain();
        cpsCompiler.InitCompiler();
    cpsCompiler.compile(
        "defineNode(C0, DescriptionC0);"+
        "{defineState(Continuous, 1, 3,4,6 );" +
        "p( C0 ) = NormalDist( 4,1 );"+
        "}"+
         
        "defineNode(C1, DescriptionC1);"+
        "{defineState(Discrete, 1, 2 );" +
        "p( C1 | C0 ) = if( C0 == 1 ) { PoissonDist( 4 );}"+
        "else if( C0 == 3 ) { PoissonDist( 4 );}"+
        "else if( C0 == 4 ) { PoissonDist( 2 );}"+
        "}"+
         
        "setSampleSize(100000);"+
        "createCPT( C0, C1  );" 
        
      );
       
      EDB.This().print("ROOT");
    }
 
  public void test_final() {
    test1();
    test2();
    test3();
    test4();
   }
 
  public void test_All() {
    test_final()
  }
 
  /**
   * @param args
   */
  public static void main(String[] args) {
     
    ContinuousDistribution_Test t = new ContinuousDistribution_Test();
    t.test3();  
  }
}
TOP

Related Classes of ContinuousDistribution_Test

TOP
Copyright © 2018 www.massapi.com. 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.