What's wrong with using 0.5 1 I. y or even 0.5 I. y instead of 0 0.5 1 I. y ?
----- Original Message ----- From: Brian Schott <[EMAIL PROTECTED]> Date: Friday, August 8, 2008 14:56 Subject: Re: [Jprogramming] general Gamma distribution To: Programming forum <[email protected]> > Robert, > > I think your use of I. in this way by first > generating the cumulative distribution is a huge take > away and I look forward to others using it for generating > discrete random variates besides Poisson such as binomial, > hypergeometric, negative binomial, etc. > > However, there is a caveat about using I. ; it must > be used carefully. For example, consider the case of a > SINGLE binomial trial, sometimes called a Bernoulli > experiment, for which there is only the possibility of > failure (X=0) or success (X=1). The cumulative distribution > function is as follows. > > 0 if x<0 > F(x) = 0.5 if 0<:x<1 > 1 if 1<:x > > But look at how I. works in this case. > > 0 0.5 1 I. 0.01 0.25 0.51 0.991 > 1 1 2 2 > > According to the Dictionary, ?0 produces > 0<Uvalues<1, so we need to use <:@I. here. > > 0 0.5 1 <:@I. 0.01 0.25 0.51 0.991 > 0 0 1 1 > > > > On Fri, 8 Aug 2008, Robert Cyr wrote: > > + poissonran=: 4 : 0 > + n=. 5*x > + (+/\(^-x)**/\1,x%}.i.>:n)I.?y$0 > + ) > + > + It's really fast and accurate for integer values as long as > the limit is > + chosen sufficiently large to ensure that the last of the > cumulated values is > + 1. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
