Maxima and Stochastic Calculus



Ciao Lorenzo,


As far as I know, the only package dealing with probabilistic models is
the 'distrib' one:
http://cvs.sourceforge.net/viewcvs.py/maxima/maxima/share/contrib/distrib/

which includes basic stuff for discrete and continuous distributions.
You can calculate densities, cumulative probabilities, first and second
moments and random simulation.

In particular, the lognormal distribution is also implemented; here is
an example:


/************  begin Maxima ***************/

(%i3) load(distrib)$

(%i5) /* density function */
      assume(x>0,s>0)$ denlogn(x,m,s);
                                     2
                         (log(x) - m)
                       - -------------
                                2
                             2 s
                     %e
(%o6)              ---------------------
                   sqrt(2) sqrt(%pi) s x
(%i7) /* distribution function */
      dislogn(x,m,s);
                        log(x) - m
                    erf(----------)
                        sqrt(2) s     1
(%o7)               --------------- + -
                           2          2
(%i8) /* kurtosis coefficient */
      kurlogn(m,s);
                   2          2          2
                4 s        3 s        2 s
(%o8)         %e     + 2 %e     + 3 %e     - 3
(%i9) /* random sample of size 7 for m=2 and s=1*/
      rlogn(2,1,7);
(%o9) [6.7102640819652, 15.81413232484992,
2.648651971238268, 28.90109420904617, 44.80131546192278,
1.558728229609015, 17.29526928162041]

/************  end Maxima ***************/


Densities are defined explicitly, not as derivatives of the distribution
functions.

Please, try it and give me your opinion; the package is still under
development and I accept suggestions (in particular those which are not
difficult to implement :-)

Best wishes.



El s??b, 04-02-2006 a las 15:03 +0000, L.Isella escribi??:
> Dear All,
> I have not been active on the Maxima mailing list for a long time.
> I am interested in stochastic calculus for financial applications and I recall some discussion about an implementation of the Ito stochastic calculus for Maxima.
> I wonder if Maxima can do anything like deriving the distribution of a random variable following a certain stochastic process, at least in some cases.
> For example, consider a stock S whose evolution is described by the geometric Brownian motion (BM) leading to Black and Scholes (BS) equation.
> A European option is defined by a certain payoff function depending on the underlying S and can be exercised only at a specific time, called maturity.
> As a consequence of the BM, stock returns are lognormally distributed.
> In the case of a complicated payoff, for which no analytical formula is available, one can still price the option e.g. by Monte Carlo simulating many lognormally distributed returns and take the option's expectation value.
> Depending on the process the stocks are expected to follow, their distribution will be different, but knowing it amounts to being able to price at least certain kinds of options.
> Many thanks
> 
> Lorenzo
> 
> Best regards
> 
> Lorenzo 
> 
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
-- 
Mario Rodriguez Riotorto
www.biomates.net