Changeset 215
- Timestamp:
- 06/23/08 05:48:37 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/QLNet/QLNet/Methods/montecarlo/montecarlomodel.cs
r194 r215 92 92 double price = pathPricer_.value(path.value); 93 93 94 if (isControlVariate_) 94 if (isControlVariate_) { 95 95 if (cvPathGenerator_ == null) { 96 price += cvOptionValue_-cvPathPricer_.value(path.value); 96 price += cvOptionValue_ - cvPathPricer_.value(path.value); 97 } else { 98 Sample<Path> cvPath = cvPathGenerator_.next(); 99 price += cvOptionValue_ - cvPathPricer_.value(cvPath.value); 97 100 } 98 else { 99 Sample<Path> cvPath = cvPathGenerator_.next(); 100 price += cvOptionValue_-cvPathPricer_.value(cvPath.value); 101 } 101 } 102 102 103 103 if (isAntitheticVariate_) { 104 104 path = pathGenerator_.antithetic(); 105 105 double price2 = pathPricer_.value(path.value); 106 if (isControlVariate_) 106 if (isControlVariate_) { 107 107 if (cvPathGenerator_ == null) 108 price2 += cvOptionValue_ -cvPathPricer_.value(path.value);108 price2 += cvOptionValue_ - cvPathPricer_.value(path.value); 109 109 else { 110 110 Sample<Path> cvPath = cvPathGenerator_.antithetic(); 111 price2 += cvOptionValue_ -cvPathPricer_.value(cvPath.value);111 price2 += cvOptionValue_ - cvPathPricer_.value(cvPath.value); 112 112 } 113 } 113 114 114 115 sampleAccumulator_.add((price+price2)/2.0, path.weight);