23 #define PARDISTTYPE "DistanceType"
24 #define PARPOINTQNT "NearestPoints"
25 #define PARDIST "MaxDistance"
26 #define PARDISTMIN 0.0
27 #define PARDISTMAX 1.0
29 #define LOG_SQRT_PI 0.5723649429247000870717135
30 #define I_SQRT_PI 0.5641895835477562869480795
32 #define ex(x) (((x) < -BIGX) ? 0.0 : exp (x))
40 "Metric used to calculate distances: "
45 "Metric used to calculate distances: "
58 "Nearest \'n\' points",
60 "Nearest \'n\' points whose mean value will be the reference when calculating environmental distances.",
61 "Nearest \'n\' points whose mean value will be the reference when calculating environmental distances. When set to 1, distances will be measured to the closest point, which is the same behavior of the previously existing minimum distance algorithm. When set to 0, distances will be measured to the average of all presence points, which is the same behavior of the previously existing distance to average algorithm. Intermediate values between 1 and the total number of presence points are now accepted.",
72 "Maximum distance to the reference in the environmental space.",
73 "Maximum distance to the reference in the environmental space, above which the conditions will be considered unsuitable for presence. Since 1 corresponds to the biggest possible distance between any two points in the environment space, setting the maximum distance to this value means that all points in the environmental space will have an associated probability. The probability of presence for points that fall within the range of the maximum distance is inversely proportional to the distance to the reference point (linear decay). The only exception is when the maximum distance is 1 and the metric is Mahalanobis, which will produce probabilities following the chi-square distribution.",
84 "Environmental Distance",
86 "Generic algorithm based on environmental dissimilarity metrics.",
87 "Generic algorithm based on environmental dissimilarity metrics. When used with the Gower metric and maximum distance 1, this algorithm should produce the same result of the algorithm known as DOMAIN.",
88 "Mauro E. S. Muņoz, Renato De Giovanni, Danilo J. S. Bellini",
89 "Carpenter G, Gillison AN, Winter J (1993) DOMAIN: A flexible modeling procedure for mapping potential distributions of animals and plants. Biodiversity and Conservation 2: 667-680. Farber O & Kadmon R 2003. Assessment of alternative approaches for bioclimatic modeling with special emphasis on the Mahalanobis distance. Ecological Modelling 160: 115-130.",
90 "Danilo J. S. Bellini, Renato De Giovanni",
91 "danilo . estagio [at] gmail . com, renato [at] cria . org . br",
215 Log::instance()->
error(
"Could not determine maximum distance in the environmental space.\n");
241 if((distIterator < dist || dist < 0)){
250 Scalar distIterator, distTmp;
251 int indexIterator, indexTmp;
270 if(nPdist[j] > distIterator){
271 distTmp = distIterator;
272 indexTmp = indexIterator;
273 distIterator = nPdist[j];
274 indexIterator = nearestIndex[j];
276 nearestIndex[j] = indexTmp;
320 (*_cov_matrix)(i,j) = 0;
324 (*_cov_matrix)(i,j) /= _presence_count;
332 (*_cov_matrix)(i,j) = (i == j) ? 1 : 0;
339 (*_cov_matrix_inv) = !(*_cov_matrix);
341 catch ( std::exception& e ) {
342 string msg = e.what();
343 msg.append(
"\nExperiment has no solution using Mahalanobis distance.\n" );
363 lineMatrix(0,i) = x[i] - y[i];
365 dist = (lineMatrix * (*_cov_matrix_inv) * (~lineMatrix))(0,0);
433 bool foundDist =
false;
437 if((i & (1<<k)) != 0){
445 if(distIterator > distMax){
446 distMax = distIterator;
494 if (y >= (
Z_MAX * 0.5))
498 x = ((((((((0.000124818987 * w
499 -0.001075204047) * w +0.005198775019) * w
500 -0.019198292004) * w +0.059054035642) * w
501 -0.151968751364) * w +0.319152932694) * w
502 -0.531923007300) * w +0.797884560593) * y * 2.0;
506 x = (((((((((((((-0.000045255659 * y
507 +0.000152529290) * y -0.000019538132) * y
508 -0.000676904986) * y +0.001390604284) * y
509 -0.000794620820) * y -0.002034254874) * y
510 +0.006549791214) * y -0.010557625006) * y
511 +0.011630447319) * y -0.009279453341) * y
512 +0.005353579108) * y -0.002141268741) * y
513 +0.000535310849) * y +0.999936657524;
516 return (z > 0.0 ? ((x + 1.0) * 0.5) : ((1.0 - x) * 0.5));
523 if (x <= 0.0 || df < 1)
526 even = (2*(df/2)) == df;
529 s = (even ? y : (2.0 *
_poz(-sqrt (x))));
531 x = 0.5 * (df - 1.0);
532 z = (even ? 1.0 : 0.5);
544 e = (even ? 1.0 : (
I_SQRT_PI / sqrt(a)));
563 config->addSubsection(model_config);
564 model_config->addNameValue(
"MaxDistance",
_par_dist);
566 model_config->addSubsection(envpoints_config);
569 envpoints_config->addSubsection(point_config);
579 if (!model_config)
return;
601 _par_dist = model_config->getAttributeAsDouble(
"MaxDistance", 0.0);
603 ConstConfigurationPtr envpoints_config = model_config->getSubsection(
"EnvironmentalReferences",
false);
605 Configuration::subsection_list::iterator begin = subs.begin();
606 Configuration::subsection_list::iterator end = subs.end();
607 for (; begin != end; ++begin) {
608 if ((*begin)->getName() !=
"Reference")
continue;
609 Sample point = (*begin)->getAttributeAsSample(
"Value");
void warn(const char *format,...)
'Warn' level.
std::vector< ConfigurationPtr > subsection_list
double Scalar
Type of map values.
Scalar _pochisq(Scalar x, int df) const
#define AMOUNT_DISTANCE_TYPES
OM_ALG_DLL_EXPORT AlgMetadata const * algorithmMetadata()
bool _init_distance_type()
static Log * instance()
Returns the instance pointer, creating the object on the first call.
static AlgMetadata metadata
Scalar _poz(Scalar z) const
void error(const char *format,...)
'Error' level.
int getParameter(std::string const &name, std::string *value)
OM_ALG_DLL_EXPORT AlgorithmImpl * algorithmFactory()
void _calc_covariance_matrix()
void resize(std::size_t size)
#define FIRST_DISTANCE_TYPE
static AlgParamMetadata parameters[NUM_PARAM]
virtual void _setConfiguration(const ConstConfigurationPtr &)
std::vector< Sample > _presence_points
Scalar _distance(const Sample &x, const Sample &y) const
void info(const char *format,...)
'Info' level.
void debug(const char *format,...)
'Debug' level.
Normalizer * _normalizerPtr
virtual void _getConfiguration(ConfigurationPtr &) const
Scalar getValue(const Sample &x) const