search for: choose

Displaying 20 results from an estimated 16121 matches for "choose".

2011 Jan 07
4
how to calculate this natural logarithm
Hello I want to calculate natural logarithm of sum of combinations as follow: (R code) { com_sum=choose(2000000,482)*choose(1000000,118)+choose(2000000,483)*choose(1000000,117)+...+choose(2000000,i)*choose(1000000,600-i)+...+choose(2000000,600)*choose(1000000,0) #calculate the sum result=log(com_sum) #calculate the log of the sum } But every elemen...
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 (2...
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 (2...
2004 Nov 08
4
About 'choose' function
Hello R-users, When I didn't know about the internal 'choose' function, I made such function, 'my.choose' below. But when I used them instead of choose(6000,20), they didn't give me any answer. What is the difference between 'choose', 'my.choose1', and 'my.choose2' below? That is, what is behind 'choose' funct...
2024 Dec 18
2
Query concerning working directory for file.choose()
Try choose.files choose.files(default = file.path(mydir, "*.*"), multi = FALSE) On Wed, Dec 18, 2024 at 10:33?AM J C Nash <profjcnash at gmail.com> wrote: > > I've been working on a small personal project that needs to select files for manipulation from > various directories...
2024 Dec 18
2
Query concerning working directory for file.choose()
I've been working on a small personal project that needs to select files for manipulation from various directories and move them around in planned ways. file.choose() is a nice way to select files. However, I've noticed that if file.choose() is called within a function, it is the directory from which that calling function has been invoked that is displayed by file.choose(). This is not altered if I setwd() within that function. Have I misunderstood someth...
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 lchoose(n, k) : NaNs produced > which (the NaN's) is not particularly useful. (I have use case...
2001 Dec 13
2
inconsistency between gamma and choose functions
Please can someone explain why I seem to get these contradictory results? choose(5,2) [1] 10 gamma(6)/(gamma(3)*gamma(4)) [1] 10 gamma(6)/(gamma(3)*gamma(4)) == choose(5,2) [1] TRUE # all's well so far. # now look what happens: gamma(21)/(gamma(6)*gamma(16)) == choose(20,5) [1] FALSE # check individual terms: gamma(21)/(gamma(6)*gamma(16)) [1] 15504 choose(20,5) [1] 15504...
2020 Jan 14
2
[R] choose(n, k) as n approaches k
> On 14 Jan 2020, 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 */ >...
2005 Aug 15
1
Anything like dir.choose (similar to file.choose) in R?
Does R have a dir.choose function? I can use file.choose like this as a kludge to get something like a dir.choose, but a real dir.choose would be better: cat("Select one of files in directory to process:\n") filename <- gsub("\\\\", "/", file.choose()) basepath <- dirname(filenam...
2012 Sep 06
2
choose() function returning anomalous results (zero instead of one)
Hello, (Apologies for length, wanted to get all the relevant detail in that I know of). I've been having a lot of trouble with some code for an inventory analysis problem I was doing, and finally came to the conclusion that it appears that choose() is returning incorrect values. Specifically: ------------- Browse[1]> nn [1] 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 Browse[1]> Q1 [1] 3 Browse[1]> choose(Q1,3) [1] 0 Browse[1]> choose(Q1,nn) [1] 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 0 0 0 0 0 0 0 -...
2020 Jan 14
4
[R] choose(n, k) as n approaches k
...0, 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.; &gt...
2024 Dec 18
2
Query concerning working directory for file.choose()
I believe file.choose() remembers the last choice, and repeats that location the next time you call it. This is true when it is called at top level or from within a function. The first time you call it in a session, it will default to the current working directory, but not after that. Front ends are allowed to repl...
2009 Sep 23
1
set choose.files directory?
Hi, I've been trying to set the directory for choose.files as follows: [R2.9.0 running on XP] setwd("C:/Documents and Settings/2/Data") getwd() infile2 = choose.files(filters = Filters[c("txt","All"),], caption = "Choose ECD datafile") #<...do a bunch of stuff...> It appears the working directory isn...
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...
2006 Aug 24
4
extremely slow recursion in R?
I recently coded a recursion algorithm in R and ir ran a few days without returning any result. So I decided to try a simple case of computing binomial coefficient using recusrive relationship choose(n,k) = choose(n-1, k)+choose(n-1,k-1) I implemented in R and Fortran 90 the same algorithm (code follows). The R code finishes 31 minutes and the Fortran 90 program finishes in 6 seconds. So the Fortran program is 310 times faster. I thus wondered if there is room for speeding up recursion in R. T...
2020 Jan 15
1
[R] choose(n, k) as n approaches k
That crossed my mind too, but presumably someone designed choose() to handle the near-integer cases specially. Otherwise, we already have beta() -- you just need to remember what the connection is ;-). I would expect that it has to do with the binomial and negative binomial distributions, but I can't offhand picture a calculation that leads to integer k, n...
2008 Mar 26
2
choose fails a fundamental property of binomial coefficients (PR#11035)
Full_Name: Jerry W. Lewis Version: 2.7.0 (2008-03-23 r44847) OS: Windows XP Professional Submission from: (NULL) (71.184.230.48) choose(n,k) = choose(n,n-k) is not satisfied if either 1. n is a negative integer with k a positive integer (due to automatically returning 0 for n-k<0) 2. n is not an integer with k a positive integer (due to rounding n-k to an integer, compounded by automatically returning 0 if n<0 which implies...
2003 Aug 30
3
fisher.test() gives wrong confidence interval (PR#4019)
...ty mass of each possible table with same marginals as x. Ref.: Alan Agresti (1990). Categorical data analysis. New York: Wiley. Page 67. Hence, the result below suggests that the two-sided confidence interval has a confidence level of 97.5% as opposed to 95%. n11 <- 7:9 theta <- 0.2985103 choose(9,n11)*choose(15-9,13-n11)*theta^n11/ sum(choose(9,n11)*choose(15-9,13-n11)*theta^n11) #[1] 0.67344877 0.30154709 0.02500414 The 95% confidence interval with one-sided (greater) alternative appears to be correct. theta <- 0.4625314 choose(9,n11)*choose(15-9,13-n11)*theta^n11/ sum(choose(9...
2010 Mar 02
1
problem with choose.files
I have recently upgraded to R 2.10.1 on Windows XP and am using scripts that I've used in previous versions successfully. I'm having a problem with choose.files. The lines read: fura_scan_file<-choose.files(caption="Select log file (*.log) for fura-2 scans") PI_scan_file<-choose.files(caption="Select log file (*.log) for PI scans") The problem is that the directory chosen after the first choose.files is not remembered. Th...