/[cl-gsl]/cl-gsl/test/test-random-number-generator.lisp
ViewVC logotype

Contents of /cl-gsl/test/test-random-number-generator.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Tue May 17 00:53:35 2005 UTC (8 years, 11 months ago) by edenny
Branch: MAIN
CVS Tags: HEAD
Initial check in.
1 ;;;; -*- Mode: Lisp; Synatx: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;;
3 ;;;; Copyright (C) 2005 Edgar Denny <edgardenny@comcast.net>
4 ;;;; This file is part of CL-GSL.
5 ;;;;
6 ;;;; This program is free software; you can redistribute it and/or modify
7 ;;;; it under the terms of the GNU General Public License as published by
8 ;;;; the Free Software Foundation; either version 2 of the License, or
9 ;;;; (at your option) any later version.
10 ;;;;
11 ;;;; This program is distributed in the hope that it will be useful,
12 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;;; GNU General Public License for more details.
15 ;;;;
16 ;;;; You should have received a copy of the GNU General Public License
17 ;;;; along with this program; if not, write to the Free Software
18 ;;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 (in-package #:cl-gsl-test)
21
22 (defconstant +rng+ "rng")
23
24 (defconstant +generator-list+
25 (list "borosh13" "coveyou" "cmrg" "fishman18" "fishman20" "fishman2x" "gfsr4" "knuthran" "knuthran2" "lecuyer21" "minstd" "mrg" "mt19937" "mt19937-1999" "mt19937-1998" "r250" "ran0" "ran1" "ran2" "ran3" "rand" "rand48" "random128-bsd" "random128-glibc2" "random128-libc5" "random256-bsd" "random256-glibc2" "random256-libc5" "random32-bsd" "random32-glibc2" "random32-libc5" "random64-bsd" "random64-glibc2" "random64-libc5" "random8-bsd" "random8-glibc2" "random8-libc5" "random-bsd" "random-glibc2" "random-libc5" "randu" "ranf" "ranlux" "ranlux389" "ranlxd1" "ranlxd2" "ranlxs0" "ranlxs1" "ranlxs2" "ranmar" "slatec" "taus" "taus2" "taus113" "transputer" "tt800" "uni" "uni32" "vax" "waterman14" "zuf"))
26
27 (defun iterate (name seed num)
28 (gsl-rng:with-generator (g name)
29 (gsl-rng:seed g seed)
30 (dotimes (i (1- num))
31 (gsl-rng:get-integer g))
32 (gsl-rng:get-integer g)))
33
34 (deftest "rand" :category +rng+
35 :test-fn
36 #'(lambda ()
37 (= (iterate "rand" 1 10000) 1910041713)))
38
39 (deftest "randu" :category +rng+
40 :test-fn
41 #'(lambda ()
42 (= (iterate "randu" 1 10000) 1623524161)))
43
44 (deftest "cmrg" :category +rng+
45 :test-fn
46 #'(lambda ()
47 (= (iterate "cmrg" 1 10000) 719452880)))
48
49 (deftest "minstd" :category +rng+
50 :test-fn
51 #'(lambda ()
52 (= (iterate "minstd" 1 10000) 1043618065)))
53
54 (deftest "mrg" :category +rng+
55 :test-fn
56 #'(lambda ()
57 (= (iterate "mrg" 1 10000) 2064828650)))
58
59 (deftest "taus" :category +rng+
60 :test-fn
61 #'(lambda ()
62 (= (iterate "taus" 1 10000) 2733957125)))
63
64 (deftest "taus113" :category +rng+
65 :test-fn
66 #'(lambda ()
67 (= (iterate "taus113" 1 1000) 1925420673)))
68
69 (deftest "transputer" :category +rng+
70 :test-fn
71 #'(lambda ()
72 (= (iterate "transputer" 1 10000) 1244127297)))
73
74 (deftest "vax" :category +rng+
75 :test-fn
76 #'(lambda ()
77 (= (iterate "vax" 1 10000) 3051034865)))
78
79 (deftest "borosh13" :category +rng+
80 :test-fn
81 #'(lambda ()
82 (= (iterate "borosh13" 1 10000) 2513433025)))
83
84 (deftest "fishman18" :category +rng+
85 :test-fn
86 #'(lambda ()
87 (= (iterate "fishman18" 1 10000) 330402013)))
88
89 (deftest "fishman2x" :category +rng+
90 :test-fn
91 #'(lambda ()
92 (= (iterate "fishman2x" 1 10000) 540133597)))
93
94 (deftest "knuthran2" :category +rng+
95 :test-fn
96 #'(lambda ()
97 (= (iterate "knuthran2" 1 10000) 1084477620)))
98
99 (deftest "lecuyer21" :category +rng+
100 :test-fn
101 #'(lambda ()
102 (= (iterate "lecuyer21" 1 10000) 2006618587)))
103
104 (deftest "waterman14" :category +rng+
105 :test-fn
106 #'(lambda ()
107 (= (iterate "waterman14" 1 10000) 3776680385)))
108
109 (deftest "coveyou" :category +rng+
110 :test-fn
111 #'(lambda ()
112 (= (iterate "coveyou" 6 10000) 1416754246)))
113
114 (deftest "fishman20" :category +rng+
115 :test-fn
116 #'(lambda ()
117 (= (iterate "fishman20" 6 10000) 248127575)))
118
119 (deftest "ranlux" :category +rng+
120 :test-fn
121 #'(lambda ()
122 (= (iterate "ranlux" 314159265 10000) 12077992)))
123
124 (deftest "ranlux389" :category +rng+
125 :test-fn
126 #'(lambda ()
127 (= (iterate "ranlux389" 314159265 10000) 165942)))
128
129 (deftest "ranlxs0" :category +rng+
130 :test-fn
131 #'(lambda ()
132 (= (iterate "ranlxs0" 1 10000) 11904320)))
133
134 (deftest "ranlxs1" :category +rng+
135 :test-fn
136 #'(lambda ()
137 (= (iterate "ranlxs1" 1 10000) 8734328)))
138
139 (deftest "ranlxs2" :category +rng+
140 :test-fn
141 #'(lambda ()
142 (= (iterate "ranlxs2" 1 10000) 6843140) ))
143
144 (deftest "ranlxd1" :category +rng+
145 :test-fn
146 #'(lambda ()
147 (= (iterate "ranlxd1" 1 10000) 1998227290)))
148
149 (deftest "ranlxd2" :category +rng+
150 :test-fn
151 #'(lambda ()
152 (= (iterate "ranlxd2" 1 10000) 3949287736)))
153
154 (deftest "slatec" :category +rng+
155 :test-fn
156 #'(lambda ()
157 (= (iterate "slatec" 1 10000) 45776)))
158
159 (deftest "uni" :category +rng+
160 :test-fn
161 #'(lambda ()
162 (= (iterate "uni" 1 10000) 9214)))
163
164 (deftest "uni32" :category +rng+
165 :test-fn
166 #'(lambda ()
167 (= (iterate "uni32" 1 10000) 1155229825)))
168
169 (deftest "zuf" :category +rng+
170 :test-fn
171 #'(lambda ()
172 (= (iterate "zuf" 1 10000) 3970)))
173
174 (deftest "r250" :category +rng+
175 :test-fn
176 #'(lambda ()
177 (= (iterate "r250" 1 10000) 1100653588)))
178
179 (deftest "mt19937" :category +rng+
180 :test-fn
181 #'(lambda ()
182 (= (iterate "mt19937" 4357 1000) 1186927261)))
183
184 (deftest "mt19937-1999" :category +rng+
185 :test-fn
186 #'(lambda ()
187 (= (iterate "mt19937-1999" 4357 1000) 1030650439)))
188
189 (deftest "mt19937-1998" :category +rng+
190 :test-fn
191 #'(lambda ()
192 (= (iterate "mt19937-1998" 4357 1000) 1309179303)))
193
194 (deftest "tt800" :category +rng+
195 :test-fn
196 #'(lambda ()
197 (= (iterate "tt800" 0 10000) 2856609219)))
198
199 (deftest "ran0" :category +rng+
200 :test-fn
201 #'(lambda ()
202 (= (iterate "ran0" 0 10000) 1115320064)))
203
204 (deftest "ran1" :category +rng+
205 :test-fn
206 #'(lambda ()
207 (= (iterate "ran1" 0 10000) 1491066076)))
208
209 (deftest "ran2" :category +rng+
210 :test-fn
211 #'(lambda ()
212 (= (iterate "ran2" 0 10000) 1701364455)))
213
214 (deftest "ran3" :category +rng+
215 :test-fn
216 #'(lambda ()
217 (= (iterate "ran3" 0 10000) 186340785)))
218
219 (deftest "ranmar" :category +rng+
220 :test-fn
221 #'(lambda ()
222 (= (iterate "ranmar" 1 10000) 14428370)))
223
224 (deftest "random-glibc2" :category +rng+
225 :test-fn
226 #'(lambda ()
227 (= (iterate "random-glibc2" 0 10000) 1908609430)))
228
229 (deftest "random8-glibc2" :category +rng+
230 :test-fn
231 #'(lambda ()
232 (= (iterate "random8-glibc2" 0 10000) 1910041713)))
233
234 (deftest "random32-glibc2" :category +rng+
235 :test-fn
236 #'(lambda ()
237 (= (iterate "random32-glibc2" 0 10000) 1587395585)))
238
239 (deftest "random64-glibc2" :category +rng+
240 :test-fn
241 #'(lambda ()
242 (= (iterate "random64-glibc2" 0 10000) 52848624)))
243
244 (deftest "random128-glibc2" :category +rng+
245 :test-fn
246 #'(lambda ()
247 (= (iterate "random128-glibc2" 0 10000) 1908609430)))
248
249 (deftest "random256-glibc2" :category +rng+
250 :test-fn
251 #'(lambda ()
252 (= (iterate "random256-glibc2" 0 10000) 179943260)))
253
254 (deftest "random-bsd" :category +rng+
255 :test-fn
256 #'(lambda ()
257 (= (iterate "random-bsd" 0 10000) 1457025928)))
258
259 (deftest "random8-bsd" :category +rng+
260 :test-fn
261 #'(lambda ()
262 (= (iterate "random8-bsd" 0 10000) 1910041713)))
263
264 (deftest "random32-bsd" :category +rng+
265 :test-fn
266 #'(lambda ()
267 (= (iterate "random32-bsd" 0 10000) 1663114331)))
268
269 (deftest "random64-bsd" :category +rng+
270 :test-fn
271 #'(lambda ()
272 (= (iterate "random64-bsd" 0 10000) 864469165)))
273
274 (deftest "random128-bsd" :category +rng+
275 :test-fn
276 #'(lambda ()
277 (= (iterate "random128-bsd" 0 10000) 1457025928)))
278
279 (deftest "random256-bsd" :category +rng+
280 :test-fn
281 #'(lambda ()
282 (= (iterate "random256-bsd" 0 10000) 1216357476)))
283
284 (deftest "random-libc5" :category +rng+
285 :test-fn
286 #'(lambda ()
287 (= (iterate "random-libc5" 0 10000) 428084942)))
288
289 (deftest "random8-libc5" :category +rng+
290 :test-fn
291 #'(lambda ()
292 (= (iterate "random8-libc5" 0 10000) 1910041713)))
293
294 (deftest "random32-libc5" :category +rng+
295 :test-fn
296 #'(lambda ()
297 (= (iterate "random32-libc5" 0 10000) 1967452027)))
298
299 (deftest "random64-libc5" :category +rng+
300 :test-fn
301 #'(lambda ()
302 (= (iterate "random64-libc5" 0 10000) 2106639801)))
303
304 (deftest "random128-libc5" :category +rng+
305 :test-fn
306 #'(lambda ()
307 (= (iterate "random128-libc5" 0 10000) 428084942)))
308
309 (deftest "random256-libc5" :category +rng+
310 :test-fn
311 #'(lambda ()
312 (= (iterate "random256-libc5" 0 10000) 116367984)))
313
314 (deftest "ranf" :category +rng+
315 :test-fn
316 #'(lambda ()
317 (= (iterate "ranf" 2 10000) 339327233)))

  ViewVC Help
Powered by ViewVC 1.1.5