root/trunk/random/rayleigh-tail.lisp

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

Subversion version stamp.

  • Property svn:keywords set to Id
Line 
1;; Rayleigh tail distribution
2;; Liam Healy, Sat Sep 30 2006
3;; Time-stamp: <2008-02-17 13:00:06EST rayleigh-tail.lisp>
4;; $Id$
5
6(in-package :gsl)
7
8(defmfun rayleigh-tail (generator a sigma)
9  "gsl_ran_rayleigh_tail"
10  (((generator generator) :pointer) (a :double) (sigma :double))
11  :c-return :double
12  :documentation                        ; FDL
13  "A random variate from the tail of the Rayleigh
14  distribution with scale parameter sigma and a lower limit of
15  a.  The distribution is
16  p(x) dx = {x \over \sigma^2} \exp ((a^2 - x^2) /(2 \sigma^2)) dx
17  for x > a.")
18
19(defmfun rayleigh-tail-pdf (x a sigma)
20  "gsl_ran_rayleigh_tail_pdf" ((x :double) (a :double) (sigma :double))
21  :c-return :double
22  :documentation                        ; FDL
23  "The probability density p(x) at x
24   for a Rayleigh tail distribution with scale parameter sigma and
25   lower limit a, using the formula given in #'rayleigh-tail.")
26
27;;; Examples and unit test
28#|
29(make-tests rayleigh-tail
30  (letm ((rng (random-number-generator *mt19937* 0)))
31      (loop for i from 0 to 10
32            collect (rayleigh-tail rng 1.0d0 10.0d0)))
33  (rayleigh-tail-pdf 0.25d0 -2.0d0 2.0d0))
34|#
35
36(LISP-UNIT:DEFINE-TEST RAYLEIGH-TAIL
37  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
38   (LIST
39    (LIST 1.0255032370386696d0 19.0764679267351d0
40          15.928966102255199d0 3.4422048899106383d0
41          17.131838333441106d0 12.071957529361999d0
42          3.112992916690818d0 7.749889301203328d0
43          11.145450138119857d0 7.825198187316554d0
44          7.476774681552917d0))
45   (MULTIPLE-VALUE-LIST
46    (LETM ((RNG (RANDOM-NUMBER-GENERATOR *MT19937* 0)))
47      (LOOP FOR I FROM 0 TO 10 COLLECT
48            (RAYLEIGH-TAIL RNG 1.0d0 10.0d0)))))
49  (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
50   (LIST 0.10224317624874313d0)
51   (MULTIPLE-VALUE-LIST
52    (RAYLEIGH-TAIL-PDF 0.25d0 -2.0d0 2.0d0))))
Note: See TracBrowser for help on using the browser.