本文整理汇总了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"));
}
}
示例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));
}
}
示例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);
}
示例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);
}
示例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);
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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");
// }
}
示例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");
// }
// }
}
示例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");
}
示例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"));
}
示例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"));
}
示例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"));
}
}
示例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"));
}