Is there any existing way for returning multiple values from
a MonteCarlo simulation? I can’t see a way for any of the existing
pricing engines. By this, I mean being able to calculate many different
values for each MC path (e.g. price, leg 1 value, leg 2 value, dv01 etc) and As far as I can see, I’d have to: Define a different traits (mctraits.hpp) struct which used a
PathPricer<path_type, VECTOR return type>. Use a GenericSequenceStatistics<GaussianStatistics> class
(instead of a GenericRiskStatistics<GaussianStatistics> class). Then either a) Define
arithmetic operations for the VECTOR return type or b) Write parts
of MonteCarloModel specialised (via class template) for the particular traits
class. Would this be correct? Thanks, Simon
This email is not intended to nor should it be taken to create any legal relations or contractual relationships. This email has originated from ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
On Wed, 2010-11-24 at 10:46 +0000, Simon Ibbotson wrote:
> Is there any existing way for returning multiple values from a > MonteCarlo simulation? I can’t see a way for any of the existing > pricing engines. No, existing ones don't do that. > As far as I can see, I’d have to: > > Define a different traits (mctraits.hpp) struct which used a > PathPricer<path_type, VECTOR return type>. > > Use a GenericSequenceStatistics<GaussianStatistics> class (instead of > a GenericRiskStatistics<GaussianStatistics> class). True and true. > Then either > > a) Define arithmetic operations for the VECTOR return type or > > b) Write parts of MonteCarloModel specialised (via class > template) for the particular traits class. No, I don't think you need to do that. SequenceStatistics doesn't do statistics on the passed vectors as such, it just maintains a set of 1-D statistics. This part should just work. Let me know how it goes, Luigi -- Better to have an approximate answer to the right question than a precise answer to the wrong question. -- John Tukey as quoted by John Chambers ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
The problem is that MonteCarloModel::addSamples(Size samples) does some simple arithmetic operations on the result_type. Also, McSimulation::value() and McSimulation::calculate() do some other simple operations. In the short-term, I've fully specialised the addSamples() function and defined some arithmetic operations for std::vector<double>. In the long-term, I'd prefer a cleaner solution. I'd suggest making GenericSequenceStatistics into a double template class - GenericRiskStatistics<GaussianStatistics,template <class> class TVector = std::vector> and create a specific TVector class for MonteCarlo simulations. What do you think? Simon > Then either > > a) Define arithmetic operations for the VECTOR return type or > > b) Write parts of MonteCarloModel specialised (via class > template) for the particular traits class. No, I don't think you need to do that. SequenceStatistics doesn't do statistics on the passed vectors as such, it just maintains a set of 1-D statistics. This part should just work. Let me know how it goes, Luigi This communication and any attachments contains information which is confidential and may be subject to legal privilege. It is for intended recipients only. If you are not the intended recipient you must not copy, distribute, publish, rely on or otherwise use it without our consent. Some of our communications may contain confidential information which it could be a criminal offence for you to disclose or use without authority. If you have received this email in error please notify [hidden email] immediately and delete the email from your computer. The FSA reserves the right to monitor all email communications for compliance with legal, regulatory and professional standards. This email is not intended to nor should it be taken to create any legal relations or contractual relationships. This email has originated from The Financial Services Authority (FSA) 25 The North Colonnade, Canary Wharf, London E14 5HS United Kingdom Registered as a Limited Company in England and Wales No.1920623. Registered Office as above Switchboard: 020 7066 1000 Web Site: http://www.fsa.gov.uk ***************************************************************** ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
On Fri, 2010-12-03 at 15:57 +0000, Simon Ibbotson wrote:
> The problem is that MonteCarloModel::addSamples(Size samples) does some > simple arithmetic operations on the result_type. Also, > McSimulation::value() and McSimulation::calculate() do some other simple > operations. Right, I overlooked those. Hmm. As far as I see, MonteCarloModel::addSamples would work if one used Array as the result type (it has algebra, and SequenceStatistics:add takes any container regardless of what it uses internally.) I don't see the calculations in McSimulation::value(), apart from the call to maxError that should work on any container. Does the thing work if you use just use Array as the result type, without other modifications? Luigi -- Better to have an approximate answer to the right question than a precise answer to the wrong question. -- John Tukey as quoted by John Chambers ------------------------------------------------------------------------------ This SF Dev2Dev email is sponsored by: WikiLeaks The End of the Free Internet http://p.sf.net/sfu/therealnews-com _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Unfortunately not; McSimulation::value() instantiates a result_type
(i.e. an Array) from a vector<double> obtained from the sampleAccumulator at several points (also in ::valueWithSamples()). Therefore, Array would need a new constructor either: 1) explicit Array(const std::vector<Real>&); or 2) template<class container> explicit Array(const container&, container::value_type redundant = 0); or 3) template <class T> explicit Array(const T&); plus specialisations for T=Array and T=Size etc. The first works only with a STL vector. The second one allows all STL containers but is opaque because of the redundant second parameter (required to specialise only for STL containers). The third means that the existing constructors are duplicated (or removed entirely). Which would you recommend? Simon -----Original Message----- From: Luigi Ballabio [mailto:[hidden email]] Sent: 09 December 2010 11:29 To: Simon Ibbotson Cc: [hidden email] Subject: RE: [Quantlib-dev] Returning multiple values from a Monte-Carlo pricing engine On Fri, 2010-12-03 at 15:57 +0000, Simon Ibbotson wrote: > The problem is that MonteCarloModel::addSamples(Size samples) does some > simple arithmetic operations on the result_type. Also, > McSimulation::value() and McSimulation::calculate() do some other simple > operations. Right, I overlooked those. Hmm. As far as I see, MonteCarloModel::addSamples would work if one used Array as the result type (it has algebra, and SequenceStatistics:add takes any container regardless of what it uses internally.) I don't see the calculations in McSimulation::value(), apart from the call to maxError that should work on any container. Does the thing work if you use just use Array as the result type, without other modifications? Luigi -- Better to have an approximate answer to the right question than a precise answer to the wrong question. -- John Tukey as quoted by John Chambers This communication and any attachments contains information which is confidential and may be subject to legal privilege. It is for intended recipients only. If you are not the intended recipient you must not copy, distribute, publish, rely on or otherwise use it without our consent. Some of our communications may contain confidential information which it could be a criminal offence for you to disclose or use without authority. If you have received this email in error please notify [hidden email] immediately and delete the email from your computer. The FSA reserves the right to monitor all email communications for compliance with legal, regulatory and professional standards. This email is not intended to nor should it be taken to create any legal relations or contractual relationships. This email has originated from The Financial Services Authority (FSA) 25 The North Colonnade, Canary Wharf, London E14 5HS United Kingdom Registered as a Limited Company in England and Wales No.1920623. Registered Office as above Switchboard: 020 7066 1000 Web Site: http://www.fsa.gov.uk ***************************************************************** ------------------------------------------------------------------------------ Lotusphere 2011 Register now for Lotusphere 2011 and learn how to connect the dots, take your collaborative environment to the next level, and enter the era of Social Business. http://p.sf.net/sfu/lotusphere-d2d _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
On Tue, 2010-12-14 at 12:48 +0000, Simon Ibbotson wrote:
> Unfortunately not; McSimulation::value() instantiates a result_type > (i.e. an Array) from a vector<double> obtained from the > sampleAccumulator at several points (also in ::valueWithSamples()). > > Therefore, Array would need a new constructor either: > > [...] > > Which would you recommend? Neither. You can use the existing Array(ForwardIterator begin, ForwardIterator end); and pass the begin() and end() of the vector. Luigi -- It is better to know some of the questions than all of the answers. -- James Thurber ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Unfortunately, that would mean producing a specialised template routine
for McSimulation::value() (and others) as we cannot instantiate both result_type of Array and result_type of double using begin() and end() arguments. That would take us back to the beginning of this email chain... I personally would go for a constructor of Array(const std::vector<double>&) for simplicity. Would you agree? Simon -----Original Message----- From: Luigi Ballabio [mailto:[hidden email]] Sent: 24 December 2010 09:55 To: Simon Ibbotson Cc: [hidden email] Subject: RE: [Quantlib-dev] Returning multiple values from a Monte-Carlo pricing engine On Tue, 2010-12-14 at 12:48 +0000, Simon Ibbotson wrote: > Unfortunately not; McSimulation::value() instantiates a result_type > (i.e. an Array) from a vector<double> obtained from the > sampleAccumulator at several points (also in ::valueWithSamples()). > > Therefore, Array would need a new constructor either: > > [...] > > Which would you recommend? Neither. You can use the existing Array(ForwardIterator begin, ForwardIterator end); and pass the begin() and end() of the vector. Luigi -- It is better to know some of the questions than all of the answers. -- James Thurber This communication and any attachments contains information which is confidential and may be subject to legal privilege. It is for intended recipients only. If you are not the intended recipient you must not copy, distribute, publish, rely on or otherwise use it without our consent. Some of our communications may contain confidential information which it could be a criminal offence for you to disclose or use without authority. If you have received this email in error please notify [hidden email] immediately and delete the email from your computer. The FSA reserves the right to monitor all email communications for compliance with legal, regulatory and professional standards. This email is not intended to nor should it be taken to create any legal relations or contractual relationships. This email has originated from The Financial Services Authority (FSA) 25 The North Colonnade, Canary Wharf, London E14 5HS United Kingdom Registered as a Limited Company in England and Wales No.1920623. Registered Office as above Switchboard: 020 7066 1000 Web Site: http://www.fsa.gov.uk ***************************************************************** ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
On Tue, 2011-01-04 at 10:22 +0000, Simon Ibbotson wrote:
> Unfortunately, that would mean producing a specialised template routine > for McSimulation::value() (and others) as we cannot instantiate both > result_type of Array and result_type of double using begin() and end() > arguments. That would take us back to the beginning of this email > chain... Oh, rats. > I personally would go for a constructor of Array(const > std::vector<double>&) for simplicity. Would you agree? Hmm, I don't like coupling Array and vector. I'd try doing it as locally as possible. For example, in McSimulation, we could use two template functions copy and combine (add? average?) instead of operator= and operator+ so that we can write specializations for double and Array/vector. -- All generalizations are dangerous, even this one. -- Alexandre Dumas ------------------------------------------------------------------------------ Gaining the trust of online customers is vital for the success of any company that requires sensitive data to be transmitted over the Web. Learn how to best implement a security strategy that keeps consumers' information secure and instills the confidence they need to proceed with transactions. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Free forum by Nabble | Edit this page |