root/trunk/random/gumbel1.lisp

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

Subversion version stamp.

  • Property svn:keywords set to Id
Line 
1;; The Gumbel type 1 random number distribution
2;; Liam Healy, Sun Oct 29 2006
3;; Time-stamp: <2008-02-17 13:30:24EST gumbel1.lisp>
4;; $Id$
5
6(in-package :gsl)
7
8(defmfun gumbel1 (generator a b)
9  "gsl_ran_gumbel1"
10  (((generator generator) :pointer) (a :double) (b :double))
11  :c-return :double
12  :documentation                        ; FDL
13  "A random variate from the Type-1 Gumbel
14   distribution,
15   p(x) dx = a b \exp(-(b \exp(-ax) + ax)) dx
16   for -\infty < x < \infty.")
17
18(defmfun gumbel1-pdf (x a b)
19  "gsl_ran_gumbel1_pdf" ((x :double) (a :double) (b :double))
20  :c-return :double
21  :documentation                        ; FDL
22  "The probability density p(x) at x
23  for a Type-1 Gumbel distribution with parameters a and b,
24  using the formula given for #'gumbel1.")
25
26(defmfun gumbel1-P (x a b)
27  "gsl_cdf_gumbel1_P" ((x :double) (a :double) (b :double))
28  :c-return :double
29  :documentation                        ; FDL
30  "The cumulative distribution functions
31  P(x) for the Type-1 Gumbel distribution with
32  parameters a and b.")
33
34(defmfun gumbel1-Q (x a b)
35  "gsl_cdf_gumbel1_Q" ((x :double) (a :double) (b :double))
36  :c-return :double
37  :documentation                        ; FDL
38  "The cumulative distribution functions
39  Q(x) for the Type-1 Gumbel distribution with
40  parameters a and b.")
41
42(defmfun gumbel1-Pinv (P a b)
43  "gsl_cdf_gumbel1_Pinv" ((P :double) (a :double) (b :double))
44  :c-return :double
45  :documentation                        ; FDL
46  "The inverse cumulative distribution functions
47  P(x) for the Type-1 Gumbel distribution with
48  parameters a and b.")
49
50(defmfun gumbel1-Qinv (Q a b)
51  "gsl_cdf_gumbel1_Qinv" ((Q :double) (a :double) (b :double))
52  :c-return :double
53  :documentation                        ; FDL
54  "The inverse cumulative distribution functions
55  Q(x) for the Type-1 Gumbel distribution with
56  parameters a and b.")
57
58;;; Examples and unit test
59#|
60(make-tests gumbel1
61  (letm ((rng (random-number-generator *mt19937* 0)))
62      (loop for i from 0 to 10
63            collect (gumbel1 rng 1.0d0 2.0d0)))
64  (gumbel1-pdf 0.1d0 1.0d0 2.0d0)
65  (gumbel1-P 0.1d0 1.0d0 2.0d0)
66  (gumbel1-Q 0.1d0 1.0d0 2.0d0)
67  (gumbel1-Pinv 0.1637073598773166d0 1.0d0 2.0d0)
68  (gumbel1-Qinv 0.8362926401226833d0 1.0d0 2.0d0))
69|#
70
71(LISP-UNIT:DEFINE-TEST GUMBEL1
72  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
73   (LIST
74    (LIST 8.954596257487015d0 0.0973051899750762d0
75          0.45913506233088003d0 3.6074124224293223d0
76          0.31300027468174807d0 1.0165796949651174d0
77          3.8292081936610396d0 1.912897393181305d0
78          1.17748457894919d0 1.893232107970416d0
79          1.9859118616847695d0))
80   (MULTIPLE-VALUE-LIST
81    (LETM ((RNG (RANDOM-NUMBER-GENERATOR *MT19937* 0)))
82      (LOOP FOR I FROM 0 TO 10 COLLECT
83            (GUMBEL1 RNG 1.0d0 2.0d0)))))
84  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
85   (LIST 0.29625708964974956d0)
86   (MULTIPLE-VALUE-LIST (GUMBEL1-PDF 0.1d0 1.0d0 2.0d0)))
87  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
88   (LIST 0.1637073598773166d0)
89   (MULTIPLE-VALUE-LIST (GUMBEL1-P 0.1d0 1.0d0 2.0d0)))
90  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
91   (LIST 0.8362926401226833d0)
92   (MULTIPLE-VALUE-LIST (GUMBEL1-Q 0.1d0 1.0d0 2.0d0)))
93  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
94   (LIST 0.10000000000000007d0)
95   (MULTIPLE-VALUE-LIST
96    (GUMBEL1-PINV 0.1637073598773166d0 1.0d0 2.0d0)))
97  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
98   (LIST 0.10000000000000028d0)
99   (MULTIPLE-VALUE-LIST
100    (GUMBEL1-QINV 0.8362926401226833d0 1.0d0 2.0d0))))
101
Note: See TracBrowser for help on using the browser.