Hi,
I would like to understand something about LsmBasisSystem In particular LsmBasisSystem::LsmBasisSystem(Size dim, Size order, PolynomType polynomType); What is the relationship between the dimension (dim) and the size of the state returned by Array EarlyExercisePathPricer<MultiPath>::state(); Do they need to be the same? It still works if they are different. What does it do? (I haven't stepped through the code yet). ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Andrea
On Friday 11 September 2009 22:39:53 Andrea wrote: > > In particular LsmBasisSystem::LsmBasisSystem(Size dim, Size order, > PolynomType polynomType); > > What is the relationship between the dimension (dim) and the size of the > state returned by > > Array EarlyExercisePathPricer<MultiPath>::state(); > They should have the same size. if dim < size of state returned, the states variables from dim to size-1 will be ignored within the regression. The behaviour for dim > size is undefined. At least for this case one I'm going to add a QL_REQUIRE to avoid it. best regards Klaus ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On 12/09/09 18:49, Klaus Spanderen wrote:
> They should have the same size. if dim< size of state returned, the states > variables from dim to size-1 will be ignored within the regression. The > behaviour for dim> size is undefined. At least for this case one I'm going > to add a QL_REQUIRE to avoid it. > I've seen your change inline Real f_workaround(const Array& a, Size i) { QL_REQUIRE(i < a.size(), "dimension of the basis system is too large"); return a[i]; } but it still behaves the same. As far as I understand, in this example void foo() { std::vector<boost::function1<Real, Array> > v = LsmBasisSystem::multiPathBasisSystem(2, 2, LsmBasisSystem::Monomial); Array foo1(1); foo1[0] = 1.0; std::cout << v[0](foo1) << std::endl; Array foo2(2); foo2[0] = 1.0; foo2[1] = 1.0; std::cout << v[0](foo2) << std::endl; Array foo3(4); foo3[0] = 1.0; foo3[1] = 1.0; foo3[2] = 1.0; std::cout << v[0](foo3) << std::endl; } foo1 should trigger QL_REQUIRE foo2 is OK, foo3[2] is ignored. But it prints 1 1 1 Just to be sure, I've tried to define QL_EXTRA_SAFETY_CHECKS at the very top of my source code. (no exception is thrown). Do I need also to recompile QL? Or have I misunderstood the dimensions? I have to admit I am completely lost with the boost binders used in the basis system. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Andrea
thanks for the example. The "problem" is that LsmBasisSystem::multiPathBasisSystem(2, 2, LsmBasisSystem::Monomial); returns the following basis system { 1.0, x[0], x[1], x[0]^2, x[1]^2, x[0]*x[1] }. Therefore v[0](foo1) and v[1](foo1) will pass whereas v[2](foo1) will cause the error you've expected. I agree this is not the expected behaviour. Therefore I've checked in another version. Now v[...] will fail if x.size() != dim (hopefully;-). Thanks for your advice. best regards Klaus ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On 13/09/09 21:38, Klaus Spanderen wrote:
> Hi Andrea > > thanks for the example. The "problem" is that > LsmBasisSystem::multiPathBasisSystem(2, 2, LsmBasisSystem::Monomial); > returns the following basis system > { 1.0, x[0], x[1], x[0]^2, x[1]^2, x[0]*x[1] }. > Thanks for the explanation. Using '[0]' was misleading, I should have tried all indices. Will try again to be sure I understand. > Therefore v[0](foo1) and v[1](foo1) will pass whereas v[2](foo1) will cause > the error you've expected. > > I agree this is not the expected behaviour. Therefore I've checked in another > version. Now v[...] will fail if x.size() != dim (hopefully;-). > > Thanks for your advice. > > best regards > Klaus ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |