I think these probability distribution functions were meant to be instructive than indestructible.
In the case of binomialprob, there is indeed a problem in binomialdist when p is quite small and n is quite large. A switch was used when p <: 0.5; it should instead apply when p>0.5 : binomialdist=: 3 : 0 'p n'=. y if. b=. p>0.5 do. p=. -. p end. NB. NOT p<:0.5 !!! q=. -.p r=. }.i.>:n r=. (q^n)**/\1,(p% q)*(>:n-r)%r if. b do. |. r end. ) binomialprob 0.0143281399120119, 2872 41 41 0.0626089 Mike On 15/03/2012 4:19 PM, Tarmo Veskioja wrote: > The syntax description is here: > http://www.jsoftware.com/jwiki/Addons/stats/base/distribution#binomialdist > > A simple working example: > > load 'statdist' > binomialdist 0.5 5 > NB. 0.03125 0.15625 0.3125 0.3125 0.15625 0.03125 > > binomialprob 0.5 5 4 4 NB. what are the odds of getting 4 successes > out of 5 trials with success of 0.5 in any individual trial > NB. 0.15625 > > The same in R or RStudio: > > dbinom(4, 5, 0.5)[1] 0.15625 > > ------------------------------------ > Now some unexpected results: > > First in RStudio: > >> dbinom(41, 2872, 0.0143281399120119)[1] 0.06260893 > > And now in j602a: > binomialprob 0.0143281399120119 2872 41 41 > NB. 0 > > x: binomialprob 0.0143281399120119 2872 41 41 > NB. 0 > > I also get weird results with this: > binomialdist 0.07 280 > > And this: > binomialprob 0.075 280 20 20 > NB. _ > > The last one in RStudio gives this result: > >> dbinom(20, 280, 0.075)[1] 0.08980949 > -------------------- > > > Is this a bug in j602a statdist package? > My Package Manager shows stats/distribs version as 1.0.2, which is > indicated as the latest. > > Regards, > Tarmo Veskioja > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm