Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #include <iostream>
00056 #include "TrainTools.h"
00057 #include "ScoreWarp.h"
00058
00059 int main (int argc, char *argv[])
00060 {
00061 using namespace std;
00062 using namespace alize;
00063
00064 try
00065 {
00066 Config config;
00067 CmdLine cmdLine (argc, argv);
00068 if (cmdLine.displayHelpRequired ())
00069 {
00070 cout << "ScoreWarp.exe" << endl;
00071 cout << " " << endl;
00072 }
00073 else if (cmdLine.displayVersionRequired ())
00074 cout << "Version 0.0" << endl;
00075 else
00076 {
00077 cmdLine.copyIntoConfig (config);
00078 if (config.getParamCount() == 0)
00079 {cerr << "Error: Type ScoreWarp --help to get usage" << endl;exit(1);}
00080 if (config.existsParam("debug")) debug=true;
00081 if (config.existsParam("verbose")) verbose=true;
00082 if (config.existsParam("generateGauss")){
00083 unsigned long nbBin=50;
00084 if (config.existsParam("nbBinGauss")) nbBin=config.getParam("nbBinGauss").toLong();
00085 unsigned long nbSample=1000000;
00086 if (config.existsParam("nbSample")) nbSample=config.getParam("nbSample").toLong();
00087 double mean=0;
00088 if (config.existsParam("mean")) mean=config.getParam("mean").toDouble();
00089 double cov=1;
00090 if (config.existsParam("cov")) cov=config.getParam("cov").toDouble();
00091 String outputFile="foo";
00092 if (config.existsParam("outputFilename")) outputFile=config.getParam("outputFilename");
00093 Histo gaussH=makeGausHisto(nbSample,mean, cov,nbBin);
00094 gaussH.saveGnuplot(outputFile+".gnuplot");
00095 gaussH.save(outputFile+".histo");
00096 }
00097 if (config.existsParam("testWarp")){
00098 String outputFile="foo.out";
00099 if (config.existsParam("outputFilename")) outputFile=config.getParam("outputFilename");
00100 ofstream ofile(outputFile.c_str(),ios::out);
00101 String fileDestH="destH";
00102 if (config.existsParam("filenameDestH")) fileDestH=config.getParam("filenameDestH");
00103 String fileRawH="rawH";
00104 if (config.existsParam("filenameRawH")) fileRawH=config.getParam("filenameRawH");
00105 unsigned long nbSample=1000000;
00106 if (config.existsParam("nbSample")) nbSample=config.getParam("nbSample").toLong();
00107 double mean=0;
00108 if (config.existsParam("mean")) mean=config.getParam("mean").toDouble();
00109 double cov=1;
00110 if (config.existsParam("cov")) cov=config.getParam("cov").toDouble();
00111 double nonObserved=0.1;
00112 if (config.existsParam("nonObserved")) nonObserved=config.getParam("nonObserved").toDouble();
00113 double area=0.5;
00114 if (config.existsParam("refArea")) area=config.getParam("refArea").toDouble();
00115 Histo gaussH;
00116 Histo gaussR;
00117 gaussH.load(fileDestH+".histo");
00118 gaussR.load(fileRawH+".histo");
00119 boxMullerGeneratorInit();
00120 for (unsigned long i=0;i<nbSample;i++){
00121 double val=boxMullerGenerator(mean, cov);
00122 ofile << val <<" "<<scoreWarping(val,gaussR ,gaussH,nonObserved,area)<<endl;
00123 }
00124 }
00125 if (config.existsParam("normalizeHisto")){
00126 String outputFile="foo";
00127 if (config.existsParam("outputFilename")) outputFile=config.getParam("outputFilename");
00128 ofstream ofile(outputFile.c_str(),ios::out);
00129 String fileInputH="";
00130 if (config.existsParam("filenameInputH")) fileInputH=config.getParam("filenameInputH");
00131 Histo inputH;
00132 inputH.load(fileInputH+".histo");
00133 double area=0;
00134 for (unsigned long i=0;i<inputH.size();i++) area+=areaHisto(inputH,i);
00135 if (debug) cout <<"normalizeHisto, area["<<area<<"]"<<endl;
00136 inputH.div(area);
00137 inputH.save(outputFile+".histo");
00138 inputH.saveGnuplot(outputFile+".gnuplot");
00139 }
00140 if (config.existsParam("testWarpLinear")){
00141 String outputFile="foo.out";
00142 if (config.existsParam("outputFilename")) outputFile=config.getParam("outputFilename");
00143 ofstream ofile(outputFile.c_str(),ios::out);
00144 String fileDestH="destH";
00145 if (config.existsParam("filenameDestH")) fileDestH=config.getParam("filenameDestH");
00146 String fileRawH="rawH";
00147 if (config.existsParam("filenameRawH")) fileRawH=config.getParam("filenameRawH");
00148 unsigned long nbSample=1000000;
00149 if (config.existsParam("nbSample")) nbSample=config.getParam("nbSample").toLong();
00150 double min=-10;
00151 if (config.existsParam("min")) min=config.getParam("min").toDouble();
00152 double max=10;
00153 if (config.existsParam("max")) max=config.getParam("max").toDouble();
00154 double nonObserved=0.1;
00155 if (config.existsParam("nonObserved")) nonObserved=config.getParam("nonObserved").toDouble();
00156 double area=0.5;
00157 if (config.existsParam("refArea")) area=config.getParam("refArea").toDouble();
00158 Histo gaussH;
00159 Histo gaussR;
00160 gaussH.load(fileDestH+".histo");
00161 gaussR.load(fileRawH+".histo");
00162 for (unsigned long i=0;i<nbSample;i++){
00163 double val=min+(i*((max-min)/(double)nbSample));
00164 ofile << val <<" "<<scoreWarping(val,gaussR ,gaussH,nonObserved,area)<<endl;
00165 }
00166 }
00167 }
00168 }
00169 catch (alize::Exception & e)
00170 {
00171 cout << e.toString () << endl;
00172 }
00173
00174 return 0;
00175 }