41 #define PI 3.141592653589793238462643
49 #define BACKGROUND_ID "NumberOfBackgroundPoints"
50 #define USE_ABSENCES_ID "UseAbsencesAsBackground"
51 #define THRESHOLD_ID "SuitabilityThreshold"
52 #define STD_FACTOR_ID "StandardDeviationFactor"
62 "Number of background points",
64 "Number of background points to be generated.",
65 "Number of background points to be generated, which will be used to estimate the standard deviation of each variable in the area of interest.",
75 " Use absence points as background",
77 " Use absence points as background",
78 "When absence points are provided, this parameter can be used to instruct the algorithm to use them as background points. This would prevent the algorithm to randomly generate them, also facilitating comparisons between different algorithms.",
88 "Suitability threshold",
90 "Suitability threshold to get a binary niche.",
91 "Suitability threshold to get a binary niche. Use 1 if you want to keep the continuous niche.",
101 "Standard deviation factor",
103 "Standard deviation factor.",
104 "Factor (x) used to control the minimum limit of the random standard deviation for each variable. The random standard deviation will be a value between [x*S, S], where S is the standard deviation of the entire native region. Increase the factor to get larger niches, especially when using many environmental variables.",
119 "Virtual Niche Generator",
123 "Algorithm used to create virtual niches using the\
124 first presence point as a reference for optimum\
125 environmental conditions. The niche is represented by\
126 a multivariate Gaussian distribution with the mean value\
127 based on the optimum conditions and a random standard\
128 deviation smaller than the standard deviation of the\
129 region of interest. Suitability is calculated by assuming\
130 independence between all variables.",
132 "Algorithm used to create virtual niches using the\
133 first presence point as a reference for optimum\
134 environmental conditions. The niche is represented by\
135 a multivariate Gaussian distribution with the mean value\
136 based on the optimum conditions and a random standard\
137 deviation. Suitability is calculated by assuming\
138 independence between all variables, i.e., the final\
139 value is the product of the individual suitability\
140 for each variable. Individual suitabilities are\
141 calculated as the result of the Gaussian probability\
142 density function scaled by a factor to make the\
143 optimum condition correspond to 1. Standard deviations\
144 for each variable are randomly chosen within the range\
145 [x*S, S], where S is the standard deviation of the entire\
146 native region (calculated based on the background\
147 points) and x is the standard deviation factor parameter\
150 "Renato De Giovanni",
153 "renato [at] cria.org.br",
155 "Renato De Giovanni",
156 "renato [at] cria.org.br",
217 Log::instance()->
warn(
"This algorithm creates virtual niches - do not use it to generate models for real species!\n" );
225 if (
_samp->numPresence() > 1 ) {
227 Log::instance()->
warn(
"Virtual Niche uses only one point (the first). All other points will be ignored.\n" );
231 bool use_absences_as_background =
false;
233 int num_absences = 0;
236 use_absences_as_background =
true;
239 if ( use_absences_as_background ) {
241 num_absences =
_samp->numAbsence();
243 if ( num_absences ) {
249 Log::instance()->
warn(
"No absence points provided. Generating 10000 background points.\n" );
273 if ( use_absences_as_background && num_absences >=0 ) {
335 while ( oc != end ) {
337 Sample tmp( (*oc)->environment() );
338 background_mean += tmp;
347 while ( oc != end ) {
349 Sample tmp( (*oc)->environment() );
350 tmp -= background_mean;
352 background_std += tmp;
359 background_std /= npts;
360 background_std.
sqrt();
368 for (
int i = 0; i <
_samp->numIndependent(); ++i) {
406 for (
unsigned int i=0; i < x.
size(); i++) {
410 suitability *= pdf_value*
_scale[i];
415 return (suitability <
_threshold) ? 0.0 : 1.0;
441 config->addSubsection( model_config );
443 model_config->addNameValue(
"Minimum" ,
_minimum );
444 model_config->addNameValue(
"Maximum" ,
_maximum );
445 model_config->addNameValue(
"Mean" ,
_mean );
446 model_config->addNameValue(
"Std" ,
_std );
447 model_config->addNameValue(
"Scale" ,
_scale );
448 model_config->addNameValue(
"Threshold",
_threshold );
461 _minimum = model_config->getAttributeAsSample(
"Minimum" );
462 _maximum = model_config->getAttributeAsSample(
"Maximum" );
463 _mean = model_config->getAttributeAsSample(
"Mean" );
464 _std = model_config->getAttributeAsSample(
"Std" );
465 _scale = model_config->getAttributeAsSample(
"Scale" );
466 _threshold = model_config->getAttributeAsDouble(
"Threshold", 1.0 );
494 return (1.0/(std*sqrt(2.0*
PI)))*exp(-0.5*pow((val-mean)/std, 2));
Scalar getValue(const Sample &x) const
void warn(const char *format,...)
'Warn' level.
OM_ALG_DLL_EXPORT AlgMetadata const * algorithmMetadata()
int getConvergence(Scalar *const val) const
Scalar _std_factor
Threshold to get a binary niche.
double Scalar
Type of map values.
static Log * instance()
Returns the instance pointer, creating the object on the first call.
Sample _std
Average for the normal distribution.
Sample _mean
Maximum value for each variable.
virtual void _setConfiguration(const ConstConfigurationPtr &)
Scalar _threshold
Factors to multiply the PDF values.
Sample _maximum
Mininum value for each variable.
int getParameter(std::string const &name, std::string *value)
static AlgParamMetadata parameters[NUM_PARAM]
OccurrencesPtr _background
true if the algorithm is finished.
virtual void _getConfiguration(ConfigurationPtr &) const
OM_ALG_DLL_EXPORT AlgorithmImpl * algorithmFactory()
Sample _scale
Standard deviation for the normal distribution.
void info(const char *format,...)
'Info' level.
Scalar pdf(Scalar avg, Scalar std, Scalar val) const
std::vector< OccurrencePtr >::const_iterator const_iterator
static AlgMetadata metadata