Mantegna Algorithm
Mantegna Algorithm
Fast, accurate algorithm for numerical simulation of Levy stable stochastic processes
Rosario Nunzio Mantegna
We propose a fast and accurate algorithm generating Levy stable stochastic processes of arbitrary in-
dex a ranging between 0.3 and 1.99. The scale parameter is also controllable. The algorithm is very fast
when a lies between 0.75 and 1.95.
a of the distribution does not control only the wings of The analogy between Eqs. (8} and (9} and Eqs. (4) and (5)
distribution, it also a8'ects the value of the distribution at is quite remarkable. Unfortunately, it is not possible to
the origin. In fact, starting from Eq. (1), it can be shown choose a couple of values for o and 0. that satisfy the
that following conditions simultaneously for an arbitrary
I (1/a) value of a:
&{X C, s(a)=C, (rr, or, a),
A number of other properties are reported in the litera-
ture [12,13] for stable distributions (asymptotic approxi-
L, (0)=P(u=0) .
mations, numerical values, etc. ). These conditions are jointly satisfied for + = 1 only by a
couple of values (cr„=cr =1). In this case, the distribu-
III. THE ALGORITHM tion P(u) coincides with a Cauchy distribution character-
ized by @=1 [L, , (u)]. As the standard deviations cr„
During the past years, a huge number of numerical and 0. cannot be chosen independently for an arbitrary
simulations of power-law distributed stochastic processes value of a, we set 0. = 1. After this setting, we determine
have been carried out [3, 13,14]. Obviously it is quite sim-
ple to write down an algorithm for numerical simulation
,
the value of 0. by requiring that the asymptotic values of
P(u) coincide with the asymptotic values of L 1(u), i.e.,
of stochastic variables characterized by a power-law dis- we determine O. „by
solving the equation
tribution, however, the processes obtained with a simple
algorithm are not Levy stable because the probability CLs(a)=C, (o„,l, a) .
density is difFerent from the value expected starting from
Eq. (1) for z =0 when z =0. We already stated in the In- By using Eqs. (4) and (8), we obtain
1/a
troduction that a sum of several independent variables I (1+a )sin(tra/2)
having the same power-law distribution will eventually o, (a)= I ((1+a)/2)a2' (12)
converge to the Levy stable process characterized by the
same asymptotic power law. In the following, we will With this choice, the distributions of Eqs. (7) and (1) have
show that this convergence is usually quite slow, more- the same asymptotic behavior for large values of the sto-
over, it does not allow us to control the scale factor y of chastic variable u. In Fig. 1, we compare P(u) obtained
the obtained stochastic process. In several simulations for a=1.5, o„=0. 696 575, cr =1 with L, »(v}; the two
concerning random processes, it is very important to con- curves, obtained by numerical integration of Eqs. (1) and
trol the exact nature of the investigated stochastic pro- (7), are different in the region close to the origin but coin-
cess and the exact value of the scale factor. Below we cide on the wings. The inset of the figure shows the two
present an algorithm that allows us to generate a stochas- curves in a semilogarithmic plot; from this inset, it is evi-
tic variable whose probability density is arbitrary close to dent that the two distributions almost coincide for
a Levy stable distribution characterized by arbitrary oui
& 10.
chosen control parameters (0.3 & a ~ 1.99, y & 0). By using Eq. (12) we obtain the asymptotic coincidence
To illustrate the algorithm, we divide it in three succes- of the two distributions for large values of the stochastic
sive steps. The first step is to calculate variable U; the second step is to ensure that the probabili-
ty density of the generated stochastic process [u j coin-
1/a (6) cides all over the range with the Levy stable distribution
/y /
j
P(v)= P'0 ~0y I y'
0
exp
2' y 2cT ~
dy . (7) l
0.3-I 4
-20 10 0
v
&G 20
P(u)=
a2 o'„I((a+1)/2)
(]+a)
C„(o„,
(
cry,
I+ )
a)' (8) -10 10 20
whereas its value at the origin is FIG. 1. Comparison of the Levy stable distribution of index
+=1.5 and scale factor y=1 615, (v) with the probability den-
2(1 —a)/2ao 1/al sity of Eq. (7) obtained by setting a = 1.5, o.~ = 1, and
((a+ 1 ) /2a )
„=0.
P(u =0)= o. 696575 [Eq. (12}I. The semilogarithmic inset shows that
the two functions are almost coincident for ! v! & 10.
49 FAST, ACCURATE ALGORITHM FOR NUMERICAL. .. 4679
of the same index a and scale factor y=1. In analogy the nonlinear transformation
with the normal case, one can think that it is sufhcient to
sum up a limited number n of independent variables each
w = [ [K(a) —1]exp( —v/C(a)]+1 ju (15)
of them distributed in accord with Eq. (7), i.e., it is
suScient to consider the stochastic variable
1l allows an almost immediate convergence towards the
zn ty~ X uk (13) Levy stable process of index a, if the two parameters
k=i K(a) and C(a) are properly determined. This statement
In Eq. (13) the scaling factor n '~ ensures that the vari- is fully supported from the numerical results reported in
Fig. 2. In this figure, in addition to the set of points al-
able [z„j
is characterized by the same scale factor y
ready illustrated, we report the e, (n) obtained by com-
characterizing the stochastic variable v [2].
The above argument is correct but the convergence of paring P(z, „)
figure), where
with L t(z} (lower set of points in the
the stochastic process [z„j
is quite slow. To quantify
how slow the convergence is, we simulate an entire family
of stochastic processes [z„j
characterized by the same
zen ]y
7l
g wk (16)
control parameters, but with n varying from 1 to 125. k=i
The calculations are done by using Eqs. (13) and (6). The
closeness between the generated stochastic process and
the Levy stable process of the same index is quantified by is a weighted average of n independent stochastic vari-
calculating the error sum of squares between the two dis- ables w generated by using Eq. (15). The points in the
tributions, figure
=
are obtained with a 1.5, 0. = „=0.
696 575,
+10 K(a) l. 599 22, and C(a) =2. 737. From the figure it is
e (n)=
z,
g
[P(z„)
z„=—10
L, (z)]— (14) evident that by performing the additional nonlinear
transformation of Eq. (15), the convergence to the Levy
stable stochastic process is very fast and a high accuracy
by using probability density with 100 points ranging be- is reached even when n =
l. In fact, the value of e, (1) is
tween —
10 and +10 usually. In Fig. 2, we show the re- well below the value of e (125) and the scattering ob-
sult of a numerical simulation performed by setting served in the curve of e, (n) is related to the finiteness of
a=1. 0„=1, o„=0.
5, and 696 575. As expected, the er- the number of realizations (2X104 realizations} used to
ror sum of squares e (n) (upper sets of points in the
figure} is a monotonically decreasing function of the num-
determine the P(z, „).
We determine the optimal value of K(a) by requiring
ber n of intermediate independent stochastic variables
[v j.
However, the convergence of [z„j
towards a Levy
P(w=0)=L &(0) . (17)
stable process of index a is very slow. Even using more
than 100 intermediate stochastic variables [u j, we are
still quite far from a complete matching between the two Close to the origin (w =0), Eq. (15) is well approximated
processes. To reach a faster convergence to the Levy by
stable process of index a, we propose to perform an ap-
propriate nonlinear transformation. We will show that w=K(a)u, (18)
C2(o. )
0. 1 9.922 44 0.000032
0.2 3. 138 2 0.021 243 We solve this integral equation numerically. We fj.nd two
0.3 2. 104 11 0. 124 698 different solutions C, (a) and C2(a) in the interval
0.4 1.70047 0.273 51 0. 75~a~1. 99. In Fig. 3, we plot the values of C, (a)
0.5 1.479 34 0.423 607 and Cz(a) together with the numerical estimation of the
0.6 1.333 91 0.560 589 interval of C(a), which speeds up the convergence to-
0.7 1.226 37 0.683 435
wards the Levy stable process of the selected index a.
0.8 1.139 99 0.795 112 2.483
This interval is determined by simulating for several
0.9 1.066 18 0.899 389 2.767 5
values of C(a) the stochastic process for a selected value
1 1 1
1.1 0.938 291 1.100 63 2.945 of a (in this analysis we use to obtain each e [C(a)]
1.2 0.878 829 1.205 19 2.941 2X10 realizations of the stochastic process}. For each
1.3 0.819 837 1.318 36 2.900 5 value of a, the best interval is determined by using the
1.4 0.759 679 1.446 47 2.831 5 measure defined in Eq. (14). In the figure, for several
1.5 0.696 575 1.599 22 2.737 values of a, we show e;„as
a small box and a bar which
1.6 0.628 231 1.793 61 2.612 5 indicates the interval of the C(a) values providing e
1.7 0.551 126 2.064 48 2.446 5 values, which differs by less than 10% from the minimum
1.8 0.458 638
0.333 819
2.501 47
3.461 5
2.206
1.791 5
value e;„.
A direct analysis of Fig. 3 allows us to con-
clude that Cz(a) is the value that speeds up the conver-
1.9
1.95 0.241 176 4.806 63 1.392 5 gence of the generated stochastic process towards the
1.99 0. 110693 10.498 0.608 9 Levy stable stochastic process of index a and scale factor
y= 1. The values of C2(a) for several values of a are
summarized in Table I.
v =C(a), i e. , the point w(C)=[[K(a)
—I]/e+1]C(a) The e6'ectiveness of our algorithm is shown in Fig. 4
does not need correction if where we present the probability density of the stochastic
process obtained by using the algorithm of Eqs. (6), (15),
P[w=w(C)]=P(U =c)=L i[w(C)] . {21) and (16). The control parameters are a=1.5, n=1,
We can write this last equation as an integral equation by
cr, =0. 696575, K(a)=1.59922, and C(a)=2. 737. In
the figure, boxes are the result of the simulation (10 real-
using Eqs. (1) and (7):
03—
a=1.5
n=1
0.2—
t
C2 {a) Ci ti
1
t
)E
JL
0. 1 I
c) (a)
0 l 0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 -10 -8 -6 -4 -2 0 2 4 6 8 10
1. 80
I, 20
1.00
0 80 I I I I
reported in Tablee I.. To obtain each distri e middle of the picture, re-
dff 1 ions ofh t e stochastic process. spectively).
4682 ROSARIO NUNZIO MANTEGNA
6- a 0.012- a=
v= FIG. 8. Probability densities (black boxes)
5- n of Levy stable processes of index o, =1.5 and
0.009- scale factor y=0. 01 (a) and y=100 (b). The
stochastic processes are simulated by using
Eqs. (6), (15), and (23) and we use 10 realiza-
0.006- tions to obtain each distribution. The control
parameters are reported in Table I for o. = 1.5,
2- n = 1. The continuous lines are the Levy stable
0.003- distributions of index a and corresponding
scale factor y.
0 I I I I I I I
-0.5 -0.3 -0. 1 0. 1 0.3 0.5 -250 -150 -50 50 150 250
Z
Fig. 8, we show two probability distributions obtained for value of C(a) in this case must be determined by using a
a=1.5 and n =1, the usual control parameters (Table I, heuristic approach. The effectiveness of our algorithm
but for the following values of y: y =0.01 [Fig. (8a)] and outside the interval 0. 75 ~ u ~ 1.95 is illustrated in Figs. 9
y=100 [Fig. (8b}]. Both simulations (black boxes in the and 10. In Fig. 9, we show the probability distribution of
figure} are in full agreement with the Levy stable distribu- the stochastic process generated by setting a=0. 3 and
tions obtained by numerical integration of Eq. (1} for n =100, whereas in Fig. 10, we show the probability dis-
=
a 1.5 and y =0.01, 100 (continuous lines in the figure). tribution obtained by setting a =1.99 and n = 10; the oth-
The algorithm of Eqs. (6} and (16} is fast and efficient er control parameters are reported in Table I. The agree-
within the interval 0. 75~a~1. 95. The upper limit is ment between the probability distributions of the simulat-
determined by the fact that for 1.95 the function of a) ed processes and the calculated Levy stable distributions
Eq. (15} is not invertible, and due to this, the probability is excellent over the entire range. We calculate the Levy
density has local minima. On the other hand, the integral stable distributions either by numerical integration of Eq.
equation [Eq. (22)] has no real solutions for a &0.75 so (1) (a=1.99) or by using the polynomial expansion pro-
that this value fixes the lower limit of maximal efficiency vided in [12] (a=0. 3).
of our algorithm. It is worthwhile to point out that the
algorithm of Eqs. (6) and (16) is efFective even outside this
limit. The only problem outside the maximal efficiency IV. CONCLUSIONS
interval is that to reach a given degree of accuracy, it
could be necessary to use a relatively high number n of In this paper we present an algorithm generating Levy
intermediate independent stochastic variables. The best stable stochastic processes of arbitrary choosen index o;
0.3
a=0.3 a=1.99
n =100 n=10
C(o) = c(a) =0.86
0 I
0-
-0.5 -0.3 -0. 1 0.3 0.5 -10 -8 -6 -4 -2 0 2 4 6 8 10
FIG. 9. Probability density (Q) of the stochastic process ob- FIG. 10. Probability density {Cl) of the stochastic process ob-
tained with the algorithm of Eqs. (6), (15), and (16) with a=0. 3 tained with the algorithm of Eqs. (6), (15), and (16) with a= 1.99
and n =100 together with the related Levy stable distribution and n=10 together with the related Levy stable distribution
L o 3 1 ( z ) (continuous line) The other parameters are as report-
~ LI 1 99 1 ( z ) (continuous line) . The other parameters are as report-
ed in Table I. The heuristic choice of the parameter C{0.3) =20 ed in Table I. The heuristic choice of the parameter
is not critical. C(1.99) =0.86 is critical.
49 FAST, ACCURATE ALGORITHM FOR NUMERICAL. .. 4683
[1] P. Levy, Theoric de !'Addition des Variables Aleatoires Stanley, and A. L. Goldberger, Phys. Rev. Lett. 70, 1343
(Gauthier-Villars, Paris, 1937). (1993).
[2] B. V. Gnedenko and A. Kolmogorov, Limit Distributions [8] S. V. Buldyrev, A. L. Goldberger, S. Havlin, C. K. Peng,
for Sums of Independent Random Variables (Addison- M. Simons, and H. E. Stanley, Phys. Rev. E 47, 4514
Wesley, Cambridge, MA, 1954). (1993).
[3] B. B. Mandelbrot, The Fractal Geometry of Nature (Free- [9] J. Moon and H. Nakanishi, Phys. Rev. A 42, 3221 (1990).
man, San Francisco, 1982). [10] R. N. Mantegna, Physica A 179, 232 (1991).
[4] H. Takayasu, Prog. Theor. Phys. 72, 471 (1984). [11]H. Bergstrom, Ark. Mat. Astron. Fys. 2, 375 (1952).
[5] M. F. Shlesinger, B. J. West, and J. Klafter, Phys. Rev. [12] E. W. Montroll and J. T. Bendler, J. Stat. Phys. 34, 129
Lett. 58, 1100 (1987). (1984).
[6] A. Ott, J. P. Bouchaud, D. Langevin, and W. Urbach, [13]J. P. Bouchaud and A. Georges, Phys. Rep. 195, 128
Phys. Rev. Lett. 65, 2201 (1990). (1990).
[7] C. K. Peng, J. Mietus, J. M. Hausdorff, S. Havlin, H. E. [14] S. Havlin and D. Ben-Avraham, Adv. Phys. 36, 695 (1987).