File: simulateJumpsAbstract.cpp

package info (click to toggle)
fastml 3.11-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,772 kB
  • sloc: cpp: 48,522; perl: 3,588; ansic: 819; makefile: 386; python: 83; sh: 55
file content (44 lines) | stat: -rw-r--r-- 1,372 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "simulateJumpsAbstract.h"


simulateJumpsAbstract::simulateJumpsAbstract(const tree& inTree, const stochasticProcess& sp, const int alphabetSize)
: _tree(inTree), _sp(sp), _alphabetSize(alphabetSize)	
{
}



//runSimulation: do the actual simulation. iterNum specifies the number of iterations starting from each state
void simulateJumpsAbstract::runSimulation(int iterNum)
{
	init();
	for (int state = 0; state < _alphabetSize; ++state)
	{
		for (int iter = 0; iter < iterNum; ++iter)
		{
			runOneIter(state);
		}
	}
	
	computeExpectationsAndPosterior();	
}

//////////////////////////////////////////////////////////
//combined two characters into a combined state.
//For example. if the alphabet is {0,1,2} then the combined alphabet will be {0,1...8}.
//The states (terminalStart, terminalEnd) = (0,2) then combinedId = 2.
//The states (terminalStart, terminalEnd) = (1,2) then combinedId = 5. etc.
int simulateJumpsAbstract::getCombinedState(int terminalStart, int terminalEnd) const
{
	return (terminalStart * _alphabetSize + terminalEnd);
}
int simulateJumpsAbstract::getStartId(int combinedState) const
{
	return combinedState / _alphabetSize;
}
int simulateJumpsAbstract::getEndId(int combinedState) const
{
	return combinedState % _alphabetSize;
}
//////////////////////////////////////////////////////////