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

helper class for the MonteCarloCBOEngine More...

#include <qle/pricingengines/cboengine.hpp>

+ Collaboration diagram for Stats:

Public Member Functions

 Stats (std::vector< Real > data)
 
Real mean ()
 
Real std ()
 
Real max ()
 
Real min ()
 
std::vector< Real > & data ()
 
Distribution histogram (Size bins, Real xmin=-QL_MAX_REAL, Real xmax=QL_MAX_REAL)
 

Private Attributes

std::vector< Real > data_
 
Real mean_
 
Real std_
 
Real max_
 
Real min_
 

Detailed Description

helper class for the MonteCarloCBOEngine

Definition at line 45 of file cboengine.hpp.

Constructor & Destructor Documentation

◆ Stats()

Stats ( std::vector< Real >  data)

Definition at line 31 of file cboengine.cpp.

31 : data_(data), mean_(0.0), std_(0.0), max_(0.0), min_(0.0) {
32 for (Size i = 0; i < data_.size(); i++) {
33 mean_ += data_[i];
34 std_ += data_[i] * data_[i];
35 }
36 mean_ /= data_.size();
37 std_ /= data_.size();
38 std_ = sqrt(std_ - mean_ * mean_);
39 max_ = *(std::max_element(data_.begin(), data_.end()));
40 min_ = *(std::min_element(data_.begin(), data_.end()));
41}
std::vector< Real > & data()
Definition: cboengine.hpp:71
std::vector< Real > data_
Definition: cboengine.hpp:56
RandomVariable sqrt(RandomVariable x)
+ Here is the call graph for this function:

Member Function Documentation

◆ mean()

Real mean ( )

Definition at line 63 of file cboengine.hpp.

63{ return mean_; }
+ Here is the caller graph for this function:

◆ std()

Real std ( )

Definition at line 65 of file cboengine.hpp.

65{ return std_; }
+ Here is the caller graph for this function:

◆ max()

Real max ( )

Definition at line 67 of file cboengine.hpp.

67{ return max_; }

◆ min()

Real min ( )

Definition at line 69 of file cboengine.hpp.

69{ return min_; }

◆ data()

std::vector< Real > & data ( )

Definition at line 71 of file cboengine.hpp.

71{ return data_; }

◆ histogram()

Distribution histogram ( Size  bins,
Real  xmin = -QL_MAX_REAL,
Real  xmax = QL_MAX_REAL 
)

Definition at line 43 of file cboengine.cpp.

43 {
44 Distribution dist(bins, std::max(min_, xmin), std::min(max_, xmax));
45 for (Size i = 0; i < data_.size(); i++) {
46 if (data_[i] > xmax)
47 data_[i] = xmax;
48 if (data_[i] < xmin)
49 data_[i] = xmin;
50 dist.add(data_[i]);
51 }
52 dist.normalize();
53 return dist;
54}
+ Here is the caller graph for this function:

Member Data Documentation

◆ data_

std::vector<Real> data_
private

Definition at line 56 of file cboengine.hpp.

◆ mean_

Real mean_
private

Definition at line 57 of file cboengine.hpp.

◆ std_

Real std_
private

Definition at line 58 of file cboengine.hpp.

◆ max_

Real max_
private

Definition at line 59 of file cboengine.hpp.

◆ min_

Real min_
private

Definition at line 60 of file cboengine.hpp.