openModeller  Version 1.5.0
PreChiSquare.hh
Go to the documentation of this file.
1 
28 #ifndef PRE_CHISQUARE_HH
29 #define PRE_CHISQUARE_HH
30 
31 #include "PreAlgorithm.hh"
32 
33 #include <openmodeller/om.hh>
35 #include <openmodeller/Sample.hh>
36 #include <openmodeller/Sampler.hh>
37 
38 #define classLimit 16
39 
40 /*
41  *
42  *
43  * input: SamplerPtr output: shows for each variable the amount of layers that
44  * maintain correlation at the significance level of 0.05
45  */
46 
47 class dllexp PreChiSquare : public PreAlgorithm
48 {
49  private:
50  size_t num_points; // number of points.
51  size_t num_layers; // number of layers.
52  size_t nclass; // number of class
53  Sample minimum; // Mininum value for each layer.
54  Sample delta; // delta value for each layer.
55  OccurrencesPtr my_presences; //occurrence points of species.
56  Scalar measured[classLimit][classLimit]; //measured points between two crossed layers.
57  Scalar expected [classLimit][classLimit]; //expected points between two crossed layers.
58  Scalar chicell [classLimit][classLimit]; //chi value for each cell formed between two class of the crossed layers.
59  std::vector< size_t > statistic1; //dependency between layers.
60  std::vector< size_t > statistic2; //dependency between layers.
61 
62  public:
63 
64  PreChiSquare(); //constructor
65  ~PreChiSquare(); //destructor
66 
67  //Return description about the algorithm
68  string getDescription() const { return "\
69 This technique is described in Li, L., et al. (2006). \"An Integrated\
70 Bayesian Modelling Approach for Predicting Mosquito Larval Habitats\". The \
71 authors tested the independence between all pairs of layers. Each pair is \
72 cross-referenced using a contingency matrix to detect the dependency between \
73 the layers based on a set of presence points from a particular species. \
74 The output shows for each layer the number of layers that maintain correlation \
75 with the significance level of 0.05."; }
76 
77  //Checks if the supplied parameters fits the requirements of PRE algorithm implementation.
78  //return true if the parameters are OK. false if not.
79  bool checkParameters( const PreParameters& parameters ) const;
80 
81  //Runs the current algorithm implementation.
82  //return true if OK. false on error.
83  bool runImplementation();
84 
85  //get input parameters
86  void getAcceptedParameters ( stringMap& info );
87 
88  //get output information
89  void getLayersetResultSpec ( stringMap& info);
90 
91  //get output information for each layer
92  void getLayerResultSpec ( stringMap& info);
93 
94  //initialize attributes: num_points, num_layers, nclass, minimum, delta, my_presences.
95  bool init();
96 
97  //get number of points.
98  size_t getNpoints();
99 
100  //set number of points.
101  void setNpoints();
102 
103  //get number of layers.
104  size_t getNlayers();
105 
106  //set number of layers.
107  void setNlayers(SamplerPtr samplerPtr);
108 
109  //set number of class.
110  size_t getNclass();
111 
112  //set number of class.
113  void setNclass();
114 
115  //set mininum value for each layer.
116  void setMinimum();
117 
118  //get minimum value of each layer.
119  Sample getMinimum();
120 
121  //set delta value for each layer.
122  void setDelta();
123 
124  //get delta value of each layer.
125  Sample getDelta();
126 
127  //set measured points for crossed layers.
128  void setMeasured(size_t layer1, size_t layer2);
129 
130  //set expected points for crossed layers.
131  void setExpected();
132 
133  //set chi value for each cell formed between two class of the crossed layers.
134  void setChicell();
135 
136  //count layer dependency.
137  void setStatistic(size_t layer1, size_t layer2);
138 
139  //control layers crossing.
140  void run();
141 
142  //set zero to all elements of the matrix "measured".
143  void setMeasuredZero();
144 
145 };
146 
147 
148 #endif
149 
virtual void getLayersetResultSpec(stringMap &info)=0
string getDescription() const
Definition: PreChiSquare.hh:68
double Scalar
Type of map values.
Definition: om_defs.hh:39
std::vector< size_t > statistic1
Definition: PreChiSquare.hh:59
size_t num_layers
Definition: PreChiSquare.hh:51
#define classLimit
Definition: PreChiSquare.hh:38
virtual bool runImplementation()=0
std::vector< size_t > statistic2
Definition: PreChiSquare.hh:60
size_t num_points
Definition: PreChiSquare.hh:50
OccurrencesPtr my_presences
Definition: PreChiSquare.hh:55
Sample minimum
Definition: PreChiSquare.hh:53
virtual void getLayerResultSpec(stringMap &info)=0
AlgParamMetadata parameters[NUM_PARAM]
Definition: garp.cpp:55
virtual void getAcceptedParameters(stringMap &info)=0
virtual bool checkParameters(const PreParameters &parameters) const =0
Definition: Sample.hh:25