Go to the documentation of this file.00001 #include "Robust.h"
00002
00003
00004
00005
00006
00007
00008 Robust::Robust(unsigned sampleSetSize_)
00009 {
00010 sampleSetSize = sampleSetSize_;
00011 numF = 0;
00012 sampleSet = NULL;
00013 }
00014
00015
00016
00017
00018
00019
00020 void Robust::allocateSampleSet(int numNoise)
00021 {
00022 #ifdef DEBUG
00023 cout << "Robust::allocateSampleSet()" << endl;
00024 #endif
00025
00026 sampleSet = new double* [sampleSetSize];
00027
00028 for (unsigned i = 0; i < sampleSetSize; i++)
00029 sampleSet[i] = new double[numNoise];
00030 }
00031
00032 void Robust::deallocateSampleSet()
00033 {
00034 #ifdef DEBUG
00035 cout << "Robust::deallocateSampleSet()" << endl;
00036 #endif
00037
00038 if (sampleSet == NULL)
00039 return;
00040
00041 for (unsigned i = 0; i < sampleSetSize; i++)
00042 delete [] sampleSet[i];
00043
00044 delete [] sampleSet;
00045 sampleSet = NULL;
00046 }
00047
00048
00049
00050
00051
00052 void Robust::generateSampleSet_MC(int numNoise, int* numNoiseNorm, int* numNoiseUnif)
00053 {
00054 #ifdef DEBUG
00055 cout << "Robust::generateSampleSet_MC()" << endl;
00056 #endif
00057
00058 if (sampleSet == NULL)
00059 allocateSampleSet(numNoise);
00060
00061 unsigned pos;
00062 for (unsigned i = 0; i < sampleSetSize; i++)
00063 {
00064 pos = 0;
00065
00066 if (numNoiseNorm != NULL)
00067 {
00068 for (int j = 0; j < *numNoiseNorm; j++)
00069 sampleSet[i][pos++] = normReal();
00070 }
00071
00072 if (numNoiseUnif != NULL)
00073 {
00074 for (int j = 0; j < *numNoiseUnif; j++)
00075 sampleSet[i][pos++] = uniReal();
00076 }
00077 }
00078 }
00079
00080
00081
00082
00083
00084 void Robust::generateSampleSet_LH(int numNoise, int* numNoiseNorm, int* numNoiseUnif)
00085 {
00086 #ifdef DEBUG
00087 cout << "Robust::generateSampleSet_LH()" << endl;
00088 #endif
00089
00090 if (sampleSet == NULL)
00091 allocateSampleSet(numNoise);
00092
00093 vector<int> intervalId(sampleSetSize, 0);
00094 vector<double> P(sampleSetSize, 0);
00095 for (int j = 0; j < numNoise; j++)
00096 {
00097
00098 randPerm(intervalId, sampleSetSize);
00099
00100 for (unsigned i = 0; i < sampleSetSize; i++)
00101 {
00102
00103 P[i] = (intervalId[i] - uniReal())/ sampleSetSize;
00104
00105
00106 sampleSet[i][j] = P[i];
00107
00108
00109 if (numNoiseNorm != NULL)
00110 {
00111 if (j < *numNoiseNorm)
00112 {
00113 sampleSet[i][j] = boost::math::quantile(normDistMath, P[i]);
00114 }
00115 }
00116 }
00117 }
00118 }
00119
00120