[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: numerical analysis
From: |
Edward Casey |
Subject: |
Re: numerical analysis |
Date: |
Fri, 30 Jul 2004 23:31:05 -0500 |
"Kevin Rodgers" <ihs_4664@yahoo.com> wrote in message
410A7FC6.9000808@yahoo.com">news:410A7FC6.9000808@yahoo.com...
> Edward Casey wrote:
> > This code fragment produces somewhat pseudo-random powerball numbers:
> >
> > (progn
> > (random t)
> > (setq lis6 nil)
> > (while (< (length lis6) 5)
> > ;; (setq cm (+ (mod (* (nth 1 (current-time))(/ (nth 2
> > (current-time)) 10000)(random)) 52) 1))
> > ;; (random t)
> > (setq cm (+ (random 52) 1))
> > (if (not (member cm lis6)) (setq lis6 (cons cm lis6)))
> > )
> > (setq lis6 (sort lis6 '>))
> > (random t)
> > (setq cm (+ (random 41) 1))
> > (setq lis6 (cons cm lis6))
> > (reverse lis6)
> > )
> >
> > The commented-out lines don't seem to work in a loop. Is there some
> > way I could mix this up some more to get closer to true randomness?
>
> Why do you (re)set the random number seed more than once?
I just wanted to scramble things up a little more. The interpreter
wouldn't allow it within the loop so I called it afterwards. Apparently it
seeds random with a value determined by a combination of transient
hardware states.
>
> In what way does the (setq cm ...) form not work?
The (progn form does return a list of 6 pseudo-random numbers but the
commented ;; (setq cm (+ (mod.... [goes with following line that
wordwrapped] apparently didn't work for the same reason that (random t)
didn't, viz. it interrogated the hardware within a loop.
>
> > In emacs lisp is it possible to open an arbitrary file (say a
> > compressed graphic file of white noise) and to advance the file
> > pointer by 8-bit increments?
>
> Use find-file-literally or insert-file-contents-literally, then
forward-char.
Thanks for that. I am still buried under the avalanche of all this new
stuff to learn.
>
> --
> Kevin Rodgers
>