Random generator

Bernd Beuster <[email protected]> Fri, 31 Aug 2007 20:51:24 +0200
Newsgroups gmane.lisp.openmcl.bugs
Message-ID <[email protected]>
--Apple-Mail-1--174312439
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	delsp=yes;
	format=flowed

I  a small program what simulates the match differences of Snooker.  
There are differences
between  "OpenMCL Version 1.1-pre-070722 (DarwinX8664)" and "OpenMCL  
Version 1.0 (DarwinPPC32)".

It seems that in the X8664 implementation the function RANDOM is buggy.

The PPC32 implementation shows a almost monotonic decrease of  
probabilities but the X8664 implementation is more irregular.

Maybe a better regression test suite for random numbers is more  
helpful in order to detect the differences between the two  
implementations.

--Apple-Mail-1--174312439
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream; x-unix-mode=0644;
	x-mac-creator=454D4178; name=snooker.lisp
Content-Disposition: attachment;
	filename=snooker.lisp

;;; Snooker simulation
;;;
;;;
;;; OpenMCL Version 1.1-pre-070722 (DarwinX8664)
;;; MAX.ROUNDS  SCORE DIFFERENCES
;;; 9           #(27976 27237 24287 14220 6280)
;;; 11          #(23619 25877 20674 16270 9493 4067)
;;; 13          #(21997 22267 20915 16873 11203 5530 1215)
;;; 17          #(19388 22084 18855 13469 10949 7715 6104 1436 0)
;;; 19          #(18241 19838 16030 14827 10824 10417 4210 4010 1203 400)
;;; 25          #(16666 17477 15859 12366 12367 8061 8068 3761 2420 1881 1074 0 0)
;;; 27          #(19408 14117 18822 15887 8235 6765 6472 2647 3823 2058 1472 294 0 0)
;;; 33          #(13571 10355 16072 13216 10359 9286 9283 7140 5001 2144 1430 715 1428 0 0 0 0)
;;; 35          #(15268 10690 11832 11448 17178 10687 8014 4197 3816 1525 1908 1146 1146 763 382 0 0 0)
;;;
;;; 
;;; OpenMCL Version 1.0 (DarwinPPC32)
;;; MAX.ROUNDS  SCORE DIFFERENCES
;;; 9           #(27394 27299 23341 15718 6248)
;;; 11          #(24661 24627 21911 16309 9342 3150)
;;; 13          #(22652 22701 20546 16356 10893 5377 1475)
;;; 17          #(19706 19880 18173 15722 12091 8128 4222 1712 366)
;;; 19          #(18612 18550 17519 15171 12173 8676 5375 2743 985 196)
;;; 25          #(16164 16080 15494 14151 12057 9532 7024 4599 2794 1398 533 161 13)
;;; 27          #(15315 15482 15001 13626 11707 9814 7388 5269 3306 1782 861 358 83 8)
;;; 33          #(13872 14087 13458 12629 11290 9706 8036 6130 4425 2926 1807 931 427 197 62 16 1)
;;; 35          #(13613 13700 13040 12494 11026 9615 8034 6238 4636 3238 2115 1194 620 292 109 32 3 1)

(defun play-match (rounds)
  "Play a match with maximal ROUNDS frames per match. Return the score
difference of both players."
  (let ((end (ceiling rounds 2))
	(a 0)
	(b 0))
    (loop repeat rounds
	  while (and (< a end) (< b end))
	  do (if (zerop (random 2))
		 (incf a)
		 (incf b)))
    (abs (- a b))))

(defun play-matches (rounds &optional (n 100000))
  "Play N matches with maximal ROUNDS frames per match. Return an
array of size ROUNDS where the number of the differences is stored."
  (let ((differences (make-array (ceiling rounds 2) :initial-element 0)))
	(loop repeat n do (incf (aref differences (1- (play-match rounds)))))
	differences))


(defun test-case (&optional (n 100000))
  (format t "~&~A ~A~%" (lisp-implementation-type) (lisp-implementation-version))
  (format t "MAX.ROUNDS  SCORE DIFFERENCES~%")
  (loop for rounds in '(9 11 13 17 19 25 27 33 35) do (format t "~D~12T~A~%" rounds (play-matches rounds n))))




--Apple-Mail-1--174312439
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed


-- 
Bernd




--Apple-Mail-1--174312439
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Bug-openmcl mailing list
[email protected]
http://clozure.com/mailman/listinfo/bug-openmcl

--Apple-Mail-1--174312439--