28#include <ql/types.hpp>
45 QuantLib::Real initialValue);
48 const std::vector<QuantLib::Real>& initialProbabilities,
49 const std::vector<QuantLib::Real>& initialPoints);
83 void erase(QuantLib::Size n);
85 QuantLib::Size
bucket(QuantLib::Real value)
const;
Represents a bucketed probability distibution.
void erase(QuantLib::Size n)
Erase the first n buckets from the distribution.
BucketedDistribution & operator+=(const BucketedDistribution &other)
Utility functions.
void applyShift(QuantLib::Real shift)
Shift all buckets and points by an additive shift.
BucketedDistribution()
Default constructor.
BucketedDistribution(const std::vector< QuantLib::Real > &buckets, const std::vector< QuantLib::Real > &initialProbabilities, const std::vector< QuantLib::Real > &initialPoints)
Explicitly specify the initial distribution.
BucketedDistribution(QuantLib::Real min, QuantLib::Real max, QuantLib::Size numberBuckets)
Build a default initial distribution from min and max and numberBuckets.
void applyFactor(QuantLib::Real factor)
Shift all buckets and points by a multiplicative factor.
void init(QuantLib::Real min, QuantLib::Real max, QuantLib::Size numberBuckets)
Common code used in the constructor.
const std::vector< QuantLib::Real > & probabilities() const
Get the probabilities.
std::vector< QuantLib::Real > points_
Size numberBuckets() const
Return the number of buckets in the distribution.
Real inverseCumulativeProbability(QuantLib::Real p) const
Return inverse cumulative probability given a probability p using linear interpolation.
std::vector< QuantLib::Real > previousPoints_
const std::vector< QuantLib::Real > & buckets() const
Return the buckets of the distribution.
BucketedDistribution(QuantLib::Real min, QuantLib::Real max, QuantLib::Size numberBuckets, QuantLib::Real initialValue)
std::vector< QuantLib::Real > previousProbabilities_
void add(const DiscreteDistribution &distribution)
Update the bucketed distribution by adding a discrete distribution.
std::vector< QuantLib::Real > cumulativeProbabilities() const
Return the cumulative probabilities of the distribution.
std::vector< QuantLib::Real > & probabilities()
Set the probabilities.
Real cumulativeProbability(QuantLib::Real x) const
Return cumulative probability at point x using linear interpolation.
std::vector< QuantLib::Real > buckets_
Vector of numbers denoting buckets of distribution.
QuantLib::Size bucket(QuantLib::Real value) const
Returns the index of the bucket containing value.
const std::vector< QuantLib::Real > & points() const
Return the points of the distribution.
DiscreteDistribution createDiscrete() const
Create a DiscreteDistribution from a BucketedDistribution with discrete points at midpoints of the bu...
static const QuantLib::Real minProbability_
std::vector< QuantLib::Real > probabilities_
Vector of numbers denoting probabilities in each bucket.
std::vector< QuantLib::Real > complementaryProbabilities() const
Return 1.0 minus the cumulative probabilities of the distribution.
Discretized probability density and cumulative probability.
BucketedDistribution operator+(const BucketedDistribution &lhs, const BucketedDistribution &rhs)
Sum probabilities in two bucketed distributions with equal buckets.
BucketedDistribution operator*(Real factor, const BucketedDistribution &rhs)