Model_Name  		= "REV";
Model_Options 		= 7;
Model_Dimension 	= 4;
Model_EFV_Type		= "Observed In Partition";

function GUIPopulateModelMatrix (ModelMatrixName&, EFV)
{
	if (modelType == 0)
	{
		ModelMatrixName = {{*,a,b,c}
						   {a,*,d,e}
						   {b,d,*,f}
						   {c,e,f,*}};
	}
	else
	{
		global			globalVariableAC;
		global			globalVariableAT;
		global			globalVariableCG;
		global			globalVariableCT;
		global			globalVariableGT;
		
		if (modelType<2)
		{
	
			ModelMatrixName = {{*,globalVariableAC*mu,mu,globalVariableAT*mu}
							   {globalVariableAC*mu,*,globalVariableCG*mu,globalVariableCT*mu}
							   {mu,globalVariableCG*mu,*,globalVariableGT*mu}
							   {globalVariableAT*mu,globalVariableCT*mu,globalVariableGT*mu,*}};
		}
		else
		{
			global shapeParameter = .5;
			shapeParameter:>0.01;shapeParameter:<100;
			category     categoryVariable = 
						(rateClassCount, EQUAL, MEAN, GammaDist(_x_,shapeParameter,shapeParameter), CGammaDist(_x_,shapeParameter,shapeParameter), 0 , 
				  							1e25,CGammaDist(_x_,shapeParameter+1,shapeParameter));

			ModelMatrixName = {{*,globalVariableAC*mu*categoryVariable,mu*categoryVariable,globalVariableAT*mu*categoryVariable}
							   {globalVariableAC*mu*categoryVariable,*,globalVariableCG*mu*categoryVariable,globalVariableCT*mu*categoryVariable}
							   {mu*categoryVariable,globalVariableCG*mu*categoryVariable,*,globalVariableGT*mu*categoryVariable}
							   {globalVariableAT*mu*categoryVariable,globalVariableCT*mu*categoryVariable,globalVariableGT*mu*categoryVariable,*}};
		}
	}
	return 1;
}

/*-------------------------------------------------------------------------------*/

function	EFVEstimated	(EFVector&, EFVApproximations)
{
	global frequencyVariableA;
	global frequencyVariableC;
	global frequencyVariableG;
	global frequencyVariableT;
	global frequencyVariableSum;

	frequencyVariableA:<1;
	frequencyVariableC:<1;
	frequencyVariableG:<1;
	frequencyVariableT	 :=	Abs(1-frequencyVariableA-frequencyVariableC-frequencyVariableG);
	frequencyVariableSum := frequencyVariableA+frequencyVariableC+frequencyVariableG+frequencyVariableT;

	frequencyVariableA = EFVApproximations[0];
	frequencyVariableC = EFVApproximations[1];
	frequencyVariableG = EFVApproximations[2];

	EFVector = {{frequencyVariableA/frequencyVariableSum},
				{frequencyVariableC/frequencyVariableSum},
				{frequencyVariableG/frequencyVariableSum},
				{frequencyVariableT/frequencyVariableSum}};
				
	return	1;
}
