On Sat, Aug 9, 2008 at 1:58 AM, Roger Hui <[EMAIL PROTECTED]> wrote:
>> 5*y should be statistically valid
>> for far larger samples than our psuedo-random number
>> generator would be good for.
>
> Can you please explain that?  The default RNG used
> in ?y has a period of _1+2^19937 (4.32e6001).
> http://www.jsoftware.com/help/dictionary/d640.htm

Ok, it turns out I was woefully wrong here.  The problem
is not very obvious for the case I was experimenting
with, but for smaller cases this become ridiculous.

coclass 'poissondistr'

create=: 3 :0
  n=: y
  possible=: (^-y) +/\@:* 1 */\@, y&%
  thresh=: possible 1+i.y
)

rand=: 3 :0
  r=. thresh I. t=. y [EMAIL PROTECTED] 0
  while. #i=. I. r=#thresh do.
    thresh=: possible 1+i.n=: n+1
    r=. (thresh I. i{t) i} r
  end.
)

cocurrent 'base'

d2=: 2 conew 'poisondistr'

   ($thresh__d2); 'rand__d2 2^10' ts~ 2^6
+--+----------------+
|13|6.36691e_5 40320|
+--+----------------+

(compare that 13 with 5*2)

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to