Represents a bucketed probability distibution. More...
#include <qle/math/bucketeddistribution.hpp>
Public Member Functions | |
BucketedDistribution () | |
Default constructor. More... | |
BucketedDistribution (QuantLib::Real min, QuantLib::Real max, QuantLib::Size numberBuckets) | |
Build a default initial distribution from min and max and numberBuckets . More... | |
BucketedDistribution (QuantLib::Real min, QuantLib::Real max, QuantLib::Size numberBuckets, QuantLib::Real initialValue) | |
BucketedDistribution (const std::vector< QuantLib::Real > &buckets, const std::vector< QuantLib::Real > &initialProbabilities, const std::vector< QuantLib::Real > &initialPoints) | |
Explicitly specify the initial distribution. More... | |
BucketedDistribution (const BucketedDistribution &other) | |
Copy constructor. More... | |
void | add (const DiscreteDistribution &distribution) |
Update the bucketed distribution by adding a discrete distribution. More... | |
const std::vector< QuantLib::Real > & | buckets () const |
Return the buckets of the distribution. More... | |
const std::vector< QuantLib::Real > & | probabilities () const |
Get the probabilities. More... | |
std::vector< QuantLib::Real > & | probabilities () |
Set the probabilities. More... | |
const std::vector< QuantLib::Real > & | points () const |
Return the points of the distribution. More... | |
Size | numberBuckets () const |
Return the number of buckets in the distribution. More... | |
std::vector< QuantLib::Real > | cumulativeProbabilities () const |
Return the cumulative probabilities of the distribution. More... | |
std::vector< QuantLib::Real > | complementaryProbabilities () const |
Return 1.0 minus the cumulative probabilities of the distribution. More... | |
void | applyShift (QuantLib::Real shift) |
Shift all buckets and points by an additive shift . More... | |
void | applyFactor (QuantLib::Real factor) |
Shift all buckets and points by a multiplicative factor . More... | |
Real | cumulativeProbability (QuantLib::Real x) const |
Return cumulative probability at point x using linear interpolation. More... | |
Real | inverseCumulativeProbability (QuantLib::Real p) const |
Return inverse cumulative probability given a probability p using linear interpolation. More... | |
BucketedDistribution & | operator+= (const BucketedDistribution &other) |
Utility functions. More... | |
DiscreteDistribution | createDiscrete () const |
Create a DiscreteDistribution from a BucketedDistribution with discrete points at midpoints of the buckets. More... | |
void | erase (QuantLib::Size n) |
Erase the first n buckets from the distribution. More... | |
QuantLib::Size | bucket (QuantLib::Real value) const |
Returns the index of the bucket containing value. More... | |
Private Member Functions | |
void | init (QuantLib::Real min, QuantLib::Real max, QuantLib::Size numberBuckets) |
Common code used in the constructor. More... | |
Private Attributes | |
std::vector< QuantLib::Real > | buckets_ |
Vector of numbers denoting buckets of distribution. More... | |
std::vector< QuantLib::Real > | probabilities_ |
Vector of numbers denoting probabilities in each bucket. More... | |
std::vector< QuantLib::Real > | points_ |
std::vector< QuantLib::Real > | previousProbabilities_ |
std::vector< QuantLib::Real > | previousPoints_ |
Static Private Attributes | |
static const QuantLib::Real | minProbability_ = 0.00000001 |
Represents a bucketed probability distibution.
Definition at line 35 of file bucketeddistribution.hpp.
BucketedDistribution | ( | QuantLib::Real | min, |
QuantLib::Real | max, | ||
QuantLib::Size | numberBuckets | ||
) |
Build a default initial distribution from min
and max
and numberBuckets
.
BucketedDistribution | ( | QuantLib::Real | min, |
QuantLib::Real | max, | ||
QuantLib::Size | numberBuckets, | ||
QuantLib::Real | initialValue | ||
) |
Build a default initial distribution from min
and max
and numberBuckets
and set all probabilities to initialValue
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 | ( | const BucketedDistribution & | other | ) |
Copy constructor.
Definition at line 71 of file bucketeddistribution.cpp.
void add | ( | const DiscreteDistribution & | distribution | ) |
Update the bucketed distribution by adding a discrete distribution.
Definition at line 77 of file bucketeddistribution.cpp.
const std::vector< QuantLib::Real > & buckets | ( | ) | const |
Return the buckets of the distribution.
Definition at line 55 of file bucketeddistribution.hpp.
const std::vector< QuantLib::Real > & probabilities | ( | ) | const |
Get the probabilities.
Definition at line 57 of file bucketeddistribution.hpp.
std::vector< QuantLib::Real > & probabilities | ( | ) |
const std::vector< QuantLib::Real > & points | ( | ) | const |
Return the points of the distribution.
Definition at line 61 of file bucketeddistribution.hpp.
Size numberBuckets | ( | ) | const |
Return the number of buckets in the distribution.
Definition at line 63 of file bucketeddistribution.hpp.
vector< Real > cumulativeProbabilities | ( | ) | const |
Return the cumulative probabilities of the distribution.
Definition at line 167 of file bucketeddistribution.cpp.
vector< Real > complementaryProbabilities | ( | ) | const |
Return 1.0 minus the cumulative probabilities of the distribution.
Definition at line 176 of file bucketeddistribution.cpp.
void applyShift | ( | QuantLib::Real | shift | ) |
Shift all buckets and points by an additive shift
.
Definition at line 183 of file bucketeddistribution.cpp.
void applyFactor | ( | QuantLib::Real | factor | ) |
Shift all buckets and points by a multiplicative factor
.
Definition at line 194 of file bucketeddistribution.cpp.
Real cumulativeProbability | ( | QuantLib::Real | x | ) | const |
Return cumulative probability at point x
using linear interpolation.
Definition at line 213 of file bucketeddistribution.cpp.
Real inverseCumulativeProbability | ( | QuantLib::Real | p | ) | const |
Return inverse cumulative probability given a probability p
using linear interpolation.
Definition at line 228 of file bucketeddistribution.cpp.
BucketedDistribution & operator+= | ( | const BucketedDistribution & | other | ) |
Utility functions.
Definition at line 244 of file bucketeddistribution.cpp.
DiscreteDistribution createDiscrete | ( | ) | const |
Create a DiscreteDistribution from a BucketedDistribution with discrete points at midpoints of the buckets.
Definition at line 258 of file bucketeddistribution.cpp.
void erase | ( | QuantLib::Size | n | ) |
Erase the first n
buckets from the distribution.
Definition at line 269 of file bucketeddistribution.cpp.
Size bucket | ( | QuantLib::Real | value | ) | const |
Returns the index of the bucket containing value.
Definition at line 137 of file bucketeddistribution.cpp.
|
private |
Common code used in the constructor.
Definition at line 151 of file bucketeddistribution.cpp.
|
private |
Vector of numbers denoting buckets of distribution.
Definition at line 91 of file bucketeddistribution.hpp.
|
private |
Vector of numbers denoting probabilities in each bucket.
Definition at line 93 of file bucketeddistribution.hpp.
|
private |
Definition at line 94 of file bucketeddistribution.hpp.
|
private |
Definition at line 95 of file bucketeddistribution.hpp.
|
private |
Definition at line 96 of file bucketeddistribution.hpp.
|
staticprivate |
Definition at line 99 of file bucketeddistribution.hpp.