27 std::vector<std::vector<NodeData> >& simulationData,
28 std::vector<std::vector<Real> >& basisCoefficients) {
30 Size steps = simulationData.size();
31 basisCoefficients.resize(steps-1);
33 for (
Size i=steps-1; i!=0; --i) {
35 std::vector<NodeData>& exerciseData = simulationData[i];
39 Size N = exerciseData.front().values.size();
40 std::vector<Real> temp(N+1);
44 for (j=0; j<exerciseData.size(); ++j) {
45 if (exerciseData[j].isValid) {
46 std::copy(exerciseData[j].values.begin(),
47 exerciseData[j].values.end(),
49 temp.back() = exerciseData[j].cumulatedCashFlows
50 - exerciseData[j].controlValue;
56 std::vector<Real> means = stats.
mean();
61 for (
Size k=0; k<N; ++k) {
62 target[k] = covariance[k][N] + means[k]*means[N];
63 for (
Size l=0; l<=k; ++l)
64 C[k][l] = C[l][k] = covariance[k][l] + means[k]*means[l];
69 basisCoefficients[i-1].
resize(N);
70 std::copy(alphas.
begin(), alphas.
end(),
71 basisCoefficients[i-1].begin());
75 for (j=0; j<exerciseData.size(); ++j) {
76 if (exerciseData[j].isValid) {
77 Real exerciseValue = exerciseData[j].exerciseValue;
78 Real continuationValue =
79 exerciseData[j].cumulatedCashFlows;
80 Real estimatedContinuationValue =
82 exerciseData[j].values.begin(),
83 exerciseData[j].values.end(),
85 exerciseData[j].controlValue);
91 Real value = estimatedContinuationValue <= exerciseValue ?
95 simulationData[i-1][j].cumulatedCashFlows += value;
103 std::vector<NodeData>& estimatedData = simulationData[0];
104 for (
auto& j : estimatedData)
105 estimate.add(j.cumulatedCashFlows);
107 return estimate.mean();
1-D array used in linear algebra.
const_iterator end() const
const_iterator begin() const
empirical-distribution risk measures
Statistics analysis of N-dimensional (sequence) data.
void add(const Sequence &sample, Real weight=1.0)
Matrix covariance() const
returns the covariance Matrix
std::vector< Real > mean() const
Matrix used in linear algebra.
Singular value decomposition.
Array solveFor(const Array &) const
std::size_t Size
size of a container
Real genericLongstaffSchwartzRegression(std::vector< std::vector< NodeData > > &simulationData, std::vector< std::vector< Real > > &basisCoefficients)
returns the biased estimate obtained while regressing
Statistics tools for sequence (vector, list, array) samples.
singular value decomposition