SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
VivienB
Posts: 130
Joined: August 6th, 2012, 3:32 pm

F# / F Sharp

May 28th, 2013, 11:12 am

QuoteOriginally posted by: chocolatemoneyYes, we all agree on a mixed model, benefiting from the best of both worlds.Happy to read that my initial guess, back on Friday, has been confirmed.@Vivien:"I don't see where you need states. I think PDE can be implemented in a pure functional style without using monad (or imperative prog)."State, in my mind, is for example applying the scheme on the lattice from t=now to T=expiry, following the application of the ICs and eventually doing something else at expiry.I guess you refer to "lack of mutability" - I call it "state".I thought a monad could take care of the work pipeline.Ok I understand. The application of the ICs can also be done outside the pure FP part (eg we can have a function that take a vector and return a vector, the vector inputed has the IC applied).QuoteOriginally posted by: chocolatemoney*PURE* Functional programming (scala) is something very new to me - I have been working with Scala for something like 1-2 years.I'd be happy to see your pure functional implementation of a PDE solver, if you could share...PS: Is F# the language of choice at LexiFi?I don't have pure functional implementation of a PDE solver, it is mixed with imperative and OOP. In the past it were much more functionnal, but it was too slow, then we replaced some functional part with imperative, what drastically increased speed.About the language we use at LexiFi, it is mainly OCaml (when LexiFi was created, I don't think that F# existed, the choice were between OCaml and Haskell).
 
User avatar
Cuchulainn
Posts: 62591
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

F# / F Sharp

May 28th, 2013, 11:24 am

QuoteI don't have pure functional implementation of a PDE solver, it is mixed with imperative and OOP. In the past it were much more functionnal, but it was too slow, then we replaced some functional part with imperative, what drastically increased speed.Modelling-wise, PDEs are structural things, so a pure FP way to model them would be difficult IMO. However, PDE contains as well a bunch of FP functions, yes?
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
Cuchulainn
Posts: 62591
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

F# / F Sharp

May 28th, 2013, 11:31 am

QuoteOriginally posted by: chocolatemoneyPestering the thread again.Hey, I am not sure I am going in the right direction, but here is a state monad in scala.The idea is that the monad could pass along the lattice, instead of the fibonacci serie, and do all that has to be done.Bad idea?Looks kind of complicated. But maybe that's just me. Do you have any simpler examples? e.g. sum the elements of a vector, print the even-valued elements in a vector, propagate data changes in vector starting at 0.
Last edited by Cuchulainn on May 27th, 2013, 10:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
Cuchulainn
Posts: 62591
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

F# / F Sharp

May 28th, 2013, 12:03 pm

QuoteI don't have pure functional implementation of a PDE solver, it is mixed with imperative and OOP. In the past it were much more functionnal, but it was too slow, then we replaced some functional part with imperative, what drastically increased speed.Why? All that currying and bindin' and stuff like that? Is it stack-based? Is it all run-time?
Last edited by Cuchulainn on May 27th, 2013, 10:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
VivienB
Posts: 130
Joined: August 6th, 2012, 3:32 pm

F# / F Sharp

May 28th, 2013, 12:15 pm

QuoteOriginally posted by: CuchulainnQuoteI don't have pure functional implementation of a PDE solver, it is mixed with imperative and OOP. In the past it were much more functionnal, but it was too slow, then we replaced some functional part with imperative, what drastically increased speed.Why? All that currying and bindin' and stuff like that? Is it stack-based? Is it all run-time?I don't remeber exactly, but we used a lot of functors, the change of variable were represented with function instead of beeing directly applied to vectors, etc.
 
User avatar
Cuchulainn
Posts: 62591
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

F# / F Sharp

May 28th, 2013, 12:19 pm

QuoteOriginally posted by: VivienBQuoteOriginally posted by: CuchulainnQuoteI don't have pure functional implementation of a PDE solver, it is mixed with imperative and OOP. In the past it were much more functionnal, but it was too slow, then we replaced some functional part with imperative, what drastically increased speed.Why? All that currying and bindin' and stuff like that? Is it stack-based? Is it all run-time?I don't remeber exactly, but we used a lot of functors, the change of variable were represented with function instead of beeing directly applied to vectors, etc.I was considering various domain transformers y = S/(S + a), tanh(S) on 1/2 s^2 S^2 using a single binded functor in C++, but chose instead for a separate PDE for each transformer...
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
VivienB
Posts: 130
Joined: August 6th, 2012, 3:32 pm

F# / F Sharp

May 28th, 2013, 12:37 pm

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: VivienBQuoteOriginally posted by: CuchulainnQuoteI don't have pure functional implementation of a PDE solver, it is mixed with imperative and OOP. In the past it were much more functionnal, but it was too slow, then we replaced some functional part with imperative, what drastically increased speed.Why? All that currying and bindin' and stuff like that? Is it stack-based? Is it all run-time?I don't remeber exactly, but we used a lot of functors, the change of variable were represented with function instead of beeing directly applied to vectors, etc.I was considering various domain transformers y = S/(S + a), tanh(S) on 1/2 s^2 S^2 using a single binded functor in C++, but chose instead for a separate PDE for each transformer...In our current framework the change of variable is an imput of the PDE, but we are limited to the change of variable of the form S(t) = f(t)g(x), then g has to be applied only once, and the transformation of the pde is fast enough.
 
User avatar
Cuchulainn
Posts: 62591
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

F# / F Sharp

May 29th, 2013, 8:15 am

How do you impart design intent in F# and OCaml? At code level or higher-level aids? e.g. explaining a state monad by a 'language' that everyone understands, initially. Think of when you are in a team of people.
Last edited by Cuchulainn on May 28th, 2013, 10:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
VivienB
Posts: 130
Joined: August 6th, 2012, 3:32 pm

F# / F Sharp

May 29th, 2013, 2:10 pm

Most time when I explain OCaml I start with a simple example that use a lot of aspect of FP: I design a simple calculus algebra, that can be represented with algebraic data types, and I write a function that evaluate expressions using pattern matching, recursion, etc.Edit: Typo.
Last edited by VivienB on May 28th, 2013, 10:00 pm, edited 1 time in total.
 
User avatar
chocolatemoney
Topic Author
Posts: 322
Joined: October 8th, 2008, 6:50 am

F# / F Sharp

May 29th, 2013, 2:34 pm

QuoteOriginally posted by: VivienBMost time when I explain OCaml I start with a simple example that use a lot of aspect of FP: I design a simple calculus algebra, that can be represented with algebraic data types, and I write a function that evaluate expressions using pattern matching, resistivity, etc.What is resistivity in this context?
 
User avatar
VivienB
Posts: 130
Joined: August 6th, 2012, 3:32 pm

F# / F Sharp

May 29th, 2013, 3:09 pm

QuoteOriginally posted by: chocolatemoneyQuoteOriginally posted by: VivienBMost time when I explain OCaml I start with a simple example that use a lot of aspect of FP: I design a simple calculus algebra, that can be represented with algebraic data types, and I write a function that evaluate expressions using pattern matching, resistivity, etc.What is resistivity in this context?Resistivity in this context is a typo (maybe due to my spell checker) The good word is recursion.
 
User avatar
chocolatemoney
Topic Author
Posts: 322
Joined: October 8th, 2008, 6:50 am

F# / F Sharp

July 24th, 2013, 1:46 pm

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: chocolatemoneyPestering the thread again.Hey, I am not sure I am going in the right direction, but here is a state monad in scala.The idea is that the monad could pass along the lattice, instead of the fibonacci serie, and do all that has to be done.Bad idea?Looks kind of complicated. But maybe that's just me. Do you have any simpler examples? e.g. sum the elements of a vector, print the even-valued elements in a vector, propagate data changes in vector starting at 0.I just noticed this comment that branched out.I really enjoyed this: http://learnyouahaskell.com/a-fistful-of-monads
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On