00001 /*!@file CINNIC/CINNICanova.C do ANOVA tests on CINNIC outputs */ 00002 00003 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/CINNIC/CINNICanova.C $ 00004 // $Id: CINNICanova.C 6003 2005-11-29 17:22:45Z rjpeters $ 00005 00006 // ############################################################ 00007 // ############################################################ 00008 // ##### ---CINNIC--- 00009 // ##### Contour Integration: 00010 // ##### T. Nathan Mundhenk nathan@mundhenk.com 00011 // ############################################################ 00012 // ############################################################ 00013 00014 #include "Image/Image.H" 00015 #include "Util/Assert.H" 00016 #include "Util/log.H" 00017 #include "Util/readConfig.H" 00018 #include "Util/stats.H" 00019 #include <cstdlib> 00020 #include <cstring> 00021 #include <iostream> 00022 #include <vector> 00023 00024 //! the file to save stats out to 00025 char *savefilename; 00026 //! two data sets to open 00027 readConfig ReadConfigA(25); 00028 //! two data sets to open 00029 readConfig ReadConfigB(25); 00030 //! Files containing data sets 00031 char* dataSet1; 00032 char* dataSet2; 00033 //! Vector for regresion data set 1 00034 std::vector<float> rSet1; 00035 //! Vector for regresion data set 2 00036 std::vector<float> rSet2; 00037 //! Vector for euclidian data set 1 00038 std::vector<float> eSet1; 00039 //! Vector for euclidian data set 2 00040 std::vector<float> eSet2; 00041 //! Stats objects 00042 stats<float> rStats; 00043 //! Stats objects 00044 stats<float> eStats; 00045 //! F from anova 00046 float rF,eF; 00047 00048 int main(int argc, char* argv[]) 00049 { 00050 ASSERT(argc >= 2); 00051 dataSet1 = argv[1]; 00052 dataSet2 = argv[2]; 00053 //open and parse data sets 00054 ReadConfigA.openFile(dataSet1); 00055 ReadConfigB.openFile(dataSet2); 00056 //Make sure data sets are the same size 00057 ASSERT(ReadConfigA.itemCount() == ReadConfigB.itemCount()); 00058 //resize data set vectors 00059 rSet1.resize(ReadConfigA.itemCount(),0.0F); 00060 eSet1.resize(ReadConfigA.itemCount(),0.0F); 00061 rSet2.resize(ReadConfigB.itemCount(),0.0F); 00062 eSet2.resize(ReadConfigB.itemCount(),0.0F); 00063 //load values from config to a vector<float> 00064 for(int i = 0; ReadConfigA.readFileTrue(i); i++) 00065 { 00066 rSet1[i] = ReadConfigA.readFileValueNameF(i); 00067 eSet1[i] = ReadConfigA.readFileValueF(i); 00068 rSet2[i] = ReadConfigB.readFileValueNameF(i); 00069 eSet2[i] = ReadConfigB.readFileValueF(i); 00070 } 00071 rF = rStats.simpleANOVA(rSet1,rSet2); 00072 eF = eStats.simpleANOVA(eSet1,eSet2); 00073 00074 LINFO("DATA sets %s : %s",dataSet1,dataSet2); 00075 LINFO("Regression Stats on ANOVA"); 00076 00077 using std::cout; 00078 00079 cout << "between\t"; 00080 cout << rStats.SSbetween << "\t" << rStats.DFbetween << "\t" 00081 << rStats.MSbetween << "\t" << rStats.F << "\n"; 00082 cout << "within\t"; 00083 cout << rStats.SSwithin << "\t" << rStats.DFwithin << "\t" 00084 << rStats.MSwithin << "\n"; 00085 cout << "total\t"; 00086 cout << rStats.SStotal << "\n\n"; 00087 LINFO("Euclidian Stats on ANOVA"); 00088 cout << "between\t"; 00089 cout << eStats.SSbetween << "\t" << eStats.DFbetween << "\t" 00090 << eStats.MSbetween << "\t" << eStats.F << "\n"; 00091 cout << "within\t"; 00092 cout << eStats.SSwithin << "\t" << eStats.DFwithin << "\t" 00093 << eStats.MSwithin << "\n"; 00094 cout << "total\t"; 00095 cout << eStats.SStotal << "\n\n"; 00096 } 00097 00098 // ###################################################################### 00099 /* So things look consistent in everyone's emacs... */ 00100 /* Local Variables: */ 00101 /* indent-tabs-mode: nil */ 00102 /* End: */