Hello��
I have error in running the program:
Any hint or help will be appreciated!
Thanks in advance!
Yue
Error in (function (cl, name, valueClass) :
assignment of an object of class ��numeric�� is not valid for @��Dim�� in an
object of class ��dgTMatrix��; is(value, "integer") is not TRUE
Um, n(n-1)(n-2)...(n-k+1)/factorial(k), of course, but I think the argument
still holds.
Also, note that there are overflow conditions involved with computing
n(n-1)(n-2)...(n-k+1)/factorial(k)
as written, so it is computed in a loop with alternating multiply and divide
steps. This introduc
At the risk of throwing oil on a fire. If we are talking about fractional
values of choose() doesn't it make sense to look to the gamma function for the
correct analytic continuation? In particular k<0 may not imply the function
should evaluate to zero until we get k<=-1.
Example:
``` r
ch
OK, I see what you mean. But in those cases, we don't get the catastrophic
failures from the
if (k < 0) return 0.;
if (k == 0) return 1.;
/* else: k >= 1 */
part, because at that point k is sure to be integer, possibly after rounding.
It is when n-k is approximately b
On 14/01/2020 10:50 a.m., peter dalgaard wrote:
On 14 Jan 2020, at 16:21 , Duncan Murdoch 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_s
> On 14 Jan 2020, at 16:21 , Duncan Murdoch 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;
>>
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 */
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) ret
On 13/01/2020 6:33 p.m., Wright, Erik Scott wrote:
This struck me as incorrect:
choose(3.99, 4)
[1] 0.979
choose(3.999, 4)
[1] 0
choose(4, 4)
[1] 1
choose(4.001, 4)
[1] 4
choose(4.01, 4)
[1] 1.02
Should base::choose(n, k) check whether n is within machine preci
This struck me as incorrect:
> choose(3.99, 4)
[1] 0.979
> choose(3.999, 4)
[1] 0
> choose(4, 4)
[1] 1
> choose(4.001, 4)
[1] 4
> choose(4.01, 4)
[1] 1.02
Should base::choose(n, k) check whether n is within machine precision of k and
return 1?
Thanks,
Erik
***
sessionIn
Hi Bert
I sometimes use indexing with "which" too, depends on desired result,
especially with data frames.
x <- 1:10
x[5:6] <- NA
> xd <- data.frame(x, y=rnorm(10))
> xd[xd$x>3,]
x y
4 4 -1.5086790
NA NA NA
NA.1 NA NA
7 7 -0.2302614
8 8 -0.1660547
9
11 matches
Mail list logo