bpp-core  2.2.0
bpp::IntervalTransformedParameter Class Reference

Parameter transformation from ] a, b [ to ]-inf, + inf [. More...

#include <Bpp/Numeric/TransformedParameter.h>

+ Inheritance diagram for bpp::IntervalTransformedParameter:
+ Collaboration diagram for bpp::IntervalTransformedParameter:

Public Member Functions

 IntervalTransformedParameter (const std::string &name, double value, double lowerBound=0, double upperBound=1, double scale=1, bool hyper=true)
 Build a new IntervalTransformedParameter, with given bounds and scale. More...
 
IntervalTransformedParameterclone () const
 Create a copy of this object and send a pointer to it. More...
 
void setOriginalValue (double value) throw (ConstraintException)
 Set the value of the parameter using the orignal coordinate system. More...
 
double getOriginalValue () const
 
double getFirstOrderDerivative () const throw (NotImplementedException)
 
double getSecondOrderDerivative () const throw (NotImplementedException)
 
virtual void setName (const std::string &name)
 Set the name of this parameter. More...
 
virtual void setValue (double value) throw (ConstraintException)
 Set the value of this parameter. More...
 
void setPrecision (double precision)
 Set the precision of this parameter. More...
 
virtual const std::string & getName () const
 Get the name of this parameter. More...
 
virtual double getValue () const
 Get the value of this parameter. More...
 
virtual double getPrecision () const
 Get the precision of this parameter. More...
 
virtual const ConstraintgetConstraint () const
 Return the constraint associated to this parameter if there is one. More...
 
virtual ConstraintgetConstraint ()
 Return the constraint associated to this parameter if there is one. More...
 
virtual bool hasConstraint () const
 Tells if this parameter has a constraint. More...
 
virtual const ConstraintremoveConstraint ()
 Remove the constraint associated to this parameter. More...
 
virtual void setConstraint (Constraint *constraint, bool attach=false)
 Set a constraint to this parameter. More...
 
virtual void addParameterListener (ParameterListener *listener, bool attachListener=true)
 Add a new listener to this parameter. More...
 
virtual void removeParameterListener (const std::string &listenerId)
 Remove all listeners with a given id from this parameter. More...
 
virtual bool hasParameterListener (const std::string &listenerId)
 Tell is there is a listener with a given id from this parameter. More...
 

Static Public Attributes

static const IntervalConstraint R_PLUS
 
static const IntervalConstraint R_PLUS_STAR
 
static const IntervalConstraint R_MINUS
 
static const IntervalConstraint R_MINUS_STAR
 
static const IntervalConstraint PROP_CONSTRAINT_IN
 
static const IntervalConstraint PROP_CONSTRAINT_EX
 

Protected Member Functions

void fireParameterNameChanged (ParameterEvent &event)
 
void fireParameterValueChanged (ParameterEvent &event)
 

Protected Attributes

std::string name_
 
double value_
 
double precision_
 
Constraintconstraint_
 
bool attach_
 
std::vector< ParameterListener * > listeners_
 
std::vector< bool > listenerAttach_
 

Private Attributes

double scale_
 
double lowerBound_
 
double upperBound_
 
bool hyper_
 
double tiny_
 

Detailed Description

Parameter transformation from ] a, b [ to ]-inf, + inf [.

The equation of the tranformation is

\[ x' = s\tan\left(\pi\frac{x-a}{b-a} - \frac{\pi}{2}\right) \]

The 'a' and 'b' parameters are the lower and upper bounds and 's' is a scaling factor set to 1 by default. If the hyperbolic option is set to true (the default), then the following transformation is used instead:

\[ x' = s\,\text{atanh}\left(2\frac{x-a}{b-a} - 1\right) \]

Definition at line 205 of file TransformedParameter.h.

Constructor & Destructor Documentation

◆ IntervalTransformedParameter()

bpp::IntervalTransformedParameter::IntervalTransformedParameter ( const std::string &  name,
double  value,
double  lowerBound = 0,
double  upperBound = 1,
double  scale = 1,
bool  hyper = true 
)
inline

Build a new IntervalTransformedParameter, with given bounds and scale.

Parameters
namethe name of the parameter.
valuethe value of th eparameter, in orginal coordinates.
lowerBoundthe inerval lower bound to use.
upperBoundthe inerval lower bound to use.
scalethe scaling factor.
hypertell if the hyberbolic function should be used (true by default).

Definition at line 226 of file TransformedParameter.h.

Member Function Documentation

◆ addParameterListener()

virtual void bpp::Parameter::addParameterListener ( ParameterListener listener,
bool  attachListener = true 
)
inlinevirtualinherited

Add a new listener to this parameter.

Parameters
listenerThe listener to add.
attachListenerTell if the parameter will own this listener. If so, deep copies will be made when cloning the parameter, and the listener will be destroyed upon destruction of the parameter or upon removal. Alternatively, only superficial copies will be made, and the listener will persist if the parameter is destroyed.

Definition at line 298 of file Parameter.h.

References bpp::Parameter::listenerAttach_, and bpp::Parameter::listeners_.

Referenced by bpp::AbstractParameterAliasable::aliasParameters().

◆ clone()

IntervalTransformedParameter* bpp::IntervalTransformedParameter::clone ( ) const
inlinevirtual

Create a copy of this object and send a pointer to it.

Returns
A pointer toward the copy object.

Implements bpp::TransformedParameter.

Definition at line 237 of file TransformedParameter.h.

◆ fireParameterNameChanged()

void bpp::Parameter::fireParameterNameChanged ( ParameterEvent event)
inlineprotectedinherited

Definition at line 320 of file Parameter.h.

References bpp::Parameter::listeners_.

Referenced by bpp::Parameter::setName().

◆ fireParameterValueChanged()

void bpp::Parameter::fireParameterValueChanged ( ParameterEvent event)
inlineprotectedinherited

Definition at line 325 of file Parameter.h.

References bpp::Parameter::listeners_.

◆ getConstraint() [1/2]

virtual const Constraint* bpp::Parameter::getConstraint ( ) const
inlinevirtualinherited

Return the constraint associated to this parameter if there is one.

Returns
A pointer toward the constraint, or NULL if there is no constraint.

Definition at line 255 of file Parameter.h.

References bpp::Parameter::constraint_.

Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::ReparametrizationFunctionWrapper::init_(), bpp::ParameterList::matchParametersValues(), bpp::ParameterList::setParametersValues(), and bpp::ParameterList::testParametersValues().

◆ getConstraint() [2/2]

virtual Constraint* bpp::Parameter::getConstraint ( )
inlinevirtualinherited

Return the constraint associated to this parameter if there is one.

Returns
A pointer toward the constraint, or NULL if there is no constraint.

Definition at line 262 of file Parameter.h.

References bpp::Parameter::constraint_.

◆ getFirstOrderDerivative()

double bpp::IntervalTransformedParameter::getFirstOrderDerivative ( ) const
throw (NotImplementedException
)
inlinevirtual
Returns
The first order derivative of the transformation at the original point.
Exceptions
NotImplementedExceptionif the transformation does not support derivation or if the derivation was not implemented.

Implements bpp::TransformedParameter.

Definition at line 258 of file TransformedParameter.h.

References bpp::Parameter::getValue(), and bpp::NumConstants::PI().

◆ getName()

◆ getOriginalValue()

double bpp::IntervalTransformedParameter::getOriginalValue ( ) const
inlinevirtual
Returns
The current value of the parameter in orignal coordinates.

Implements bpp::TransformedParameter.

Definition at line 248 of file TransformedParameter.h.

References bpp::Parameter::getValue(), and bpp::NumConstants::PI().

◆ getPrecision()

virtual double bpp::Parameter::getPrecision ( ) const
inlinevirtualinherited

Get the precision of this parameter.

Returns
The precision value.

Definition at line 248 of file Parameter.h.

References bpp::Parameter::precision_.

◆ getSecondOrderDerivative()

double bpp::IntervalTransformedParameter::getSecondOrderDerivative ( ) const
throw (NotImplementedException
)
inlinevirtual
Returns
The second order derivative of the transformation at the original point.
Exceptions
NotImplementedExceptionif the transformation does not support derivation or if the derivation was not implemented.

Implements bpp::TransformedParameter.

Definition at line 266 of file TransformedParameter.h.

References bpp::Parameter::getValue(), and bpp::NumConstants::PI().

◆ getValue()

◆ hasConstraint()

virtual bool bpp::Parameter::hasConstraint ( ) const
inlinevirtualinherited

Tells if this parameter has a constraint.

Returns
True if this parameter has a contraint.

Definition at line 269 of file Parameter.h.

References bpp::Parameter::constraint_.

Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::ParameterList::matchParametersValues(), bpp::ParameterList::setParametersValues(), and bpp::ParameterList::testParametersValues().

◆ hasParameterListener()

bool Parameter::hasParameterListener ( const std::string &  listenerId)
virtualinherited

Tell is there is a listener with a given id from this parameter.

Parameters
listenerIdThe id of listener to remove.
Returns
True if at list one listener with the given id was found.

Definition at line 187 of file Parameter.cpp.

References bpp::Parameter::listeners_.

◆ removeConstraint()

const Constraint * Parameter::removeConstraint ( )
virtualinherited

Remove the constraint associated to this parameter.

Warning! The contraint objet is not deleted.

Returns
A pointer toward the formerly used contraint.

Definition at line 163 of file Parameter.cpp.

References bpp::Parameter::constraint_.

Referenced by bpp::SimpleDiscreteDistribution::restrictToConstraint().

◆ removeParameterListener()

void Parameter::removeParameterListener ( const std::string &  listenerId)
virtualinherited

Remove all listeners with a given id from this parameter.

Parameters
listenerIdThe id of listener to remove.

Definition at line 172 of file Parameter.cpp.

References bpp::Parameter::listenerAttach_, and bpp::Parameter::listeners_.

◆ setConstraint()

void Parameter::setConstraint ( Constraint constraint,
bool  attach = false 
)
virtualinherited

Set a constraint to this parameter.

Parameters
constrainta pointer to the constraint (may be null)
attachsays if the constraint is attached to the Parameter (default: false).

Constraint:

Definition at line 143 of file Parameter.cpp.

References bpp::Parameter::attach_, bpp::Parameter::constraint_, bpp::Constraint::isCorrect(), and bpp::Parameter::value_.

Referenced by bpp::ConstantDistribution::restrictToConstraint(), bpp::TruncatedExponentialDiscreteDistribution::restrictToConstraint(), and bpp::SimpleDiscreteDistribution::restrictToConstraint().

◆ setName()

virtual void bpp::Parameter::setName ( const std::string &  name)
inlinevirtualinherited

◆ setOriginalValue()

void bpp::IntervalTransformedParameter::setOriginalValue ( double  value)
throw (ConstraintException
)
inlinevirtual

Set the value of the parameter using the orignal coordinate system.

Parameters
valueParameter value in original coordinates.
Exceptions
ConstraintExceptionif the value is not correct.

Implements bpp::TransformedParameter.

Definition at line 240 of file TransformedParameter.h.

References bpp::NumConstants::PI(), and bpp::Parameter::setValue().

◆ setPrecision()

void Parameter::setPrecision ( double  precision)
inherited

Set the precision of this parameter.

Parameters
precisionthe new parameter precision.

Precision:

Definition at line 136 of file Parameter.cpp.

References bpp::Parameter::precision_.

◆ setValue()

Member Data Documentation

◆ attach_

bool bpp::Parameter::attach_
protectedinherited

◆ constraint_

◆ hyper_

bool bpp::IntervalTransformedParameter::hyper_
private

Definition at line 212 of file TransformedParameter.h.

◆ listenerAttach_

std::vector<bool> bpp::Parameter::listenerAttach_
protectedinherited

◆ listeners_

◆ lowerBound_

double bpp::IntervalTransformedParameter::lowerBound_
private

Definition at line 210 of file TransformedParameter.h.

◆ name_

std::string bpp::Parameter::name_
protectedinherited

◆ precision_

double bpp::Parameter::precision_
protectedinherited

◆ PROP_CONSTRAINT_EX

const IntervalConstraint Parameter::PROP_CONSTRAINT_EX
staticinherited

◆ PROP_CONSTRAINT_IN

◆ R_MINUS

const IntervalConstraint Parameter::R_MINUS
staticinherited

Definition at line 334 of file Parameter.h.

◆ R_MINUS_STAR

const IntervalConstraint Parameter::R_MINUS_STAR
staticinherited

Definition at line 335 of file Parameter.h.

◆ R_PLUS

◆ R_PLUS_STAR

const IntervalConstraint Parameter::R_PLUS_STAR
staticinherited

◆ scale_

double bpp::IntervalTransformedParameter::scale_
private

Definition at line 209 of file TransformedParameter.h.

◆ tiny_

double bpp::IntervalTransformedParameter::tiny_
private

Definition at line 213 of file TransformedParameter.h.

◆ upperBound_

double bpp::IntervalTransformedParameter::upperBound_
private

Definition at line 211 of file TransformedParameter.h.

◆ value_

double bpp::Parameter::value_
protectedinherited

The documentation for this class was generated from the following file: