I have some more observations on this poisson distribution
threshold function:
   prthre=: [:~.!.0 [EMAIL PROTECTED]@[ +/\@:* 1 */\@, %&(1+i.1000)

First off, the plots
   plot [EMAIL PROTECTED]"0 i. 713
   plot [EMAIL PROTECTED]"0 i. 800
are interesting.  The first shows a nearly linear trend and the second
shows a catastrophic
decay when we hit this limits of our numeric representation.

Anyways, if we are concerned about efficiency, maybe we should not
be generating a full 1000 terms when they are not needed.  In other words,
since the curve is nearly linear, maybe we should use a first degree
polynomial to estimate the number of terms we need.

   ([EMAIL PROTECTED]"0 i.713) %. (i.713)^/0 1
69.4126 1.24226
   >./ ([EMAIL PROTECTED]"0 i.713) - 69.4126 1.24226 p. i. 713
11.388
   11.388 + 69.4126
80.8006

In other words, the polynomial 81 1.25&p. should be more
than generous.  In fact
   >./ ([EMAIL PROTECTED]"0 i.713) - 81 1.25 p. i. 713
_2.25

we can use 79 1.25&p. and still have some room to spare.
However, I am going to use 80, because all I am really going
for here is a safe estimate:

pth=: [: ~.!.0 [EMAIL PROTECTED]@[ +/\@:* 1 */\@, ]% 1 + 80 1.25 i.@>[EMAIL 
PROTECTED] ]

   *./ (pth -: prthre)"0 i. 713
1

This variation produces the same results as before, for integers in
the domain of interest.

And in some cases the speedup is noticable:

   ts=: 6!:2,7!:[EMAIL PROTECTED]
   10000 ts 'pth 2'
2.67473e_5 4032
   10000 ts 'prthre 2'
0.000248684 25600

I could tune this further, using a slightly different polynomial,
for example, but I would expect to get into diminishing returns
rather quickly.

However, I should get around to looking at normal distributions,
for cases where the floating point exponent of ieee 64 bit floating
point numbers will not go low enough to properly represent the
necessary terms.  For example:

   pth 1000
0

FYI,

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

Reply via email to