32 #include "../../common/Exception.h" 33 #include "../../core/translator/Translator.h" 34 #include "../../common/progress/TaskProgress.h" 35 #include "../../dataaccess/datasource/DataSource.h" 36 #include "../../dataaccess/datasource/DataSourceManager.h" 37 #include "../../dataaccess/utils/Utils.h" 38 #include "../../datatype/SimpleProperty.h" 39 #include "../../geometry/Geometry.h" 40 #include "../../geometry/GeometryProperty.h" 41 #include "../../memory/DataSet.h" 42 #include "../../memory/DataSetItem.h" 64 std::size_t eventIdx = outDsType->getPropertyPosition(
m_inputParams->m_eventAttrName);
65 std::size_t popIdx = outDsType->getPropertyPosition(
m_inputParams->m_populationAttrName);
85 std::map<std::string, std::string> options;
97 std::vector<te::dt::Property*> propertyVec = dsType->
getProperties();
99 for(std::size_t t = 0; t < propertyVec.size(); ++t)
107 dataSetType->add(newProp);
112 dataSetType->add(bayesProperty);
130 for(std::size_t t = 0; t < nProp; ++t)
141 outDataset->add(outDSetItem);
149 std::vector<double> eventVecY;
150 std::vector<double> popVecN;
151 std::vector<double> rateVec;
153 double sumEventY = 0.;
169 double eventAttr = ds->
getDouble(eventIdx);
170 eventVecY.push_back(eventAttr);
173 popVecN.push_back(popAttr);
178 rateVec.push_back(eventVecY[count-1] / popVecN[count-1]);
180 sumEventY += eventVecY[count-1];
181 sumPopN += popVecN[count-1];
192 double mean = sumEventY / sumPopN;
194 double meanPop = sumPopN / (double)count;
196 double variance = 0.;
198 for(
int i = 0; i < count; ++i)
200 variance += popVecN[i] * pow((rateVec[i] - mean), 2);
205 double aux = variance - (mean / meanPop);
222 double eventAttr = ds->
getDouble(eventIdx);
227 if(aux != 0. || mean != 0.)
228 wI = aux / (aux + (mean / popAttr));
230 double thetaI = wI * (eventAttr / popAttr) + ( 1 - wI) * mean;
std::size_t size() const
It returns the collection size, if it is known.
Class that represents the Bayes output parameters.
void setMessage(const std::string &message)
Set the task message.
void setDouble(std::size_t i, double value)
It sets the value of the i-th property.
An atomic property like an integer or double.
std::unique_ptr< te::mem::DataSet > createDataSet(te::da::DataSet *inputDataSet, te::da::DataSetType *dsType)
A class that models the description of a dataset.
This class can be used to inform the progress of a task.
void setValue(std::size_t i, te::dt::AbstractData *value)
It sets the value of the i-th property.
void execute()
Function to execute the bayes operation.
static te::dt::Date ds(2010, 01, 01)
#define TE_TR(message)
It marks a string in order to get translated.
virtual Property * clone() const =0
It returns a clone of the object.
This file contains a class that represents the bayes global operation.
It models a property definition.
bool isActive() const
Verify if the task is active.
void setTotalSteps(int value)
Set the task total stepes.
void setId(unsigned int id)
It sets the property identifier.
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
void saveDataSet(te::da::DataSet *dataSet, te::da::DataSetType *dsType)
#define TE_SA_BAYES_ATTR_NAME
const std::vector< Property * > & getProperties() const
It returns the list of properties describing the CompositeProperty.
~BayesGlobalOperation()
Virtual destructor.
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
A base class for values that can be retrieved from the data access module.
Utility functions for the data access module.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
bool moveBeforeFirst()
It moves the internal pointer to a position before the first item in the collection.
bool moveNext()
It moves the internal pointer to the next item of the collection.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
A dataset is the unit of information manipulated by the data access module of TerraLib.
double getDouble(std::size_t i) const
Method for retrieving a double attribute value.
virtual std::unique_ptr< te::dt::AbstractData > getValue(std::size_t i) const
Method for retrieving any other type of data value stored in the data source.
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection.
BayesGlobalOperation()
Default constructor.
void setParameters(te::sa::BayesInputParams *inParams, te::sa::BayesOutputParams *outParams)
void runBayesGlobal(te::mem::DataSet *ds, std::size_t eventIdx, std::size_t popIdx, std::size_t bayesIdx)
std::unique_ptr< te::da::DataSetType > createDataSetType(te::da::DataSetType *dsType)
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
std::unique_ptr< te::sa::BayesOutputParams > m_outputParams
Attribute with the bayes output parameters.
std::unique_ptr< te::sa::BayesInputParams > m_inputParams
Attribute with the bayes input parameters.
void setDouble(std::size_t i, double value)
void setParent(Property *p)
It associate this property to the informed parent.