public
Description: Random number generation for common lisp
Homepage: http://code.google.com/p/cl-randist/
Clone URL: git://github.com/lvaruzza/cl-randist.git
Search Repo:
fix conflict
lvaruzza (author)
Sun Feb 24 06:47:33 -0800 2008
commit  74e1bdce6c7b740a09216387150fa9af2abce3a5
tree    a02b34e250a274f7ad4dc736e21c376c6ab227b4
parent  b95b0d278acb0dd7d0e979b674dc3e92e679c203
...
1
2
 
3
4
5
...
16
17
18
 
 
19
20
21
 
 
...
1
2
3
4
5
6
...
17
18
19
20
21
22
 
23
24
25
0
@@ -1,5 +1,6 @@
0
 (in-package :randist)
0
 
0
+(declaim (optimize (speed 3) (safety 1)))
0
 
0
 ;; The negative binomial distribution has the form,
0
 ;; prob(k) = Gamma(n + k)/(Gamma(n) Gamma(k + 1)) p^n (1-p)^k
0
@@ -16,5 +17,8 @@
0
 
0
 
0
 (defun random-negative-binomial (p n)
0
+ (declare (type double-float p)
0
+ (integer n))
0
   (let ((X (random-gamma (coerce n 'double-float) 1d0)))
0
- (random-poisson (* X (/ (- 1d0 p) p)))))
0
\ No newline at end of file
0
+ (random-poisson (* X (/ (- 1d0 p) p)))))
0
+
...
27
28
29
30
31
32
33
34
35
36
37
 
...
27
28
29
 
 
 
30
 
31
 
32
33
0
@@ -27,10 +27,6 @@
0
 p(x) dx = (a/b) / (x/b)^(a+1) dx for x >= b"
0
 
0
   (declare (type double-float a b))
0
-<<<<<<< HEAD:pareto.lisp
0
- (let* ((x (random-uniform))
0
-=======
0
   (let* ((x (random-pos))
0
->>>>>>> experimental:pareto.lisp
0
    (z (expt x (/ -1d0 a))))
0
- (* b z)))
0
\ No newline at end of file
0
+ (* b z)))

Comments

    No one has commented yet.