From: Joel Reymont
Subject: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <1122197410.310643.33440@g49g2000cwa.googlegroups.com>
Folks,

How would Lisp stack up in numerical analysis against a
high-performance Scheme like Gambit?

I'm talking about things like partial differential equations, neural
networks and the like.

Gambit does get an extra lift from GCC optimizations when the generated
C code is compiled. 

    Thanks, Joel

From: Pascal Bourguignon
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <873bq4wm4n.fsf@thalassa.informatimago.com>
"Joel Reymont" <······@gmail.com> writes:
> How would Lisp stack up in numerical analysis against a
> high-performance Scheme like Gambit?
>
> I'm talking about things like partial differential equations, neural
> networks and the like.
>
> Gambit does get an extra lift from GCC optimizations when the generated
> C code is compiled. 

gcl generates C source compiled by gcc too.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

In a World without Walls and Fences, 
who needs Windows and Gates?
From: Paolo Amoroso
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <873bq4bhsm.fsf@plato.moon.paoloamoroso.it>
"Joel Reymont" <······@gmail.com> writes:

> How would Lisp stack up in numerical analysis against a

This recent thread might provide useful information:

  http://groups-beta.google.com/group/comp.lang.lisp/browse_thread/thread/f73dd33ea4727dce/066c16302f8dee95#066c16302f8dee95


Paolo
-- 
Why Lisp? http://lisp.tech.coop/RtL%20Highlight%20Film
Recommended Common Lisp libraries/tools:
- ASDF/ASDF-INSTALL: system building/installation
- CL-PPCRE: regular expressions
- UFFI: Foreign Function Interface
From: Jens Axel Søgaard
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <42e37c59$0$2351$edfadb0f@dread11.news.tele.dk>
Joel Reymont wrote:
> How would Lisp stack up in numerical analysis against a
> high-performance Scheme like Gambit?
> 
> I'm talking about things like partial differential equations, neural
> networks and the like.

Have you tried some small examples?

Since you mention partial differential equations, Luciers's pages,
are worth a visit:

     <http://www.math.purdue.edu/~lucier/615/software/>

-- 
Jens Axel S�gaard
From: Nicolas Neuss
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <87zmsc5ry4.fsf@ortler.iwr.uni-heidelberg.de>
"Joel Reymont" <······@gmail.com> writes:

> Folks,
>
> How would Lisp stack up in numerical analysis against a
> high-performance Scheme like Gambit?
>
> I'm talking about things like partial differential equations, neural
> networks and the like.

I think, you will have to ask a more specific question.  For PDEs, there is
my CL code FEMLISP, for Scheme there is a code by Brad Lucier.  The
strengths of both codes are different, so a reasonable comparison is
unclear.  If you can think of a nice sample PDE problem, I may try to solve
it.

Nicolas.
From: Joel Reymont
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <1122207927.387999.48790@o13g2000cwo.googlegroups.com>
I was just scratching my head and thinking if Gambit was drastically
faster. I suppose not necessarily is the right answer. Thanks!
From: Joel Reymont
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <1122209849.638669.220360@z14g2000cwz.googlegroups.com>
This page is right on the money:

http://openmap.bbn.com/~kanderso/performance/
From: Joel Reymont
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <1122212943.495573.174330@f14g2000cwb.googlegroups.com>
I also agree with Nicolas that just-in-time compilation will be
particularly useful.

http://wagerlabs.com/uptick/2005/07/compiled-lambda-expressions.html

I wish I could obtain the materials from John Amuedo's "Optimizing
Numerical Performance with Symbolic Computation", Roger Dannenberg's
"Functional Programming for Signal Processing" or Lynn Quam's
"Performance Beyond Expectations" presentations from ILC 2005.

Anyone pointers?
From: Russell McManus
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <87pst8f8ae.fsf@cl-user.org>
Nicolas Neuss <·······@iwr.uni-heidelberg.de> writes:

> If you can think of a nice sample PDE problem, I may try to solve
> it.

How about valuing an american style put option?

-russ
From: Nicolas Neuss
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <87ackb61eh.fsf@ortler.iwr.uni-heidelberg.de>
Russell McManus <···············@yahoo.com> writes:

> Nicolas Neuss <·······@iwr.uni-heidelberg.de> writes:
>
>> If you can think of a nice sample PDE problem, I may try to solve
>> it.
>
> How about valuing an american style put option?

That is too vague.  I need the equation, the coefficients and the domain of
definition.  Further: what is the goal functional and which accuracy does
have to be obtained?

Nicolas.
From: GP lisper
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <1122275728.12530895196a65f11069fe0f6d84a81e@teranews>
On Mon, 25 Jul 2005 04:54:30 +0200, <·······@iwr.uni-heidelberg.de> wrote:
>
>
> Russell McManus <···············@yahoo.com> writes:
>
>> Nicolas Neuss <·······@iwr.uni-heidelberg.de> writes:
>>
>>> If you can think of a nice sample PDE problem, I may try to solve
>>> it.
>>
>> How about valuing an american style put option?
>
> That is too vague.  I need the equation, the coefficients and the domain of
> definition.  Further: what is the goal functional and which accuracy does
> have to be obtained?

There are several classic heat flow problems found in PDE texts (or at
least there were in my day).  An insulated bar uniformly heated at one
end for instance.

A PDE wouldn't "value" american options anyway.


-- 
[ingvar] Modelling forest damage by storms with regular expressions is...
  a curious idea.
[Xach] before: |||  after: //_
[Xach] seems easy enough to me
From: Russell McManus
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <87iryzfadf.fsf@cl-user.org>
GP lisper <········@CloudDancer.com> writes:

> A PDE wouldn't "value" american options anyway.

What do you mean by this?  PDE techniques are most certainly used to
value american style options.

-russ
From: GP lisper
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <1122300147.e275d953a81cd032de6260e7c4327ba4@teranews>
On Mon, 25 Jul 2005 06:28:12 -0400, <···············@yahoo.com> wrote:
>
>
>
> GP lisper <········@CloudDancer.com> writes:
>
>> A PDE wouldn't "value" american options anyway.
>
> What do you mean by this?  PDE techniques are most certainly used to
> value american style options.

Only for people living in ivory towers.


-- 
[ingvar] Modelling forest damage by storms with regular expressions is...
  a curious idea.
[Xach] before: |||  after: //_
[Xach] seems easy enough to me
From: Russell McManus
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <87wtneex2h.fsf@cl-user.org>
GP lisper <········@CloudDancer.com> writes:

>> What do you mean by this?  PDE techniques are most certainly used to
>> value american style options.
>
> Only for people living in ivory towers.

How can you possibly assert global knowledge of what other people do
with PDE techniques?  I guess it's just flamebait.

Anyway, I have personally worked on an options market making system
that uses PDEs to value options.  This is a production system for a
top three market maker in US listed equity options.  Draw your own
conclusions.

-russ
From: GP lisper
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <1122331505.b55beb72d1fa57321acd04f8253d26c0@teranews>
On Mon, 25 Jul 2005 11:15:34 -0400, <···············@yahoo.com> wrote:
>
>
>
> GP lisper <········@CloudDancer.com> writes:
>
>>> What do you mean by this?  PDE techniques are most certainly used to
>>> value american style options.
>>
>> Only for people living in ivory towers.
>
> How can you possibly assert global knowledge of what other people do
> with PDE techniques?  I guess it's just flamebait.
>
> Anyway, I have personally worked on an options market making system
> that uses PDEs to value options.  This is a production system for a
> top three market maker in US listed equity options.  Draw your own
> conclusions.

oh my!  millions of lemmings jump off cliffs, your logic makes that
right I see.

Floor traders love people like you.  Me too!


-- 
[ingvar] Modelling forest damage by storms with regular expressions is...
  a curious idea.
[Xach] before: |||  after: //_
[Xach] seems easy enough to me
From: Cameron MacKinnon
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <ELadnZiugKr88XjfRVn-vw@rogers.com>
GP lisper wrote:
> On Mon, 25 Jul 2005 11:15:34 -0400, <···············@yahoo.com> wrote:
> 
>>Anyway, I have personally worked on an options market making system
>>that uses PDEs to value options.  This is a production system for a
>>top three market maker in US listed equity options.  Draw your own
             ^^^^^^^^^^^^
>>conclusions.
> 
> Floor traders love people like you.  Me too!

Apparently so -- they pay him.

-- 
Cameron MacKinnon
Toronto, Canada
From: Russell McManus
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <877jfee7nz.fsf@cl-user.org>
GP lisper <········@CloudDancer.com> writes:

> oh my!  millions of lemmings jump off cliffs, your logic makes that
> right I see.
>
> Floor traders love people like you.  Me too!

We run a floor operation as market maker, too, and have been making
money at it for years.  Go figure.  Existence proofs are hard to
refute, aren't they?

-russ
From: Russell McManus
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <87zms9c0iv.fsf@cl-user.org>
Paul Foley <···@below.invalid> (http://public.xdi.org/=pf) writes:

> On Mon, 25 Jul 2005 20:24:16 -0400, Russell McManus wrote:
>
>> GP lisper <········@CloudDancer.com> writes:
>
>>> oh my!  millions of lemmings jump off cliffs, your logic makes that
>>> right I see.
>>> 
>>> Floor traders love people like you.  Me too!
>
>> We run a floor operation as market maker, too, and have been making
>> money at it for years.  Go figure.  Existence proofs are hard to
>> refute, aren't they?
>
> LTCM

I claimed that people exist who use PDE techniques to value options in
the real world (as opposed to the "ivory tower").  In what way does
the invocation of the long term capital management bogeyman argue
against my claim?  Please enlighten me.

-russ
From: Cameron MacKinnon
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <IYOdnYt-prA31nvfRVn-hQ@rogers.com>
Paul Foley (http://public.xdi.org/=pf) wrote:
> On Tue, 26 Jul 2005 06:41:28 -0400, Russell McManus wrote:
> 
>>I claimed that people exist who use PDE techniques to value options in
>>the real world (as opposed to the "ivory tower").  In what way does
>>the invocation of the long term capital management bogeyman argue
>>against my claim?  Please enlighten me.
> 
> 
> It doesn't.  I thought you were making the stronger claim that solving
> these equations gives some sort of objectively correct valuation.

Which term of the equation do you feel to be subjective? Alternatively, 
which assumption underlying the equation do you feel is flawed?

> [I.e., that you can successfully predict other people's future actions]
> 
> No doubt people exist who use fortune tellers and similar "techniques"
> to value options in the real world, too.  So what?

Actuaries seem to do a pretty good job of predicting people's future 
actions. Do you consider actuarial science to be akin to fortune 
telling, too?

-- 
Cameron MacKinnon
Toronto, Canada
From: Matthias
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <36wpst7pb51.fsf@hundertwasser.ti.uni-mannheim.de>
GP lisper <········@CloudDancer.com> writes:

> On Mon, 25 Jul 2005 04:54:30 +0200, <·······@iwr.uni-heidelberg.de> wrote:
> >
> >
> > Russell McManus <···············@yahoo.com> writes:
> >
> >> Nicolas Neuss <·······@iwr.uni-heidelberg.de> writes:
> >>
> >>> If you can think of a nice sample PDE problem, I may try to solve
> >>> it.
> >>
> >> How about valuing an american style put option?
> >
> > That is too vague.  I need the equation, the coefficients and the domain of
> > definition.  Further: what is the goal functional and which accuracy does
> > have to be obtained?
> 
> There are several classic heat flow problems found in PDE texts (or at
> least there were in my day).  An insulated bar uniformly heated at one
> end for instance.
> 
> A PDE wouldn't "value" american options anyway.

The Black-Scholes PDE essentially _is_ a heat flow problem.  Solving
it is the essential step in valuation of simple options.  But I agree
that a simple physical problem might make a better benchmark.
From: Nicolas Neuss
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <87fyu3nu2r.fsf@ortler.iwr.uni-heidelberg.de>
GP lisper <········@CloudDancer.com> writes:

>> That is too vague.  I need the equation, the coefficients and the domain of
>> definition.  Further: what is the goal functional and which accuracy does
>> have to be obtained?
>
> There are several classic heat flow problems found in PDE texts (or at
> least there were in my day).  An insulated bar uniformly heated at one
> end for instance.

First: domain, equation, coefficients, boundary and initial conditions, and
goal functional (quantity of interest)?

Second: if your equation is too simple, one might get the idea to use a
known solution or other shortcuts.

Nicolas.
From: Ray Dillinger
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <HWlTe.12323$p%3.49870@typhoon.sonic.net>
Nicolas Neuss wrote:
> Russell McManus <···············@yahoo.com> writes:
> 
> 
>>Nicolas Neuss <·······@iwr.uni-heidelberg.de> writes:
>>
>>
>>>If you can think of a nice sample PDE problem, I may try to solve
>>>it.
>>
>>How about valuing an american style put option?
> 
> 
> That is too vague.  I need the equation, the coefficients and the domain of
> definition.  Further: what is the goal functional and which accuracy does
> have to be obtained?
> 

Hmmm. It's actually an interesting little problem.
A put option is an option to sell a certain asset
at a future date at a given price.

It never has value less than zero, because if the
market price for that asset is above the option
price at maturity you don't have to exercise it.

On the other hand, if the market price at the put
option's maturity is below the option price, then
the difference is realized as profit, because you
can buy on the open market and sell at the option
price at the same time.

So, that's the fundamental parameters of a put option.

It gets interesting though, because at some future
point *before* the maturity of the put option, you
may see the market fluctuate;  So if you've got a
put option for 100oz. of gold at $390/oz in 90
days, for example, and the price dips to $370 an
ounce on day 30, you can buy your 100oz. of gold to
"hold" for 60 days and then sell at a price of at
least $390/oz, thus assuring that you make a profit
whether the market is up (in which case you sell
your gold at the market price and don't exercise
your option) or down (in which case you exercise
your option to sell gold you just bought without
taking a loss, at a price above the market price).

So in order to value a put option, we have to know
some way to characterize the scope and probability
of expected market fluctuations (statistics will
work here I suppose) in the value of the asset
optioned over the lifetime of the option.  And we
have to develop an "optimal" strategy given those
assumptions for the circumstances under which the
option holder should choose to cover his option
by buying the matching asset, using the Kelly
criterion.  Finally, given that strategy we can
find the real current value of a put option.

It's tricky.  But reasonably well-defined.

			Bear
From: Joe Marshall
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <d5nmkkan.fsf@alum.mit.edu>
Ray Dillinger <····@sonic.net> writes:

> Nicolas Neuss wrote:
>> Russell McManus <···············@yahoo.com> writes:
>>
>>>Nicolas Neuss <·······@iwr.uni-heidelberg.de> writes:
>>>
>>>
>>>>If you can think of a nice sample PDE problem, I may try to solve
>>>>it.
>>>
>>>How about valuing an american style put option?
>> That is too vague.  I need the equation, the coefficients and the
>> domain of
>> definition.  Further: what is the goal functional and which accuracy does
>> have to be obtained?
>>
>
> [put option explanation elided]

At 

  http://home.earthlink.net/~millerrisk/Papers/MathematicaOptions.htm

Ross Miller goes into detail about valuation of call options.

Where

> A put option is an option to sell a certain asset
> at a future date at a given price.

A call option is an option to *buy* a certain asset at a future date
at a given price.  And like a put option: 

> It never has value less than zero, because if the
> market price for that asset is above the option
> price at maturity you don't have to exercise it.
>
> On the other hand, if the market price at the put
> option's maturity is below the option price, then
> the difference is realized as profit, because you
> can buy on the open market and sell at the option
> price at the same time.

except the the sign is reversed.

In the paper, Miller gives the Black-Scholes model of option valuation
and shows how to derive the `value' of an option given the current
stock price, the exercise price of the option, the volatility of the
stock, the time until expiration of the option, and the rate of return
on a risk-free investment.

The interesting thing is that Miller did all this in Lisp.  The
unfortunate thing is that he has since translated it all to
Mathematica.
From: GP lisper
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <1126057683.21d42f3c541fe092ee6cd8dc1ed6ade8@teranews>
On Tue, 06 Sep 2005 16:34:08 -0400, <·········@alum.mit.edu> wrote:
>
> At 
>
>   http://home.earthlink.net/~millerrisk/Papers/MathematicaOptions.htm
>
> In the paper, Miller gives the Black-Scholes model of option valuation
> and shows how to derive the `value' of an option given the current
> stock price, the exercise price of the option, the volatility of the
> stock, the time until expiration of the option, and the rate of return
> on a risk-free investment.
>
> The interesting thing is that Miller did all this in Lisp.  The
> unfortunate thing is that he has since translated it all to
> Mathematica.

Is there a link to this lisp-based paper someplace Joe?


-- 
Program A uses CLOS, Program B is implemented with structs, leading
to a fourfold increase in execution speed.  --J. B. Heimatseiten
From: Joe Marshall
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <oe743ixt.fsf@alum.mit.edu>
GP lisper <········@CloudDancer.com> writes:

> On Tue, 06 Sep 2005 16:34:08 -0400, <·········@alum.mit.edu> wrote:
>>
>> At 
>>
>>   http://home.earthlink.net/~millerrisk/Papers/MathematicaOptions.htm
>>
>> In the paper, Miller gives the Black-Scholes model of option valuation
>> and shows how to derive the `value' of an option given the current
>> stock price, the exercise price of the option, the volatility of the
>> stock, the time until expiration of the option, and the rate of return
>> on a risk-free investment.
>>
>> The interesting thing is that Miller did all this in Lisp.  The
>> unfortunate thing is that he has since translated it all to
>> Mathematica.
>
> Is there a link to this lisp-based paper someplace Joe?

I haven't found one.  I wish there were.  I've been tempted to try to
translate the Mathematica code, but there might be something easier to
try.
From: JRLaws
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <b34bc$43226a98$41873e07$756@DIALUPUSA.NET>
>>Is there a link to this lisp-based paper someplace Joe?
> 
> 
> I haven't found one.  I wish there were.  I've been tempted to try to
> translate the Mathematica code, but there might be something easier to
> try.

A bit about the Black and Scholes Model is here: 
http://bradley.bradley.edu/~arr/bsm/pg04.html

and in various programming languages here: 
http://www.espenhaug.com/black_scholes.html

I am a lisp noob and can not help with the code, but I have complete 
faith in the good people's ability here at c.l.l

Good luck.
From: Christophe Rhodes
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <sqr7c2yp0r.fsf@cam.ac.uk>
Ray Dillinger <····@sonic.net> writes:

> [ valuing options ]
>
> It's tricky.  But reasonably well-defined.

One thing you left out, which makes this problem rather less
well-defined, is that the _actual_ value of an option is worth what
people are willing to pay for it.  See also Long Term Capital
Management...

Christophe
From: GP lisper
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <1126056963.820de1b3077ab0b0b06d520a03e142d8@teranews>
On Tue, 06 Sep 2005 20:28:20 +0100, <·····@cam.ac.uk> wrote:
> Ray Dillinger <····@sonic.net> writes:
>
>> [ valuing options ]
>>
>> It's tricky.  But reasonably well-defined.

to some

> Also see Long Term Capital Management

see the movie, PBS  "Trillion Dollar Bet"

'Past history is not an indicator of future gains'
and neither is a PhD.


-- 
Program A uses CLOS, Program B is implemented with structs, leading
to a fourfold increase in execution speed.  --J. B. Heimatseiten
From: Marc Battyani
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <11e7v7rj3oikm28@corp.supernews.com>
"Joel Reymont" <······@gmail.com> wrote :
> Folks,
>
> How would Lisp stack up in numerical analysis against a
> high-performance Scheme like Gambit?
>
> I'm talking about things like partial differential equations, neural
> networks and the like.
>
> Gambit does get an extra lift from GCC optimizations when the generated
> C code is compiled.

If you want very fast floating point performance, you should use the SIMD
extension like SSE3 or equivalent on general hardware processors.

If you want very very fast performance for big financial computations, like
Monte-Carlo simulations or simulated annealing for instance, then you should
look at dedicated hardware likeFPGA, DSP, etc. (I'm working on such a
project now).

BTW does somebody knows if there is some usable simulated annealing code in
Common Lisp (other than the 15 liners homeworks solutions I've found with
google) ?

Marc
From: Paolo Amoroso
Subject: Re: Numerical analysis in Lisp vs. Gambit Scheme
Date: 
Message-ID: <87sly3t9zx.fsf@plato.moon.paoloamoroso.it>
"Marc Battyani" <·············@fractalconcept.com> writes:

> BTW does somebody knows if there is some usable simulated annealing code in
> Common Lisp (other than the 15 liners homeworks solutions I've found with
> google) ?

This code by Norvig for AIMA may also qualify as homework-style:

  http://aima.cs.berkeley.edu/lisp/search/algorithms/iterative.lisp


Paolo
-- 
Why Lisp? http://lisp.tech.coop/RtL%20Highlight%20Film
Recommended Common Lisp libraries/tools:
- ASDF/ASDF-INSTALL: system building/installation
- CL-PPCRE: regular expressions
- UFFI: Foreign Function Interface