[Haskell-beginners] library for lattice data structure

James Toll james at jtoll.com
Wed Mar 12 00:51:23 UTC 2014


Hi,

I have a general question regarding data structures, maybe functional data structures, in Haskell and I’m hoping for some advice.  I would like to implement the binomial option pricing model in Haskell.

https://en.wikipedia.org/wiki/Binomial_options_pricing_model

Given its lattice structure, I originally thought of trying a recursive implementation, but because it’s recombining, the interior nodes would be calculated twice.  Although the implementation might be elegant, it doesn’t seem inefficient. Therefore I’ve been searching through Hackage for a data structure library that might lend itself to this problem.  There are a ton of libraries and as I don’t have any experience with them, I was hoping someone could provide some advice to narrow the field.

Some of the packages I've found so far are:

lattices package
http://hackage.haskell.org/package/lattices
From the name I thought this might be perfect, but the documentation is very terse and there doesn’t appear to be any other documentation so I’m not even sure how to get started with constructing a lattice with this package.

matrix package
https://hackage.haskell.org/package/matrix
This package seems fairly straightforward, and a matrix would work (it’s probably what I would use in R), but it doesn’t seem ideal.  There are other more sophisticated packages with matrices like hmatrix and repa but they seem like overkill unless this package is just slow.

vector package
https://hackage.haskell.org/package/vector
Vectors might also work for a data structure, but a matrix just seems like it would be easier.

I thought this example implementation in Haskell was intriguing but it doesn’t sound as though it’s very quick.
http://www.thulasidas.com/2009-03/a-new-kind-of-binomial-tree.htm

Any advice on an appropriate data structure in Haskell for the problem?  The solution doesn’t necessarily have to include a package. 

Thanks


James






More information about the Beginners mailing list