openModeller
Version 1.4.0
|
00001 00028 #ifndef PRE_CHISQUARE_HH 00029 #define PRE_CHISQUARE_HH 00030 00031 #include "PreAlgorithm.hh" 00032 00033 #include <openmodeller/om.hh> 00034 #include <openmodeller/Exceptions.hh> 00035 #include <openmodeller/Sample.hh> 00036 #include <openmodeller/Sampler.hh> 00037 00038 #define classLimit 16 00039 00040 /* 00041 * 00042 * 00043 * input: SamplerPtr output: shows for each variable the amount of layers that 00044 * maintain correlation at the significance level of 0.05 00045 */ 00046 00047 class dllexp PreChiSquare : public PreAlgorithm 00048 { 00049 private: 00050 size_t num_points; // number of points. 00051 size_t num_layers; // number of layers. 00052 size_t nclass; // number of class 00053 Sample minimum; // Mininum value for each layer. 00054 Sample delta; // delta value for each layer. 00055 OccurrencesPtr my_presences; //occurrence points of species. 00056 Scalar measured[classLimit][classLimit]; //measured points between two crossed layers. 00057 Scalar expected [classLimit][classLimit]; //expected points between two crossed layers. 00058 Scalar chicell [classLimit][classLimit]; //chi value for each cell formed between two class of the crossed layers. 00059 std::vector< size_t > statistic1; //dependency between layers. 00060 std::vector< size_t > statistic2; //dependency between layers. 00061 00062 public: 00063 00064 PreChiSquare(); //constructor 00065 ~PreChiSquare(); //destructor 00066 00067 //Return description about the algorithm 00068 string getDescription() const { return "\ 00069 This technique is described in Li, L., et al. (2006). \"An Integrated\ 00070 Bayesian Modelling Approach for Predicting Mosquito Larval Habitats\". The \ 00071 authors tested the independence between all pairs of layers. Each pair is \ 00072 cross-referenced using a contingency matrix to detect the dependency between \ 00073 the layers based on a set of presence points from a particular species. \ 00074 The output shows for each layer the number of layers that maintain correlation \ 00075 with the significance level of 0.05."; } 00076 00077 //Checks if the supplied parameters fits the requirements of PRE algorithm implementation. 00078 //return true if the parameters are OK. false if not. 00079 bool checkParameters( const PreParameters& parameters ) const; 00080 00081 //Runs the current algorithm implementation. 00082 //return true if OK. false on error. 00083 bool runImplementation(); 00084 00085 //get input parameters 00086 void getAcceptedParameters ( stringMap& info ); 00087 00088 //get output information 00089 void getLayersetResultSpec ( stringMap& info); 00090 00091 //get output information for each layer 00092 void getLayerResultSpec ( stringMap& info); 00093 00094 //initialize attributes: num_points, num_layers, nclass, minimum, delta, my_presences. 00095 bool init(); 00096 00097 //get number of points. 00098 size_t getNpoints(); 00099 00100 //set number of points. 00101 void setNpoints(); 00102 00103 //get number of layers. 00104 size_t getNlayers(); 00105 00106 //set number of layers. 00107 void setNlayers(SamplerPtr samplerPtr); 00108 00109 //set number of class. 00110 size_t getNclass(); 00111 00112 //set number of class. 00113 void setNclass(); 00114 00115 //set mininum value for each layer. 00116 void setMinimum(); 00117 00118 //get minimum value of each layer. 00119 Sample getMinimum(); 00120 00121 //set delta value for each layer. 00122 void setDelta(); 00123 00124 //get delta value of each layer. 00125 Sample getDelta(); 00126 00127 //set measured points for crossed layers. 00128 void setMeasured(size_t layer1, size_t layer2); 00129 00130 //set expected points for crossed layers. 00131 void setExpected(); 00132 00133 //set chi value for each cell formed between two class of the crossed layers. 00134 void setChicell(); 00135 00136 //count layer dependency. 00137 void setStatistic(size_t layer1, size_t layer2); 00138 00139 //control layers crossing. 00140 void run(); 00141 00142 //set zero to all elements of the matrix "measured". 00143 void setMeasuredZero(); 00144 00145 }; 00146 00147 00148 #endif 00149