1 #ifndef __STDAIR_BAS_CONTINUOUSATTRIBUTELITE_HPP
2 #define __STDAIR_BAS_CONTINUOUSATTRIBUTELITE_HPP
45 for (; idx < _size; ++idx) {
46 if (_cumulativeDistribution.at(idx) > lKey) {
52 return _valueArray.at(idx);
55 return _valueArray.at(idx-1);
61 const T& lValueCurrentPoint = _valueArray.at(idx);
66 const T& lValuePreviousPoint = _valueArray.at(idx-1);
68 if (lCumulativePreviousPoint == lCumulativeCurrentPoint) {
69 return lValuePreviousPoint;
72 T oValue= lValuePreviousPoint + (lValueCurrentPoint - lValuePreviousPoint)
73 * (iCumulativeProbability - lCumulativePreviousPoint)
74 / (lCumulativeCurrentPoint - lCumulativePreviousPoint);
88 for (; idx < _size; ++idx) {
89 if (_valueArray.at(idx) > iValue) {
96 return 1 - oCumulativeProbability;
101 return 1 - oCumulativeProbability;
107 const T& lValueCurrentPoint = _valueArray.at(idx);
112 const T& lValuePreviousPoint = _valueArray.at(idx-1);
114 if (lValuePreviousPoint == lValueCurrentPoint) {
115 return 1 - lCumulativePreviousPoint;
119 lCumulativePreviousPoint + (lCumulativeCurrentPoint - lCumulativePreviousPoint)
120 * (iValue - lValuePreviousPoint)
121 / (lValueCurrentPoint - lValuePreviousPoint);
123 return 1 - oCumulativeProbability;
134 unsigned int idx = 0;
135 for (; idx < _size; ++idx) {
136 if (_valueArray.at(idx) > iKey) {
141 assert (idx != _size);
146 const T& lValueCurrentPoint = _valueArray.at(idx);
151 const T& lValuePreviousPoint = _valueArray.at(idx-1);
152 assert (lValueCurrentPoint != lValuePreviousPoint);
154 const double oValue= (lCumulativeCurrentPoint - lCumulativePreviousPoint)
155 / (lValueCurrentPoint - lValuePreviousPoint);
165 unsigned int idx = 0;
166 for (; idx < _size; ++idx) {
167 if (_valueArray.at(idx) > iKey) {
172 assert (idx != _size);
174 return _valueArray.at (idx);
183 std::ostringstream oStr;
185 for (
unsigned int idx = 0; idx < _size; ++idx) {
193 oStr << _valueArray.at(idx) <<
":" << lProbability;
205 : _size (iValueMap.size()) {
213 : _size (iCAL._size),
214 _cumulativeDistribution (iCAL._cumulativeDistribution),
215 _valueArray (iCAL._valueArray) {
223 _cumulativeDistribution = iCAL._cumulativeDistribution;
224 _valueArray = iCAL._valueArray;
247 const unsigned int lSize = iValueMap.size();
248 _cumulativeDistribution.reserve (lSize);
249 _valueArray.reserve (lSize);
252 for (
typename ContinuousDistribution_T::const_iterator it =
253 iValueMap.begin(); it != iValueMap.end(); ++it) {
255 const T& attributeValue = it->first;
259 _cumulativeDistribution.push_back (lKey);
260 _valueArray.push_back (attributeValue);
275 std::vector<DictionaryKey_T> _cumulativeDistribution;
280 std::vector<T> _valueArray;
284 #endif // __STDAIR_BAS_CONTINUOUSATTRIBUTELITE_HPP