当前位置: 首页>>代码示例>>Java>>正文


Java Randomizer.setSeed方法代码示例

本文整理汇总了Java中beast.util.Randomizer.setSeed方法的典型用法代码示例。如果您正苦于以下问题:Java Randomizer.setSeed方法的具体用法?Java Randomizer.setSeed怎么用?Java Randomizer.setSeed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在beast.util.Randomizer的用法示例。


在下文中一共展示了Randomizer.setSeed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testScaleWithInt

import beast.util.Randomizer; //导入方法依赖的package包/类
@Test
public void testScaleWithInt() throws Exception {
    Randomizer.setSeed(1);

    XMLParser parser = new XMLParser();
    beast.core.Runnable runnable = parser.parseFile(
            new File("test/epiinf/xmltests/ScaleWithIntTest.xml"));
    Logger.FILE_MODE = Logger.LogFileMode.overwrite;
    runnable.run();


    List<Expectation> expectations = new ArrayList<>();
    expectations.add(new Expectation("x1", 0.5, 0.01));
    expectations.add(new Expectation("y1", 0.5, 0.01));
    expectations.add(new Expectation("y2", 0.5, 0.01));
    expectations.add(new Expectation("y3", 0.5, 0.01));
    expectations.add(new Expectation("n", 50.0, 1.0));
    LogAnalyser logAnalyser = new LogAnalyser("ScaleWithIntTest.log", expectations);

    try {
        for (Expectation expectation : expectations) {
            assertTrue(expectation.isValid());
            assertTrue(expectation.isPassed());
        }
    } catch (Exception e) {
        throw e;

    } finally {
        Files.deleteIfExists(Paths.get("ScaleWithIntTest.xml.state"));
        Files.deleteIfExists(Paths.get("ScaleWithIntTest.log"));
    }
}
 
开发者ID:tgvaughan,项目名称:EpiInf,代码行数:33,代码来源:OperatorTests.java

示例2: testIntegerData

import beast.util.Randomizer; //导入方法依赖的package包/类
@Test
public void testIntegerData() {
	IntegerData datatype = new IntegerData();
	assertEquals("?", datatype.getCode(-1));
	assertEquals("0", datatype.getCode(0));
	assertEquals("1", datatype.getCode(1));
	assertEquals("10", datatype.getCode(10));
	assertEquals("123", datatype.getCode(123));
	Randomizer.setSeed(127);
	for (int i = 0; i < 100; i++) {
		int state = Randomizer.nextInt(100000000);
		int x = state;
    	String str = "";
    	while (state > 0) {
    		str = (char)('0' + state%10) + str;
    		state /= 10;
    	}
		assertEquals(str, datatype.getCode(x));
	}
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:21,代码来源:IntegerDataTest.java

示例3: testNarrowExchange4Taxa

import beast.util.Randomizer; //导入方法依赖的package包/类
@Test 
public void testNarrowExchange4Taxa() throws Exception {
	
       int runs = 10000;
       Randomizer.setSeed(666);
       // test that going from source tree to target tree 
       // is as likely as going the other way around
       // taking the HR in account.
       Sequence A = new Sequence("A", "A");
       Sequence B = new Sequence("B", "A");
       Sequence C = new Sequence("C", "A");
       Sequence D = new Sequence("D", "A");

       Alignment data = new Alignment();
       data.initByName("sequence", A, "sequence", B, "sequence", C, "sequence", D,
               "dataType", "nucleotide"
       );
       String sourceTree = "((A:2.0,B:2.0):1.0,(C:1.0,D:1.0):2.0):0.0"; // ((A,B),(C,D))
       String targetTree = "((A:2.0,(C:1.0,D:1.0):1.0):1.0,B:3.0):0.0"; // ((A,(C,D)),B)
       testNarrowExchange(sourceTree, targetTree, runs, data);
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:22,代码来源:ExchangeOperatorTest.java

示例4: testNarrowExchange5Taxa

import beast.util.Randomizer; //导入方法依赖的package包/类
@Test
public void testNarrowExchange5Taxa() throws Exception {
   	int runs = 10000;
    Randomizer.setSeed(666);
       Sequence A = new Sequence("A", "A");
       Sequence B = new Sequence("B", "A");
       Sequence C = new Sequence("C", "A");
       Sequence D = new Sequence("D", "A");
       Sequence E = new Sequence("E", "A");

       Alignment data = new Alignment();
       data.initByName("sequence", A, "sequence", B, "sequence", C, "sequence", D, "sequence", E,
               "dataType", "nucleotide"
       );
       String sourceTree = "(((A:2.0,B:2.0):1.0,(C:1.0,D:1.0):2.0):1.0,E:4.0):0.0"; // (((A,B),(C,D)),E)
       String targetTree = "(((A:2.0,(C:1.0,D:1.0):1.0):1.0,B:3.0):1.0,E:4.0):0.0"; // (((A,(C,D)),B),E)
       testNarrowExchange(sourceTree, targetTree, runs, data);
   }
 
开发者ID:CompEvol,项目名称:beast2,代码行数:19,代码来源:ExchangeOperatorTest.java

示例5: testNarrowExchange6Taxa

import beast.util.Randomizer; //导入方法依赖的package包/类
@Test
public void testNarrowExchange6Taxa() throws Exception {
   	int runs = 10000;
    Randomizer.setSeed(666);
       Sequence A = new Sequence("A", "A");
       Sequence B = new Sequence("B", "A");
       Sequence C = new Sequence("C", "A");
       Sequence D = new Sequence("D", "A");
       Sequence E = new Sequence("E", "A");
       Sequence F = new Sequence("F", "A");

       Alignment data = new Alignment();
       data.initByName("sequence", A, "sequence", B, "sequence", C, "sequence", D, "sequence", E, "sequence", F,
               "dataType", "nucleotide"
       );
       //String sourceTree = "((((A:2.0,B:2.0):1.0,(C:1.0,D:1.0):2.0):1.0,E:4.0):1.0,F:5.0):0.0"; // ((((A,B),(C,D)),E),F)
       //String targetTree = "((((A:2.0,(C:1.0,D:1.0):1.0):1.0,B:3.0):1.0,E:4.0):1.0,F:5.0):0.0"; // ((((A,(C,D)),B),E),F)

       String sourceTree = "(((A:5.0,B:5.0):2.0,((C:5.0,D:5.0):1.0,E:6.0):1.0):1.0,F:8.0):0.0"; 
       String targetTree = "(((A:5.0,B:5.0):2.0,F:7.0):1.0,((C:5.0,D:5.0):1.0,E:6.0):2.0):0.0"; 

       testNarrowExchange(sourceTree, targetTree, runs, data);
   }
 
开发者ID:CompEvol,项目名称:beast2,代码行数:24,代码来源:ExchangeOperatorTest.java

示例6: test5TaxonSerialSampling

import beast.util.Randomizer; //导入方法依赖的package包/类
@Test
public void test5TaxonSerialSampling() throws Exception {
    Randomizer.setSeed(1);

    XMLParser parser = new XMLParser();
    beast.core.Runnable runnable = parser.parseFile(
            new File("examples/ACGsimulations/simulateACGs5taxonSerialSampling.xml"));
    runnable.run();

    List<Expectation> expectations = new ArrayList<>();
    expectations.add(new Expectation("acg.CFheight", 1.909, 1e-2));
    expectations.add(new Expectation("acg.CFlength", 4.655, 1e-2));
    expectations.add(new Expectation("acg.nConv", 23.381, 5e-2));

    LogAnalyser logAnalyser = new LogAnalyser("simulateACGs5taxonSerialSampling.stats",
            expectations);

    for (int i=0; i<expectations.size(); i++) {
        assertTrue(expectations.get(i).isValid());
        assertTrue(expectations.get(i).isPassed());
    }

    Files.deleteIfExists(Paths.get("simulateACGs5taxonSerialSampling.stats"));
    Files.deleteIfExists(Paths.get("simulateACGs5taxonSerialSampling.converted"));
    Files.deleteIfExists(Paths.get("simulateACGs5taxonSerialSampling.trees"));
}
 
开发者ID:tgvaughan,项目名称:bacter,代码行数:27,代码来源:SimulatedACGTest.java

示例7: test5TaxonDynamicPopSize

import beast.util.Randomizer; //导入方法依赖的package包/类
@Test
public void test5TaxonDynamicPopSize() throws Exception {
    Randomizer.setSeed(1);

    XMLParser parser = new XMLParser();
    beast.core.Runnable runnable = parser.parseFile(
            new File("examples/ACGsimulations/simulateACGs5taxonDynamicPopSize.xml"));
    runnable.run();

    List<Expectation> expectations = new ArrayList<>();
    expectations.add(new Expectation("acg.CFheight", 8.840, 1e-2));
    expectations.add(new Expectation("acg.CFlength", 25.312, 1e-2));
    expectations.add(new Expectation("acg.nConv", 25.464, 5e-2));

    LogAnalyser logAnalyser = new LogAnalyser("simulateACGs5taxonDynamicPopSize.stats",
            expectations);

    for (int i=0; i<expectations.size(); i++) {
        assertTrue(expectations.get(i).isValid());
        assertTrue(expectations.get(i).isPassed());
    }

    Files.deleteIfExists(Paths.get("simulateACGs5taxonDynamicPopSize.stats"));
    Files.deleteIfExists(Paths.get("simulateACGs5taxonDynamicPopSize.converted"));
    Files.deleteIfExists(Paths.get("simulateACGs5taxonDynamicPopSize.trees"));
}
 
开发者ID:tgvaughan,项目名称:bacter,代码行数:27,代码来源:SimulatedACGTest.java

示例8: testCFSTX

import beast.util.Randomizer; //导入方法依赖的package包/类
@Test
public void testCFSTX() throws Exception {
    Randomizer.setSeed(1);

    XMLParser parser = new XMLParser();
    beast.core.Runnable runnable = parser.parseFile(
            new File("examples/CFOperatorTests/CFSubtreeExchangeTest5taxon.xml"));
    disableScreenLog(runnable);
    runnable.run();

    List<Expectation> expectations = new ArrayList<>();
    expectations.add(new Expectation("acg.CFheight", 1.606, 0.2));
    expectations.add(new Expectation("acg.CFlength", 4.181, 0.5));
    expectations.add(new Expectation("acg.nConv", 21.0, 0.5));

    new LogAnalyser("CFSubtreeExchangeTest5taxon.stats", expectations);

    for (Expectation expectation : expectations) {
        assertTrue(expectation.isValid());
        assertTrue(expectation.isPassed());
    }

    Files.deleteIfExists(Paths.get("CFSubtreeExchangeTest5taxon.stats"));
    Files.deleteIfExists(Paths.get("CFSubtreeExchangeTest5taxon.trees"));
    Files.deleteIfExists(Paths.get("CFSubtreeExchangeTest5taxon.xml.state"));
}
 
开发者ID:tgvaughan,项目名称:bacter,代码行数:27,代码来源:CFOperatorTest.java

示例9: set_seed

import beast.util.Randomizer; //导入方法依赖的package包/类
public static void set_seed(/*@Current Context context,*/ int seed) { //, SEXP kind, SEXP normalkind) {
	  Randomizer.setSeed(seed);
//    //RNG rng = context.getSession().rng;
//    rng.randomseed = seed;
//    RNGkind(/*context,*/ kind, normalkind);
//    switch (rng.RNG_kind) {
//    case WICHMANN_HILL:
//      throw new EvalException(rng.RNG_kind + " not implemented yet");
//
//    case MARSAGLIA_MULTICARRY:
//      throw new EvalException(rng.RNG_kind + " not implemented yet");
//
//    case SUPER_DUPER:
//      throw new EvalException(rng.RNG_kind + " not implemented yet");
//
//    case MERSENNE_TWISTER:
//      if (rng.mersenneTwisterAlg == null) {
//        rng.mersenneTwisterAlg = new MersenneTwister(seed);
//      } else {
//        rng.mersenneTwisterAlg.setSeed(seed);
//      }
//      return;
//
//    case KNUTH_TAOCP:
//    case KNUTH_TAOCP2:
//      throw new EvalException(rng.RNG_kind + " not implemented yet");
//    case USER_UNIF:
//      throw new EvalException(rng.RNG_kind + " not implemented yet");
//    default:
//      throw new EvalException(rng.RNG_kind + " not implemented yet");
//    }
  }
 
开发者ID:CompEvol,项目名称:beastshell,代码行数:33,代码来源:RNG.java

示例10: analyse

import beast.util.Randomizer; //导入方法依赖的package包/类
public void analyse(int index_XML) throws Exception {
//        for (int i = 0; i < xmls.length; i++) {
//            if (giveExpectations(i).size() > 0) {
        Randomizer.setSeed(SEED);
        Logger.FILE_MODE = Logger.LogFileMode.overwrite;
        
        long beagleFlags = BeagleFlag.PROCESSOR_CPU.getMask() | BeagleFlag.VECTOR_SSE.getMask();
        System.setProperty("beagle.preferred.flags", Long.toString(beagleFlags));


        String fileName = dirName + xmls[index_XML];

        System.out.println("Processing " + fileName);
        XMLParser parser = new XMLParser();
        beast.core.Runnable runable = parser.parseFile(new File(fileName));
        runable.setStateFile("tmp.state", false);
//		   runable.setInputValue("preBurnin", 0);
//		   runable.setInputValue("chainLength", 1000);
        runable.run();

        String logFile = logDir + testFile + (useSeed ? SEED : "") + ".log";
        System.out.println("\nAnalysing log " + logFile);
        LogAnalyser logAnalyser = new LogAnalyser(logFile, giveExpectations(index_XML)); // burnIn = 0.1 * maxState

        for (Expectation expectation : logAnalyser.m_pExpectations.get()) {
            Assert.assertTrue(xmls[index_XML] + ": Expected " + expectation.traceName.get() + " delta mean: "
                    + expectation.expValue.get() + " - " + expectation.getTraceStatistics().getMean()
                    + " <= delta stdErr: 2*(" + expectation.getStdError() + " + "
                    + expectation.getTraceStatistics().getStdErrorOfMean() + ")", expectation.isPassed());

            if (checkESS)
            	Assert.assertTrue(xmls[index_XML] + ":  has very low effective sample sizes (ESS) "
                    + expectation.getTraceStatistics().getESS(), expectation.isValid());
        }

        System.out.println("\nSucceed " + fileName);
        System.out.println("\n***************************************\n");
//            }
//        }
    }
 
开发者ID:CompEvol,项目名称:beast2,代码行数:41,代码来源:TestFramework.java

示例11: testEquilibriumFrequencies

import beast.util.Randomizer; //导入方法依赖的package包/类
/**      
 * test that equilibrium frequencies are
 * [ p0 * f0, p1, * f0, p0 * f1, p1, * f1 ]
 */
@Test
public void testEquilibriumFrequencies() {
	Randomizer.setSeed(120);
	doWithTufflySteel();

	for (int i = 0; i < 10; i++) {
		doWithEqualHFreqs("BEAST");
		doWithEqualHFreqs("REVERSIBLE");
	}
	doWithUnEqualHFreqs("REVERSIBLE");
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:16,代码来源:BinaryCovarionModelTest.java

示例12: test5Taxon

import beast.util.Randomizer; //导入方法依赖的package包/类
@Test
public void test5Taxon() throws Exception {
    Randomizer.setSeed(1);

    XMLParser parser = new XMLParser();
    beast.core.Runnable runnable = parser.parseFile(
            new File("examples/addRemoveTests/addRemoveTest5taxon.xml"));
    disableScreenLog(runnable);
    runnable.run();

    List<Expectation> expectations = new ArrayList<>();
    expectations.add(new Expectation("acg.CFheight", 1.606, 0.2));
    expectations.add(new Expectation("acg.CFlength", 4.181, 0.5));
    expectations.add(new Expectation("acg.nConv", 21.0, 0.5));

    LogAnalyser logAnalyser = new LogAnalyser("addRemoveTest5taxon.stats",
            expectations);

    for (int i=0; i<expectations.size(); i++) {
        assertTrue(expectations.get(i).isValid());
        assertTrue(expectations.get(i).isPassed());
    }

    Files.deleteIfExists(Paths.get("addRemoveTest5taxon.stats"));
    Files.deleteIfExists(Paths.get("addRemoveTest5taxon.converted"));
    Files.deleteIfExists(Paths.get("addRemoveTest5taxon.trees"));
    Files.deleteIfExists(Paths.get("addRemoveTest5taxon.cf"));
    Files.deleteIfExists(Paths.get("addRemoveTest5taxon.xml.state"));
}
 
开发者ID:tgvaughan,项目名称:bacter,代码行数:30,代码来源:AddRemoveTest.java

示例13: test5TaxonDynamicPopSize

import beast.util.Randomizer; //导入方法依赖的package包/类
@Test
public void test5TaxonDynamicPopSize() throws Exception {
    Randomizer.setSeed(1);

    XMLParser parser = new XMLParser();
    beast.core.Runnable runnable = parser.parseFile(
            new File("examples/addRemoveTests/addRemoveDynamicPopSize5taxon.xml"));
    disableScreenLog(runnable);
    runnable.run();

    List<Expectation> expectations = new ArrayList<>();
    expectations.add(new Expectation("acg.CFheight", 8.840, 1e-2));
    expectations.add(new Expectation("acg.CFlength", 25.312, 0.5));
    expectations.add(new Expectation("acg.nConv", 25.464, 0.5));

    LogAnalyser logAnalyser = new LogAnalyser("addRemoveDynamicPopSize5taxon.stats",
            expectations);

    for (int i=0; i<expectations.size(); i++) {
        assertTrue(expectations.get(i).isValid());
        assertTrue(expectations.get(i).isPassed());
    }

    Files.deleteIfExists(Paths.get("addRemoveDynamicPopSize5taxon.stats"));
    Files.deleteIfExists(Paths.get("addRemoveDynamicPopSize5taxon.converted"));
    Files.deleteIfExists(Paths.get("addRemoveDynamicPopSize5taxon.trees"));
    Files.deleteIfExists(Paths.get("addRemoveDynamicPopSize5taxon.cf"));
    Files.deleteIfExists(Paths.get("addRemoveDynamicPopSize5taxon.xml.state"));
}
 
开发者ID:tgvaughan,项目名称:bacter,代码行数:30,代码来源:AddRemoveTest.java

示例14: testGeomRandomWalk

import beast.util.Randomizer; //导入方法依赖的package包/类
@Test
public void testGeomRandomWalk() throws Exception {
    Randomizer.setSeed(1);

    XMLParser parser = new XMLParser();
    beast.core.Runnable runnable = parser.parseFile(
            new File("test/epiinf/xmltests/GeomRandomWalkTest.xml"));
    Logger.FILE_MODE = Logger.LogFileMode.overwrite;
    runnable.run();


    List<Expectation> expectations = new ArrayList<>();
    expectations.add(new Expectation("n", 50.0, 1.0));
    LogAnalyser logAnalyser = new LogAnalyser("GeomRandomWalkTest.log", expectations);

    try {
        for (Expectation expectation : expectations) {
            assertTrue(expectation.isValid());
            assertTrue(expectation.isPassed());
        }
    } catch (Exception e) {
        throw e;

    } finally {
        Files.deleteIfExists(Paths.get("GeomRandomWalkTest.xml.state"));
        Files.deleteIfExists(Paths.get("GeomRandomWalkTest.log"));
    }
}
 
开发者ID:tgvaughan,项目名称:EpiInf,代码行数:29,代码来源:OperatorTests.java

示例15: testRegionShift

import beast.util.Randomizer; //导入方法依赖的package包/类
@Test
public void testRegionShift() throws Exception {
    Randomizer.setSeed(1);

    XMLParser parser = new XMLParser();
    beast.core.Runnable runnable = parser.parseFile(
            new File("examples/regionShiftTests/regionShiftTest5taxon.xml"));
    disableScreenLog(runnable);
    runnable.run();

    List<Expectation> expectations = new ArrayList<>();
    expectations.add(new Expectation("acg.CFheight", 1.606, 0.2));
    expectations.add(new Expectation("acg.CFlength", 4.181, 0.5));
    expectations.add(new Expectation("acg.nConv", 21.0, 0.5));

    LogAnalyser logAnalyser = new LogAnalyser("regionShiftTest5taxon.stats",
            expectations);

    for (int i=0; i<expectations.size(); i++) {
        assertTrue(expectations.get(i).isValid());
        assertTrue(expectations.get(i).isPassed());
    }

    Files.deleteIfExists(Paths.get("regionShiftTest5taxon.stats"));
    Files.deleteIfExists(Paths.get("regionShiftTest5taxon.converted"));
    Files.deleteIfExists(Paths.get("regionShiftTest5taxon.trees"));
    Files.deleteIfExists(Paths.get("regionShiftTest5taxon.cf"));
    Files.deleteIfExists(Paths.get("regionShiftTest5taxon.xml.state"));
}
 
开发者ID:tgvaughan,项目名称:bacter,代码行数:30,代码来源:RegionShiftTest.java


注:本文中的beast.util.Randomizer.setSeed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。