1 #ifndef __TRADEMGEN_BAS_CONTINUOUSATTRIBUTE_HPP
2 #define __TRADEMGEN_BAS_CONTINUOUSATTRIBUTE_HPP
11 #include <stdair/stdair_date_time_types.hpp>
12 #include <stdair/service/Logger.hpp>
33 return _cumulativeDistribution;
38 return _inverseCumulativeDistribution;
45 _cumulativeDistribution = iCumulativeDistribution;
52 const T
getValue (
const stdair::Probability_T& iCumulativeProbability)
const{
55 typename ContinuousInverseDistribution_T::const_iterator it =
56 _inverseCumulativeDistribution.lower_bound (lKey);
58 stdair::Probability_T cumulativeProbabilityNextPoint =
60 T valueNextPoint = it->second;
62 if (it == _inverseCumulativeDistribution.begin()) {
63 STDAIR_LOG_DEBUG (
"Last element");
64 return valueNextPoint;
68 stdair::Probability_T cumulativeProbabilityPreviousPoint =
70 T valuePreviousPoint = it->second;
71 if (cumulativeProbabilityNextPoint == cumulativeProbabilityPreviousPoint) {
72 return valuePreviousPoint;
75 return valuePreviousPoint + (valueNextPoint - valuePreviousPoint)
76 * (iCumulativeProbability - cumulativeProbabilityPreviousPoint)
77 / (cumulativeProbabilityNextPoint - cumulativeProbabilityPreviousPoint);
84 std::ostringstream oStr;
86 for (
typename ContinuousDistribution_T::const_iterator it =
87 _cumulativeDistribution.begin();
88 it != _cumulativeDistribution.end(); ++it, ++idx) {
92 oStr << it->first <<
":"
100 std::ostringstream oStr;
101 for (
typename ContinuousInverseDistribution_T::const_iterator it =
102 _inverseCumulativeDistribution.begin();
103 it != _inverseCumulativeDistribution.end(); ++it) {
105 <<
" value: " << it->second << std::endl;
117 : _cumulativeDistribution (iCumulativeDistribution) {
123 : _cumulativeDistribution (iContinuousAttribute._cumulativeDistribution),
124 _inverseCumulativeDistribution (iContinuousAttribute._inverseCumulativeDistribution) {
133 for (
typename ContinuousDistribution_T::iterator itCumulativeDistribution =
134 _cumulativeDistribution.begin();
135 itCumulativeDistribution != _cumulativeDistribution.end();
136 ++itCumulativeDistribution) {
137 _inverseCumulativeDistribution.
139 value_type (itCumulativeDistribution->second,
140 itCumulativeDistribution->first));
155 #endif // __STDAIR_BAS_CONTINUOUSATTRIBUTE_HPP