[CM] 'drunk' behavior

Rick Taube taube at uiuc.edu
Sun Sep 3 17:58:32 PDT 2006


indeed. the bug is that the value is bounded (between (- width)  
width) which means that there is 1 more neg. number than positive :/
if you change that to (between (- width) (+ width 1) ) then it  
behaves correctly ie drunkvec averages to the initial value:

(defun drunkvec (startpit len &optional (stepsize 1))
    (loop repeat len
      for r = startpit then (drunk r stepsize)
      collect r))

(defun avr (l) (floor (apply #'+ l) (length l)))


? (avr (loop repeat 30 append (last (drunkvec 50 20))))
=> 49
? (avr (loop repeat 30 append (last (drunkvec 50 20))))
=> 51
? (avr (loop repeat 30 append (last (drunkvec 50 20))))
=> 50

this is fixed in cvs (rev 1.14 of data.scm). thanks drew!





More information about the Cmdist mailing list