Logo Search packages:      
Sourcecode: quantlib version File versions  Download package

void QuantLib::IncrementalStatistics::add ( Real  value,
Real  weight = 1.0 
)

adds a datum to the set, possibly with a weight

Precondition:
weight must be positive or null

Definition at line 143 of file incrementalstatistics.cpp.

References max(), min(), QL_ENSURE, and QL_REQUIRE.

Referenced by addSequence().

                                                           {
        QL_REQUIRE(weight>=0.0,
                   "negative weight (" << weight << ") not allowed");

        Size oldSamples = sampleNumber_;
        sampleNumber_++;
        QL_ENSURE(sampleNumber_ > oldSamples,
                  "maximum number of samples reached");

        sampleWeight_ += weight;

        Real temp = weight*value;
        sum_ += temp;
        temp *= value;
        quadraticSum_ += temp;
        if (value<0.0) {
            downsideQuadraticSum_ += temp;
            downsideSampleNumber_++;
            downsideSampleWeight_ += weight;
        }
        temp *= value;
        cubicSum_ += temp;
        temp *= value;
        fourthPowerSum_ += temp;
        if (oldSamples == 0) {
            min_ = max_ = value;
        } else {
            min_ = std::min(value, min_);
            max_ = std::max(value, max_);
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index