openModeller
Version 1.5.0
|
#include <Sampler.hh>
Public Member Functions | |
SamplerImpl () | |
SamplerImpl (const EnvironmentPtr &env, const OccurrencesPtr &presences, const OccurrencesPtr &absence, bool isNormalized=false) | |
~SamplerImpl () | |
EnvironmentPtr | getEnvironment () |
ConstEnvironmentPtr | getEnvironment () const |
OccurrencesPtr | getPresences () |
ConstOccurrencesPtr | getPresences () const |
OccurrencesPtr | getAbsences () |
ConstOccurrencesPtr | getAbsences () const |
void | getMinMax (Sample *min, Sample *max) const |
void | normalize (Normalizer *normalizerPtr) |
bool | isNormalized () const |
void | resetNormalization () |
int | numIndependent () const |
int | numDependent () const |
int | numPresence () const |
int | numAbsence () const |
ConstOccurrencePtr | getOneSample () const |
ConstOccurrencePtr | getPresence () const |
ConstOccurrencePtr | getPresence (int index) const |
ConstOccurrencePtr | getAbsence () const |
ConstOccurrencePtr | getAbsence (int index) const |
OccurrencePtr | generateRandomSample (Scalar abundance=1.0) const |
OccurrencePtr | getPseudoAbsence () const |
OccurrencePtr | getPseudoPresence () const |
OccurrencePtr | getPseudoAbsence (const Model &model, const Scalar threshold) const |
OccurrencePtr | getPseudoPresence (const Model &model, const Scalar threshold) const |
OccurrencePtr | getPseudoAbsenceOutsideInterval (const Sample *minimum, const Sample *maximum) const |
OccurrencePtr | getPseudoPresenceInsideInterval (const Sample *minimum, const Sample *maximum) const |
OccurrencesPtr | getPseudoAbsences (const int &numPoints, const Model &model, const Scalar threshold=0.5, const bool geoUnique=false, const bool envUnique=false, const int idSequenceStart=1) const |
OccurrencesPtr | getPseudoPresences (const int &numPoints, const Model &model, const Scalar threshold=0.5, const bool geoUnique=false, const bool envUnique=false, const int idSequenceStart=1) const |
OccurrencesPtr | getPseudoAbsences (const int &numPoints, const Sample *minimum, const Sample *maximum, const bool geoUnique=false, const bool envUnique=false, const int idSequenceStart=1) const |
OccurrencesPtr | getPseudoPresences (const int &numPoints, const Sample *minimum, const Sample *maximum, const bool geoUnique=false, const bool envUnique=false, const int idSequenceStart=1) const |
int | isCategorical (int i) |
void | environmentallyUnique () |
bool | isEnvironmentallyUnique (const OccurrencesPtr &occurrences, const OccurrencePtr &point) const |
void | spatiallyUnique () |
bool | isSpatiallyUnique (const OccurrencesPtr &occurrences, const OccurrencePtr &point) const |
ConfigurationPtr | getConfiguration () const |
void | setConfiguration (const ConstConfigurationPtr &) |
void | dump () const |
Public Member Functions inherited from Configurable | |
virtual | ~Configurable () |
Public Member Functions inherited from Normalizable | |
virtual | ~Normalizable () |
Private Member Functions | |
ConstOccurrencePtr | getRandomOccurrence (const OccurrencesPtr &occur) const |
void | setEnvironmentInOccurrences () |
void | environmentallyUnique (OccurrencesPtr &occurrencesPtr, const char *type) |
void | spatiallyUnique (OccurrencesPtr &occurrencesPtr, const char *type) |
Private Member Functions inherited from ReferenceCountedObject | |
ReferenceCountedObject () | |
virtual | ~ReferenceCountedObject ()=0 |
Private Attributes | |
OccurrencesPtr | _presence |
OccurrencesPtr | _absence |
EnvironmentPtr | _env |
bool | _normalized |
Friends | |
class | ReferenceCountedPointer< SamplerImpl > |
class | ReferenceCountedPointer< const SamplerImpl > |
Base class to create samplers of environmental variables and occurrence data. Each derived class can implement different behaviors, such as proportional sampling according to the distribution of occurrence data, disproportional sampling regarding presence and absence data, etc.
Definition at line 81 of file Sampler.hh.
SamplerImpl::SamplerImpl | ( | ) |
Definition at line 69 of file Sampler.cpp.
References Log::debug(), and Log::instance().
SamplerImpl::SamplerImpl | ( | const EnvironmentPtr & | env, |
const OccurrencesPtr & | presences, | ||
const OccurrencesPtr & | absence, | ||
bool | isNormalized = false |
||
) |
Definition at line 81 of file Sampler.cpp.
References Log::debug(), Log::instance(), and setEnvironmentInOccurrences().
SamplerImpl::~SamplerImpl | ( | ) |
Definition at line 100 of file Sampler.cpp.
References Log::debug(), and Log::instance().
void SamplerImpl::dump | ( | ) | const |
Definition at line 1156 of file Sampler.cpp.
void SamplerImpl::environmentallyUnique | ( | ) |
Remove sample duplicates accross the environment (presences and absences are treated separately). After erasing a point, the remaining one increases the abundance by one.
Definition at line 927 of file Sampler.cpp.
References _absence, _presence, Log::info(), and Log::instance().
|
private |
Definition at line 942 of file Sampler.cpp.
References _env, Sample::equals(), Log::info(), and Log::instance().
OccurrencePtr SamplerImpl::generateRandomSample | ( | Scalar | abundance = 1.0 | ) | const |
Generate a random sample
Definition at line 387 of file Sampler.cpp.
References _env, Log::error(), Log::instance(), and numDependent().
Referenced by getPseudoAbsence(), and getPseudoPresence().
|
inline |
|
inline |
Get a specific absence point by index
Definition at line 168 of file Sampler.hh.
|
inline |
Definition at line 101 of file Sampler.hh.
|
inline |
Definition at line 102 of file Sampler.hh.
|
virtual |
Implements Configurable.
Definition at line 127 of file Sampler.cpp.
|
inline |
Definition at line 95 of file Sampler.hh.
|
inline |
Definition at line 96 of file Sampler.hh.
Indicate that all non categorical variable layers must be normalized according to the interval [min, max]. Returns through offsets, scales the normalization parameters.
Implements Normalizable.
Definition at line 209 of file Sampler.cpp.
ConstOccurrencePtr SamplerImpl::getOneSample | ( | ) | const |
Samples one presence, absence or pseudo-absence point in a uniform way. There is 50% of chance to get a presence point and 50% of get an absence or pseudo-absence point. If there are real absence points (user input) then only absences are sampled. If there are not real absence, samples pseudo-absence points.
Definition at line 346 of file Sampler.cpp.
References _absence, _presence, Log::error(), getAbsence(), getPresence(), getPseudoAbsence(), and Log::instance().
|
inline |
Get a random presence point
Definition at line 150 of file Sampler.hh.
Referenced by getOneSample().
|
inline |
Get a specific presence point by index
Definition at line 156 of file Sampler.hh.
|
inline |
Definition at line 98 of file Sampler.hh.
|
inline |
Definition at line 99 of file Sampler.hh.
OccurrencePtr SamplerImpl::getPseudoAbsence | ( | ) | const |
Generate a pseudo absence sample
Definition at line 412 of file Sampler.cpp.
References generateRandomSample().
Referenced by getOneSample(), getPseudoAbsence(), getPseudoAbsenceOutsideInterval(), and getPseudoAbsences().
OccurrencePtr SamplerImpl::getPseudoAbsence | ( | const Model & | model, |
const Scalar | threshold | ||
) | const |
Generate a pseudo absence sample outside the given model
Definition at line 428 of file Sampler.cpp.
References Log::error(), getPseudoAbsence(), and Log::instance().
OccurrencePtr SamplerImpl::getPseudoAbsenceOutsideInterval | ( | const Sample * | minimum, |
const Sample * | maximum | ||
) | const |
Generate a pseudo absence sample outside the minimum and maximum
Definition at line 504 of file Sampler.cpp.
References Log::error(), getPseudoAbsence(), Log::instance(), and Sample::size().
Referenced by getPseudoAbsences().
OccurrencesPtr SamplerImpl::getPseudoAbsences | ( | const int & | numPoints, |
const Model & | model, | ||
const Scalar | threshold = 0.5 , |
||
const bool | geoUnique = false , |
||
const bool | envUnique = false , |
||
const int | idSequenceStart = 1 |
||
) | const |
Generate pseudo absence samples outside the given model according to the specified threshold
Definition at line 598 of file Sampler.cpp.
References _absence, _presence, getPseudoAbsence(), isEnvironmentallyUnique(), and isSpatiallyUnique().
OccurrencesPtr SamplerImpl::getPseudoAbsences | ( | const int & | numPoints, |
const Sample * | minimum, | ||
const Sample * | maximum, | ||
const bool | geoUnique = false , |
||
const bool | envUnique = false , |
||
const int | idSequenceStart = 1 |
||
) | const |
Generate pseudo absence samples outside the minimum and maximum
Definition at line 760 of file Sampler.cpp.
References _absence, _presence, getPseudoAbsenceOutsideInterval(), isEnvironmentallyUnique(), and isSpatiallyUnique().
OccurrencePtr SamplerImpl::getPseudoPresence | ( | ) | const |
Generate a pseudo presence sample
Definition at line 420 of file Sampler.cpp.
References generateRandomSample().
Referenced by getPseudoPresence(), getPseudoPresenceInsideInterval(), and getPseudoPresences().
OccurrencePtr SamplerImpl::getPseudoPresence | ( | const Model & | model, |
const Scalar | threshold | ||
) | const |
Generate a pseudo presence sample inside the given model
Definition at line 466 of file Sampler.cpp.
References Log::error(), getPseudoPresence(), and Log::instance().
OccurrencePtr SamplerImpl::getPseudoPresenceInsideInterval | ( | const Sample * | minimum, |
const Sample * | maximum | ||
) | const |
Generate a pseudo presence sample inside the minimum and maximum
Definition at line 551 of file Sampler.cpp.
References Log::error(), getPseudoPresence(), Log::instance(), and Sample::size().
Referenced by getPseudoPresences().
OccurrencesPtr SamplerImpl::getPseudoPresences | ( | const int & | numPoints, |
const Model & | model, | ||
const Scalar | threshold = 0.5 , |
||
const bool | geoUnique = false , |
||
const bool | envUnique = false , |
||
const int | idSequenceStart = 1 |
||
) | const |
Generate pseudo presence samples inside the given model according to the specified threshold
Definition at line 679 of file Sampler.cpp.
References _absence, _presence, getPseudoPresence(), isEnvironmentallyUnique(), and isSpatiallyUnique().
OccurrencesPtr SamplerImpl::getPseudoPresences | ( | const int & | numPoints, |
const Sample * | minimum, | ||
const Sample * | maximum, | ||
const bool | geoUnique = false , |
||
const bool | envUnique = false , |
||
const int | idSequenceStart = 1 |
||
) | const |
Generate pseudo presence samples inside the minimum and maximum
Definition at line 834 of file Sampler.cpp.
References _absence, _presence, getPseudoPresenceInsideInterval(), isEnvironmentallyUnique(), and isSpatiallyUnique().
|
private |
Definition at line 1141 of file Sampler.cpp.
int SamplerImpl::isCategorical | ( | int | i | ) |
Returns 1 if i-th variable is categorical, otherwise returns 0.
Definition at line 908 of file Sampler.cpp.
References _env.
bool SamplerImpl::isEnvironmentallyUnique | ( | const OccurrencesPtr & | occurrences, |
const OccurrencePtr & | point | ||
) | const |
If OccurrencePtr point duplicates accross the environment, return false. Otherwise return true. Missae(set/2008)
Definition at line 1065 of file Sampler.cpp.
References _env, and Sample::equals().
Referenced by getPseudoAbsences(), and getPseudoPresences().
|
inline |
Returns true if "normalized()" was called, false otherwise.
Definition at line 115 of file Sampler.hh.
bool SamplerImpl::isSpatiallyUnique | ( | const OccurrencesPtr & | occurrences, |
const OccurrencePtr & | point | ||
) | const |
If OccurrencePtr point duplicates accross geographic space, return false. Otherwise return true. Uniqueness is considered for row/col pairs defined in the input mask. If mask is undefined, use first layer as a mask. Missae(set/2008)
Definition at line 1097 of file Sampler.cpp.
References _env, and Map::getRowColumn().
Referenced by getPseudoAbsences(), and getPseudoPresences().
|
virtual |
Normalize sampler data
Implements Normalizable.
Definition at line 233 of file Sampler.cpp.
References _absence, _env, _normalized, _presence, Log::error(), Log::instance(), and setEnvironmentInOccurrences().
int SamplerImpl::numAbsence | ( | ) | const |
Number of absences (localities with no occurrence).
Definition at line 337 of file Sampler.cpp.
References _absence.
int SamplerImpl::numDependent | ( | ) | const |
Number of dependent variables (attributes of the occurred thing). These are the variables to be modelled.
Definition at line 319 of file Sampler.cpp.
References _absence, and _presence.
Referenced by generateRandomSample().
int SamplerImpl::numIndependent | ( | ) | const |
Number of independent variables (environmental variables).
Definition at line 296 of file Sampler.cpp.
int SamplerImpl::numPresence | ( | ) | const |
Number of presences (occurrence points).
Definition at line 328 of file Sampler.cpp.
References _presence.
void SamplerImpl::resetNormalization | ( | ) |
Reset normalization
Definition at line 273 of file Sampler.cpp.
References _absence, _env, _normalized, and _presence.
|
virtual |
Implements Configurable.
Definition at line 156 of file Sampler.cpp.
References _absence, _env, _presence, createEnvironment(), Log::debug(), Log::error(), Log::instance(), and setEnvironmentInOccurrences().
|
private |
Definition at line 108 of file Sampler.cpp.
References _absence, _env, and _presence.
Referenced by normalize(), SamplerImpl(), and setConfiguration().
void SamplerImpl::spatiallyUnique | ( | ) |
Remove sample duplicates accross geographic space (presences and absences are treated separately). After erasing a point, the remaining one increases the abundance by one. Uniqueness is considered for row/col pairs defined in the input mask. If mask is undefined, use first layer as a mask.
Definition at line 990 of file Sampler.cpp.
References _absence, _presence, Log::info(), and Log::instance().
|
private |
Definition at line 1005 of file Sampler.cpp.
References _env, Map::getRowColumn(), Log::info(), and Log::instance().
|
friend |
Definition at line 84 of file Sampler.hh.
|
friend |
Definition at line 83 of file Sampler.hh.
|
private |
Definition at line 277 of file Sampler.hh.
Referenced by dump(), environmentallyUnique(), getConfiguration(), getMinMax(), getOneSample(), getPseudoAbsences(), getPseudoPresences(), normalize(), numAbsence(), numDependent(), numIndependent(), resetNormalization(), setConfiguration(), setEnvironmentInOccurrences(), and spatiallyUnique().
|
private |
Definition at line 278 of file Sampler.hh.
Referenced by environmentallyUnique(), generateRandomSample(), getConfiguration(), isCategorical(), isEnvironmentallyUnique(), isSpatiallyUnique(), normalize(), numIndependent(), resetNormalization(), setConfiguration(), setEnvironmentInOccurrences(), and spatiallyUnique().
|
private |
Definition at line 279 of file Sampler.hh.
Referenced by normalize(), and resetNormalization().
|
private |
Definition at line 276 of file Sampler.hh.
Referenced by dump(), environmentallyUnique(), getConfiguration(), getMinMax(), getOneSample(), getPseudoAbsences(), getPseudoPresences(), normalize(), numDependent(), numIndependent(), numPresence(), resetNormalization(), setConfiguration(), setEnvironmentInOccurrences(), and spatiallyUnique().