![]() |
FIMS
v0.8.1
|
A collection of mathematical functions used in FIMS. More...
#include <cmath>#include <random>#include <sstream>#include "../interface/interface.hpp"#include "fims_vector.hpp"Go to the source code of this file.
Functions | |
| template<class Type > | |
| const Type | fims_math::logistic (const Type &inflection_point, const Type &slope, const Type &x) |
| The general logistic function. | |
| template<class Type > | |
| const Type | fims_math::logit (const Type &a, const Type &b, const Type &x) |
| A logit function for bounding of parameters. | |
| template<class Type > | |
| const Type | fims_math::inv_logit (const Type &a, const Type &b, const Type &logit_x) |
| An inverse logit function for bounding of parameters. | |
| template<class Type > | |
| const Type | fims_math::double_logistic (const Type &inflection_point_asc, const Type &slope_asc, const Type &inflection_point_desc, const Type &slope_desc, const Type &x) |
| The general double logistic function. | |
| template<class Type > | |
| const Type | fims_math::ad_fabs (const Type &x, Type C=1e-5) |
| template<typename Type > | |
| const Type | fims_math::ad_min (const Type &a, const Type &b, Type C=1e-5) |
| template<typename Type > | |
| const Type | fims_math::ad_max (const Type &a, const Type &b, Type C=1e-5) |
| template<class T > | |
| T | fims_math::sum (const std::vector< T > &v) |
| template<class T > | |
| T | fims_math::sum (const fims::Vector< T > &v) |
A collection of mathematical functions used in FIMS.
Used when x could evaluate to zero, which will result in a NaN for derivative values.
Evaluates:
\( (x^2+C)^.5 \)
| x | value to keep positive |
| C | default = 1e-5 |
Returns the maximum between a and b in a continuous manner using:
(a + b + fims_math::ad_fabs(a - b)) *.5; Reference: fims_math::ad_fabs() This is an approximation with minimal error.
| a | |
| b | |
| C | default = 1e-5 |
Returns the minimum between a and b in a continuous manner using:
(a + b - fims_math::ad_fabs(a - b))*.5; Reference: fims_math::ad_fabs()
This is an approximation with minimal error.
| a | |
| b | |
| C | default = 1e-5 |
|
inline |
The general double logistic function.
\( \frac{1.0}{ 1.0 + exp(-1.0 * slope_{asc} (x - inflection_point_{asc}))} \left(1-\frac{1.0}{ 1.0 + exp(-1.0 * slope_{desc} (x - inflection_point_{desc}))} \right)\)
| inflection_point_asc | the inflection point of the ascending limb of the double logistic function |
| slope_asc | the slope of the ascending limb of the double logistic function |
| inflection_point_desc | the inflection point of the descending limb of the double logistic function, where inflection_point_desc > inflection_point_asc |
| slope_desc | the slope of the descending limb of the double logistic function |
| x | the index the logistic function should be evaluated at |
An inverse logit function for bounding of parameters.
\( a+\frac{b-a}{1+\mathrm{exp}(-\mathrm{logit}(x))}\)
| a | lower bound |
| b | upper bound |
| logit_x | the parameter in real space |
|
inline |
The general logistic function.
The logistic function can range from zero to one or one to zero, depending on the slope parameter, but it is not normalized to force values to reach those ranges.
\( \frac{1.0}{ 1.0 + exp(-1.0 * slope (x - inflection_point))} \)
| inflection_point | the inflection point of the logistic function |
| slope | the slope of the logistic function. A positive slope results in an ascending logistic curve (0 to 1), while a negative slope results in a descending logistic curve (1 to 0). |
| x | the index the logistic function should be evaluated at |
A logit function for bounding of parameters.
\( -\mathrm{log}(b-x) + \mathrm{log}(x-a) \)
| a | lower bound |
| b | upper bound |
| x | the parameter in bounded space |
Sum elements of a vector
| v | A vector of constants. |