search for: k_small_max

Displaying 10 results from an estimated 10 matches for "k_small_max".

2020 Jan 14
2
[R] choose(n, k) as n approaches k
...at 16:21 , Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > > On 14/01/2020 10:07 a.m., peter dalgaard wrote: >> Yep, that looks wrong (probably want to continue discussion over on R-devel) >> I think the culprit is here (in src/nmath/choose.c) >> if (k < k_small_max) { >> int j; >> if(n-k < k && n >= 0 && R_IS_INT(n)) k = n-k; /* <- Symmetry */ >> if (k < 0) return 0.; >> if (k == 0) return 1.; >> /* else: k >= 1 */ >> if n is a near-integer, then k can...
2020 Jan 14
1
[R] choose(n, k) as n approaches k
Yep, that looks wrong (probably want to continue discussion over on R-devel) I think the culprit is here (in src/nmath/choose.c) if (k < k_small_max) { int j; if(n-k < k && n >= 0 && R_IS_INT(n)) k = n-k; /* <- Symmetry */ if (k < 0) return 0.; if (k == 0) return 1.; /* else: k >= 1 */ if n is a near-integer, then k can become non-integer and negative. In your case, n ==...
2020 Jan 13
3
choose(n, k) as n approaches k
This struck me as incorrect: > choose(3.999999, 4) [1] 0.9999979 > choose(3.9999999, 4) [1] 0 > choose(4, 4) [1] 1 > choose(4.0000001, 4) [1] 4 > choose(4.000001, 4) [1] 1.000002 Should base::choose(n, k) check whether n is within machine precision of k and return 1? Thanks, Erik *** sessionInfo() R version 3.6.0 beta (2019-04-15 r76395) Platform: x86_64-apple-darwin15.6.0
2020 Jan 13
3
choose(n, k) as n approaches k
This struck me as incorrect: > choose(3.999999, 4) [1] 0.9999979 > choose(3.9999999, 4) [1] 0 > choose(4, 4) [1] 1 > choose(4.0000001, 4) [1] 4 > choose(4.000001, 4) [1] 1.000002 Should base::choose(n, k) check whether n is within machine precision of k and return 1? Thanks, Erik *** sessionInfo() R version 3.6.0 beta (2019-04-15 r76395) Platform: x86_64-apple-darwin15.6.0
2020 Jan 14
4
[R] choose(n, k) as n approaches k
...ncan at gmail.com> wrote: >>> >>> On 14/01/2020 10:07 a.m., peter dalgaard wrote: >>>> Yep, that looks wrong (probably want to continue discussion over on R-devel) >>>> I think the culprit is here (in src/nmath/choose.c) >>>> if (k < k_small_max) { >>>> int j; >>>> if(n-k < k && n >= 0 && R_IS_INT(n)) k = n-k; /* <- Symmetry */ >>>> if (k < 0) return 0.; >>>> if (k == 0) return 1.; >>>> /* else: k >= 1 */ >...
2009 Dec 15
3
RFC: lchoose() vs lfactorial() etc
lgamma(x) and lfactorial(x) are defined to return ln|Gamma(x)| {= log(abs(gamma(x)))} or ln|Gamma(x+1)| respectively. Unfortunately, we haven't chosen the analogous definition for lchoose(). So, currently > lchoose(1/2, 1:10) [1] -0.6931472 -2.0794415 NaN -3.2425924 NaN -3.8869494 [7] NaN -4.3357508 NaN -4.6805913 Warning message: In
2020 Jan 14
0
[R] choose(n, k) as n approaches k
On 14/01/2020 10:07 a.m., peter dalgaard wrote: > Yep, that looks wrong (probably want to continue discussion over on R-devel) > > I think the culprit is here (in src/nmath/choose.c) > > if (k < k_small_max) { > int j; > if(n-k < k && n >= 0 && R_IS_INT(n)) k = n-k; /* <- Symmetry */ > if (k < 0) return 0.; > if (k == 0) return 1.; > /* else: k >= 1 */ > > if n is a near-integer, then k can become non-in...
2020 Jan 14
0
[R] choose(n, k) as n approaches k
...rdoch <murdoch.duncan at gmail.com> wrote: >> >> On 14/01/2020 10:07 a.m., peter dalgaard wrote: >>> Yep, that looks wrong (probably want to continue discussion over on R-devel) >>> I think the culprit is here (in src/nmath/choose.c) >>> if (k < k_small_max) { >>> int j; >>> if(n-k < k && n >= 0 && R_IS_INT(n)) k = n-k; /* <- Symmetry */ >>> if (k < 0) return 0.; >>> if (k == 0) return 1.; >>> /* else: k >= 1 */ >>> if n i...
2020 Jan 15
1
[R] choose(n, k) as n approaches k
...t;>> >>>>> On 14/01/2020 10:07 a.m., peter dalgaard wrote: >>>>>> Yep, that looks wrong (probably want to continue discussion over on R-devel) >>>>>> I think the culprit is here (in src/nmath/choose.c) >>>>>> if (k < k_small_max) { >>>>>> int j; >>>>>> if(n-k < k && n >= 0 && R_IS_INT(n)) k = n-k; /* <- Symmetry */ >>>>>> if (k < 0) return 0.; >>>>>> if (k == 0) return 1.; >>>>>&gt...
2020 Jan 14
0
[R] choose(n, k) as n approaches k
...t; wrote: >>>> >>>> On 14/01/2020 10:07 a.m., peter dalgaard wrote: >>>>> Yep, that looks wrong (probably want to continue discussion over on R-devel) >>>>> I think the culprit is here (in src/nmath/choose.c) >>>>> if (k < k_small_max) { >>>>> int j; >>>>> if(n-k < k && n >= 0 && R_IS_INT(n)) k = n-k; /* <- Symmetry */ >>>>> if (k < 0) return 0.; >>>>> if (k == 0) return 1.; >>>>> /* else: k...