root/trunk/random/landau.lisp

Revision 26, 1.7 kB (checked in by lhealy, 9 months ago)

Subversion version stamp.

  • Property svn:keywords set to Id
Line 
1;; Landau distribution
2;; Liam Healy, Sat Sep 30 2006
3;; Time-stamp: <2008-02-17 13:01:50EST landau.lisp>
4;; $Id$
5
6(in-package :gsl)
7
8(defmfun landau (generator)
9  "gsl_ran_landau"
10  (((generator generator) :pointer))
11  :c-return :double
12  :documentation                        ; FDL
13  "A random variate from the Landau distribution.  The
14   probability distribution for Landau random variates is defined
15   analytically by the complex integral,
16   {1 \over {2 \pi i}} \int_{c-i\infty}^{c+i\infty} ds\, \exp(s \log(s) + x s)
17   For numerical purposes it is more convenient to use the following
18   equivalent form of the integral,
19   p(x) = (1/\pi) \int_0^\infty dt \exp(-t \log(t) - x t) \sin(\pi t).")
20
21(defmfun landau-pdf (x)
22  "gsl_ran_landau_pdf" ((x :double))
23  :c-return :double
24  :documentation                        ; FDL
25  "The probability density p(x) at x
26   for the Landau distribution using an approximation to the formula given
27   in #'landau.")
28
29;;; Examples and unit test
30#|
31(make-tests landau
32  (letm ((rng (random-number-generator *mt19937* 0)))
33      (loop for i from 0 to 10
34            collect (landau rng)))
35  (landau-pdf 0.25d0))
36|#
37
38(LISP-UNIT:DEFINE-TEST LANDAU
39  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
40   (LIST
41    (LIST 3880.037426254597d0 -0.6953200314545297d0
42          -0.02354364646600932d0 21.329209630030316d0
43          -0.3062224704714883d0 1.2424186669362394d0
44          26.146168479649152d0 4.337217640968217d0
45          1.6799546281085946d0 4.2475719218268395d0
46          4.681506208977819d0))
47   (MULTIPLE-VALUE-LIST
48    (LETM ((RNG (RANDOM-NUMBER-GENERATOR *MT19937* 0)))
49      (LOOP FOR I FROM 0 TO 10 COLLECT
50            (LANDAU RNG)))))
51  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
52   (LIST 0.17331968995860203d0)
53   (MULTIPLE-VALUE-LIST (LANDAU-PDF 0.25d0))))
54
Note: See TracBrowser for help on using the browser.