Package

Source Code of DiscreteDistribution_Test

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


public class DiscreteDistribution_Test extends Test{

  public DiscreteDistribution_Test() { }
  
  //*** This works well at 6/16/2011 ***
  public void poisson_test() {
    CPSCompilerMain cpsCompiler = new CPSCompilerMain();
        cpsCompiler.InitCompiler();
    cpsCompiler.compile(
        "defineNode(C1, DescriptionC0);"+
        "{defineState(Discrete, 1, 2, 3, 4, 5, 6);" +
        "p( C1 ) = PoissonDist( 2 );"+
        "}"+
             
        "defineNode(C0, DescriptionC0);"+
        "{defineState(Discrete, 7, 8 );" +
        "p( C0 ) = PoissonDist( 2 );"+
        "}"+
       
        "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 == 7 && C1 == 6 ) { PoissonDist( 7 ); } " +
        //
        "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 ); } " +
        "else if ( C0 == 8 && C1 == 6 ) { PoissonDist( 17 ); } " +
        "}" +
        
        "setSampleSize(1000);"+
        "createCPT( C0, C1, C2 );"
      );
       
      EDB.This().print("ROOT");
    }
 
  //*** This works well at 6/16/2011 ***
  public void poisson_test2() {
    CPSCompilerMain cpsCompiler = new CPSCompilerMain();
        cpsCompiler.InitCompiler();
    cpsCompiler.compile(
        "defineNode(C1, DescriptionC0);"+
        "{defineState(Discrete, 1, 2, 3, 4, 5, 6);" +
        "p( C1 ) = PoissonDist( 2 );"+
        "}"+
       
        "defineNode(C2, DescriptionC0);"+
        "{defineState(Discrete, 1, 2, 3, 4, 5, 6);" +
        "p( C2 | C1 ) = if ( C1 == 1 ){ 1: 0.3; 2: 0.1; 3: 0.1; 4: 0.3; 5: 0.1; 6: 0.1;  } " +
        "else if ( C1 == 2 ) { PoissonDist( 3 ); } " +
        "else if ( C1 == 3 ) { PoissonDist( 4 ); } " +
        "else if ( C1 == 4 ) { PoissonDist( 5 ); } " +
        "else if ( C1 == 5 ) { PoissonDist( 6 ); } " +
        "else if ( C1 == 6 ) { PoissonDist( 7 ); } " +
        "}" +
       
        "setSampleSize(1000);"+
        "createCPT( C0, C1, C2 );"
      );
       
      EDB.This().print("ROOT");
    }
 
  /**
   * @param args
   */
  public static void main(String[] args) {
    DiscreteDistribution_Test t = new DiscreteDistribution_Test();
    t.poisson_test();  
  }
}
TOP

Related Classes of DiscreteDistribution_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.