43 #include <Bpp/Numeric/NumConstants.h> 55 const NucleicAlphabet* alphabet,
bool allowNullFreqs,
59 addParameter_(
new Parameter(
62 &Parameter::PROP_CONSTRAINT_IN :
64 addParameter_(
new Parameter(
67 &Parameter::PROP_CONSTRAINT_IN :
69 addParameter_(
new Parameter(
"Full.theta2", 0.5,
71 &Parameter::PROP_CONSTRAINT_IN :
77 const NucleicAlphabet* alphabet,
double theta,
double theta1,
double theta2,
78 bool allowNullFreqs,
const string& name) :
81 addParameter_(
new Parameter(
85 &Parameter::PROP_CONSTRAINT_IN :
87 addParameter_(
new Parameter(
91 &Parameter::PROP_CONSTRAINT_IN :
93 addParameter_(
new Parameter(
97 &Parameter::PROP_CONSTRAINT_IN :
98 &Parameter::PROP_CONSTRAINT_EX));
102 getFreq_(3) = (1 - theta1) * (1. - theta);
107 if (frequencies.size() != 4)
throw DimensionException(
" FullNucleotideFrequenciesSet::setFrequencies", frequencies.size(), 4);
109 for (
unsigned int i = 0; i < 4; i++)
111 sum += frequencies[i];
113 if (fabs(1. - sum) > NumConstants::SMALL())
114 throw Exception(
"FullNucleotideFrequenciesSet::setFrequencies. Frequencies must equal 1 (sum = " + TextTools::toString(sum) +
").");
115 double theta = frequencies[1] + frequencies[2];
116 getParameter_(0).setValue(theta);
117 getParameter_(1).setValue(frequencies[0] / (1 - theta));
118 getParameter_(2).setValue(frequencies[2] / theta);
125 double theta = getParameter_(0).getValue();
126 double theta1 = getParameter_(1).getValue();
127 double theta2 = getParameter_(2).getValue();
128 getFreq_(0) = theta1 * (1. - theta);
131 getFreq_(3) = (1 - theta1) * (1. - theta);
139 if (frequencies.size() != 4)
throw DimensionException(
"GCFrequenciesSet::setFrequencies", frequencies.size(), 4);
141 for (
unsigned int i = 0; i < 4; i++)
143 sum += frequencies[i];
145 if (fabs(1. - sum) > NumConstants::SMALL())
146 throw Exception(
"GCFrequenciesSet::setFrequencies. Frequencies must equal 1 (sum = " + TextTools::toString(sum) +
").");
147 double theta = frequencies[1] + frequencies[2];
149 getParameter_(0).setValue(theta);
156 double theta = getParameter_(0).getValue();
void fireParameterChanged(const ParameterList ¶meters)
void fireParameterChanged(const ParameterList ¶meters)
This class implements a state map where all resolved states are modeled.
void setFrequencies_(const std::vector< double > &frequencies)
FullNucleotideFrequenciesSet(const NucleicAlphabet *alphabet, bool allowNullFreqs=false, const std::string &name="Full")
static IntervalConstraint FREQUENCE_CONSTRAINT_SMALL
double & getFreq_(size_t i)
void setFrequencies(const std::vector< double > &frequencies)
Set the parameters in order to match a given set of frequencies.
void setFrequencies(const std::vector< double > &frequencies)
Set the parameters in order to match a given set of frequencies.
Basic implementation of the FrequenciesSet interface.