File: rans.lsp

package info (click to toggle)
xlispstat 3.52.14-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 7,560 kB
  • ctags: 12,676
  • sloc: ansic: 91,357; lisp: 21,759; sh: 1,525; makefile: 521; csh: 1
file content (30 lines) | stat: -rw-r--r-- 983 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(defun get-random-state-values (s)
  (second (read-from-string (prin1-to-string s) t nil :start 2)))

(defun test-random-state (state values)
  (let ((*random-state* state)
	(state-max (aref (get-random-state-values *random-state*) 0)))
    (check #'=
	   0
	   (mapcar #'(lambda (v)
		       (random state-max)
		       (- v (aref (get-random-state-values *random-state*) 1)))
		   values))))

; combined congruential
(test-random-state '#$(1 #(2147483562 0 12345 67890))
		   '(2026359911 1950599823 315009702 1105313978 871469535
		     1575849876   94472070 728775444 2137747604 430227419))

; superduper
(test-random-state '#$(2 #(2147483647 0 0 12345 1 2354))
		   '(274318794 1445882217 174694986 21258797 860839904
		     1611788216 2056178182 1140888495 12651638 485726963))

; combined tausworth
(test-random-state '#$(3 #(2147483647 0 12345 67890))
		   '(702677384 51837197 1914342640 434186539 1381102196
		     1693194944 898066022 1288590140 645917234 1416028832))