So, we keep the status quo, users can still be confused, and I still am uncomfortable with the interface. I can live with it, I would just prefer it weren't the case. <br><br><div class="gmail_quote">On Dec 30, 2007 3:04 PM, Chongkai Zhu <
<a href="mailto:czhu@cs.utah.edu">czhu@cs.utah.edu</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
<br>Doug Williams wrote:<br>><br>><br>> On Dec 30, 2007 12:40 PM, Chongkai Zhu <<a href="mailto:czhu@cs.utah.edu">czhu@cs.utah.edu</a><br></div><div class="Ih2E3d">> <mailto:<a href="mailto:czhu@cs.utah.edu">
czhu@cs.utah.edu</a>>> wrote:<br>><br>><br>><br>> >Doug Williams wrote:<br>> >> And while we're on the subject, there is another problem with<br>> the new<br>> >> SRFI 27 implementation I've noticed. The randomization of
<br>> >> (random-source-pseudo-randomize! s i j) and<br>> >> (random-source-pseudo-randomize! s j i) will always be the<br>> same. The<br>> >> code uses equal-hash-code of i and j to come up with a seed and
<br>> that<br>> >> function is symmetric wrt i and j.<br>> >><br>> ><br>> > DrScheme, version 372-svn12nov2007 [3m]<br>> ><br>> >(equal-hash-code (list 1 2))
<br>> >(equal-hash-code (list 2 1))<br>> ><br>> >(equal-hash-code (list 1 0))<br>> >(equal-hash-code (list 0 1))<br>> ><br>> >=><br>> ><br>> >94564159
<br>> >95385186<br>> >94562141<br>> >93284415<br>><br>><br>> My bad on that one. Sorry. But, I still don't like compressing the<br>> repeatable random space - there are collisions there.
<br><br></div>Yes, there are collisions. But the space is still big, so collisions<br>will be very rare.<br><div><div></div><div class="Wj3C7c"><br>><br>><br>><br>> >> I think we still need to do some thinking on the
<br>> implementation. I<br>> >> think we need to either expose the SRFI 27 interface from PLT<br>> Scheme<br>> >> (and implement the old interface on top of that) or separate them<br>
> >> completely and go back to the old SRFI 27 implementation. [There<br>> >> would also be some middle ground. But, I don't think there is<br>> >> currently enough of the internal implementation exposed to
<br>> adequately<br>> >> implement SRFI 27 - there are too many kludges in that code now.]<br>> >><br>> >The current SRFI 27 implement does the following:<br>> ><br>> >1. to meet SRFI 27;
<br>> >2. to be as efficient as possible (i.e., using PLT's random<br>> procedures<br>> >as much as possible).<br>><br>> >I did once tried to connect SRFI 27's default-random-source and PLT's
<br>> >current-pseudo-random-generator, but that doesn't goes very well,<br>> so it<br>> >comes the current implement: they are not connected at all. In that<br>> >sense, SRFI 27 and PLT's random procedures are completely
<br>> separated. I<br>> >can't see what you are suggestion here.<br>><br>><br>> I'm not sure what the 'right' answer is, I'm just trying to figure out<br>> the best way to keep users from being confused. [Noel is by no means
<br>> a novice user and he was confused.] The best options seem to be at<br>> opposite ends of the spectrum. Either make them the same (and<br>> therefore there is nothing to confuse) or make them so different that
<br>> you lessen the confusion.<br>><br>> I would rather lean toward making them the same:<br>><br>> 1) Make both random sources have the same 'type' - i.e.<br>> make-pseudo-random-generator from PLT Scheme and make-random-source
<br>> from SRFI 27 should return objects that can be used in either context<br>> because they are the same implementation.<br>> 2) Make PLT Scheme random routines (like random and random-seed) be<br>> able to accept a random-source as an argument. It seems wasteful to
<br>> continually parameterize current-pseudo-random-stream to fake passing<br>> random (or random-seed) an argument, which is one of the main kludges<br>> I was referring to.<br>> 3) Implement a SRFI 27 pseudo randomize in PLT Scheme (because it is
<br>> more robust than a single seed) and then implement random-seed in<br>> terms of it. For example, we might define (random-seed s k) as being<br>> equivalent to (random-source-pseudo-randomize! s k 0).<br>>
<br>> I think that would give us an interface in PLT Scheme that is<br>> compatible with (but an extension of) the current implementation and<br>> give what is needed to make the SRFI 27 implementation better.<br>
><br>> I don't think there is a good way top reconcile the differences<br>> between the default-random-source behavior of SRFI 27 and the<br>> current-pseudo-random-generator in PLT Scheme. SRFI 27 did not
<br>> anticipate as rich as environment - i.e., with parameters, threads,<br>> etc - as PLT Scheme. Leave them both in as they are - and avoid the<br>> temptation to make default-random-stream be a parameter, it's just a
<br>> global variable. In essence this is what I did in the science<br>> collection by adding a current-random-source parameter. [It is doing<br>> the same for SRFI 27 as current-pseudo-random-generator does for PLT
<br>> Scheme.]<br>><br>> The other extreme is to just put the old SRFI 27 implementation back<br>> and just say they're different.<br>><br>> My personal opinion is that the current PLT Scheme random source
<br>> interface (not the underlying implementation) is inadequate for the<br>> work I want to use it for - simulations, in my case. But, it is more<br>> efficient than the old SRFI 27 implementation. The SRFI 27 interface
<br>> is suitable for the work - in particular, I can easily specify<br>> repeatable, independent random variables. However, it's<br>> implementation was not as efficient as the PLT Scheme implementation.<br>
> And, because the PLT Scheme implementation doesn't expose enough of<br>> the underlying implementation to make a straightforward implementation<br>> of SRFI 27 on top of it, I don't have the same confidence in the
<br>> interface code as I do in either the underlying PLT implementation or<br>> the old SRFI implementation. [For example, the procedure returned by<br>> (random-source-make-integers n) may call the underlying PLT Scheme
<br>> random routine once or twice, depending on the value of n. Some of<br>> those manipulations seem innocuous, but can bias the macro-level<br>> behavior of the random sources.]<br>><br>> In the short term, the best thing for the users of the science
<br>> collection to remember is that there is no inherent connection between<br>> the SRFI 27 random routines (and the science collection distributions,<br>> etc) and the built in PLT scheme ones.<br>><br>>
<br><br></div></div>The current PLT's SRFI 27 implementation provides all features the<br>reference implementation (or, the old SRFI implementation as Doug calls<br>it) provides, while being more efficient. Here's the reasons:
<br><br>1. They both meet the SRFI 27 interface;<br>2. "default-random-source" in both have nothing to do with PLT's<br>current-pseudo-random-generator (or any parameter in PLT).<br><br>So there is no reason to bring the old SRFI 27 implementation back.
<br><br>You SHOULD have the same confidence in the interface code as you do in<br><div class="Ih2E3d">either the underlying PLT implementation or the old SRFI implementation.<br></div>You are right that the procedure returned by
<br><div class="Ih2E3d">(random-source-make-integers s) may call the underlying PLT Scheme<br></div>random routine more than once, depending on the value of its input. But<br>that's fine (and necessary). I don't think it will bias the macro-level
<br><div><div></div><div class="Wj3C7c">behavior of the random sources.<br><br><br></div></div><font color="#888888">Chongkai<br><br></font></blockquote></div><br>