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

function GUIPopulateModelMatrix (ModelMatrixName&, EFV)
{
	if (modelType == 0)
	{
		ModelMatrixName = {{*,a,b,a}
						   {a,*,a,c}
						   {b,a,*,a}
						   {a,c,a,*}};
	}
	else
	{
		global			globalVariablePurTrst;
		global			globalVariablePyrTrst;
		if (modelType<2)
		{
			ModelMatrixName = 
						 {{*,a,globalVariablePurTrst*a,a}
						  {a,*,a,globalVariablePyrTrst*a}
						  {globalVariablePurTrst*a,a,*,a}
						  {a,globalVariablePyrTrst*a,a,*}};
		}
		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 = {{*,a*categoryVariable,globalVariablePurTrst*a*categoryVariable,a*categoryVariable}
							   {a*categoryVariable,*,a*categoryVariable,globalVariablePyrTrst*a*categoryVariable}
							   {globalVariablePurTrst*a*categoryVariable,a*categoryVariable,*,a*categoryVariable}
							   {a*categoryVariable,globalVariablePyrTrst*a*categoryVariable,a*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;
}
