Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Bucketing Class Reference

#include <qle/models/hullwhitebucketing.hpp>

+ Inheritance diagram for Bucketing:
+ Collaboration diagram for Bucketing:

Public Member Functions

template<class I >
 Bucketing (I bucketsBegin, I bucketsEnd)
 
 Bucketing (const Real lowerBound, const Real upperBound, const Size n)
 
const std::vector< Real > & upperBucketBound () const
 
Size index (const Real x) const
 
Size buckets () const
 

Protected Member Functions

void initBuckets ()
 

Protected Attributes

std::vector< Real > buckets_
 
bool uniformBuckets_ = false
 
Real lowerBound_
 
Real upperBound_
 
Real h_
 

Detailed Description

Definition at line 33 of file hullwhitebucketing.hpp.

Constructor & Destructor Documentation

◆ Bucketing() [1/2]

Bucketing ( bucketsBegin,
bucketsEnd 
)

buckets are (-QL_MAX_REAL, b1), [b1, b2), [b2,b3), ... , [b_{n-1}, b_n), [b_n, +QL_MAX_REAL)

Definition at line 77 of file hullwhitebucketing.hpp.

77 : buckets_(bucketsBegin, bucketsEnd) {
79}
std::vector< Real > buckets_
+ Here is the call graph for this function:

◆ Bucketing() [2/2]

Bucketing ( const Real  lowerBound,
const Real  upperBound,
const Size  n 
)

there are n+2 buckets constructed, lb = lower bound, ub = upper bound, h = (ub - lb) / n buckets are (-QL_MAX_REAL, lb), [lb, lb+h), [lb+h, lb+2h), ... , [lb+(n-1)h, ub), [ub,+QL_MAX_REAL)

Definition at line 28 of file hullwhitebucketing.cpp.

28 {
29 buckets_.resize(n + 1);
30 Real h = (upperBound - lowerBound) / static_cast<Real>(n);
31 for (Size i = 0; i <= n; ++i)
32 buckets_[i] = lowerBound + static_cast<Real>(i) * h;
34 uniformBuckets_ = true;
35 lowerBound_ = lowerBound;
36 upperBound_ = upperBound;
37 h_ = h;
38}
+ Here is the call graph for this function:

Member Function Documentation

◆ upperBucketBound()

const std::vector< Real > & upperBucketBound ( ) const

Definition at line 40 of file hullwhitebucketing.hpp.

40{ return buckets_; }
+ Here is the caller graph for this function:

◆ index()

Size index ( const Real  x) const

Definition at line 40 of file hullwhitebucketing.cpp.

40 {
41 if (uniformBuckets_) {
42 return std::min<Size>(buckets_.size() - 1,
43 std::max(0, static_cast<int>(std::floor((x - lowerBound_) / h_) + 1)));
44 } else {
45 return std::upper_bound(buckets_.begin(), buckets_.end(), x) - buckets_.begin();
46 }
47}
+ Here is the caller graph for this function:

◆ buckets()

Size buckets ( ) const

Definition at line 42 of file hullwhitebucketing.hpp.

42{ return buckets_.size(); }
+ Here is the caller graph for this function:

◆ initBuckets()

void initBuckets ( )
protected

Definition at line 49 of file hullwhitebucketing.cpp.

49 {
50 QL_REQUIRE(!buckets_.empty(), "Bucketing::initBuckets() no buckets given");
51 QL_REQUIRE(std::is_sorted(buckets_.begin(), buckets_.end()), "buckets must be sorted");
52 if (!close_enough(buckets_.back(), QL_MAX_REAL)) {
53 buckets_.insert(buckets_.end(), QL_MAX_REAL);
54 }
55}
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ buckets_

std::vector<Real> buckets_
protected

Definition at line 46 of file hullwhitebucketing.hpp.

◆ uniformBuckets_

bool uniformBuckets_ = false
protected

Definition at line 47 of file hullwhitebucketing.hpp.

◆ lowerBound_

Real lowerBound_
protected

Definition at line 48 of file hullwhitebucketing.hpp.

◆ upperBound_

Real upperBound_
protected

Definition at line 48 of file hullwhitebucketing.hpp.

◆ h_

Real h_
protected

Definition at line 48 of file hullwhitebucketing.hpp.