Checking the code of verb binomialdist tells you that the result in this
case will be 0
n=. 2872
p=. -. 0.0143281399120119
]q=. -.p
0.0143281
r=. }.i.>:n
The result of the line
r=. (q^n)**/\1,(p%q)*(>:n-r)%r
is all zero's.
(-:!.(0) 0$~#)(q^n)**/\1,(p%q)*(>:n-r)%r
1
Because
q^n
0
then all the values of */\ will be reduced to zero.
With the standard formula to calculate this, the answer should be
(s!n)*(q^s)*(-.q)^n-s
0.0626089
as shown by R.
FYI
On 15-03-12 17:19, 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
--
Met vriendelijke groet,
@@i = Arie Groeneveld
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm