40 #ifndef _TRANSFORMEDPARAMETER_H_ 41 #define _TRANSFORMEDPARAMETER_H_ 135 RTransformedParameter(
const std::string& name,
double value,
double bound = 0,
bool positive =
true,
double scale = 1):
149 if (positive_ ? value <= bound_ : value >= bound_)
throw ConstraintException(
"RTransformedParameter::setValue",
this, value);
150 if (positive_ & (value < 1 + bound_))
setValue(log(scale_ * (value - bound_)));
151 if (positive_ & (value >= 1 + bound_))
setValue(scale_ * (value - 1. - bound_));
152 if (!positive_ & (value > -1 + bound_))
setValue(log(-scale_ * (value - bound_)));
153 if (!positive_ & (value <= -1 + bound_))
setValue(-scale_ * (value - 1. - bound_));
160 if(x < 0)
return exp(x) / scale_ + bound_;
161 else return x / scale_ + 1. + bound_;
163 if(x < 0)
return - exp(-x) / scale_ + bound_;
164 else return - x / scale_ - 1. + bound_;
171 if(x < 0)
return exp(x) / scale_;
172 else return 1. / scale_;
174 if(x < 0)
return exp(-x) / scale_;
175 else return - 1. / scale_;
182 if(x < 0)
return exp(x) / scale_;
185 if(x < 0)
return - exp(-x) / scale_;
226 IntervalTransformedParameter(
const std::string& name,
double value,
double lowerBound = 0,
double upperBound = 1,
double scale = 1,
bool hyper =
true):
228 scale * atanh(2. * (value - lowerBound) / (upperBound - lowerBound) - 1.) :
231 lowerBound_(lowerBound),
232 upperBound_(upperBound),
242 if (value <= lowerBound_ || value >= upperBound_)
throw ConstraintException(
"IntervalTransformedParameter::setValue",
this, value);
244 scale_ * atanh(2. * (value - lowerBound_) / (upperBound_ - lowerBound_) - 1.) :
252 (tanh(x / scale_) + 1.) * (upperBound_ - lowerBound_) / 2. + lowerBound_ :
262 1. / (pow(cosh(x / scale_), 2)) * (upperBound_ - lowerBound_) / (2. * scale_) :
263 (upperBound_ - lowerBound_) / (
NumConstants::PI() * scale_ * (pow(x / scale_, 2) + 1.));
270 - 1. / (pow(cosh(x / scale_), 2)) * tanh(x / scale_) * (upperBound_ - lowerBound_) / (scale_ * scale_) :
271 -2. * x * (upperBound_ - lowerBound_) / (
NumConstants::PI() * pow(scale_, 3) * pow((pow(x / scale_, 2) + 1.), 2));
311 #endif //_TRANSFORMEDPARAMETER_H_
this static class contains several useful constant values.
This class allows to perform a correspondence analysis.
This class is designed to facilitate the manipulation of parameters.
virtual void setValue(double value)
Set the value of this parameter.
This expeption is sent when a given method is not implemented.
virtual double getValue() const
Get the value of this parameter.
Exception thrown when a value do not match a given constraint.