search for: nchoosek

Displaying 5 results from an estimated 5 matches for "nchoosek".

2008 Aug 22
1
Retrieving sample points
...t the problem is that it does not work when the dimension of X is large (when n is greater than 25). I think the problem is memory size, is there anyway I can maximize the memory. Here is the syntax that I used.   > bestunits <- function(x){ + n <- nrow(x) + p <- ncol(x) + h <- p+1 + nchoosek <- function(n,h){ + factorial(n)/(factorial(h+1)*factorial(n-h-1))} + vec11 <- matrix(nrow=nchoosek(n,h), ncol=p) + vec12 <- matrix(nrow=nchoosek(n,h), ncol=h) + for (i in 1:nchoosek(n,h)){ + flag <- sample(1:n, h, replace=FALSE) + z <- x[flag,] + y <- eigen(var(z), only.values=TR...
2012 Sep 06
2
choose() function returning anomalous results (zero instead of one)
...e any of it in; browser() is not in the code below, but I generally put it somewhere in ugly_function() to check on choose(), but it looks like ugly finishes executing and goes back to body of the program before letting me do anything. (Commented out is my problematic solution, using R.basic's nChooseK on the values most likely to return anomalous results. and bits of debug code). Shayne Hodge schodge@ieee.org # VeridianDynamics Inventory Optimization Script # Copyright 2012 Shayne Hodge # Two-vendor Sensitivity Analysis rm(list=ls()) # Clear previous session data library("R.basic")...
2006 May 26
2
combinatorial programming problem
Hola! I am programming a class (S3) "symarray" for storing the results of functions symmetric in its k arguments. Intended use is for association indices for more than two variables, for instance coresistivity against antibiotics. There is one programming problem I haven't solved, making an inverse of the index function indx() --- se code below. It could for instance return the
2003 Aug 01
1
index all subsets of k of m items?
How can I efficiently index all choose(m, k) subsets of m items taken k at a time? For example, with (m, k) = (3, 2), the subsets are (1, 2), (1, 3), and (2, 3). I'd like a function something like "index.subsets(subset, k, m)" that would return 1, 2 or 3 for these 3 subsets. Examples: index.subsets(c(1,2), 2, 3) -> 1 index.subsets(c(1,3), 2, 3) -> 2
2006 May 09
1
combn(n, k, ...) and all its re-inventions
...DATE WRITTEN: 14 April 1994 LAST REVISED: 10 July 1995 # AUTHOR: Scott Chasalow OTOH, people have since reinvented the wheel quite prolifically: There's combinations() in gtools {based on Bill Venables' code from R News 1/1}, combs() in CAtools, subsets() in BHH2, and nchoosek() in vsn (bioconductor); then 'fwd.combn' in package "forward" which states explicitly that it is Scott's combn() renamed.. I stopped searching for more, and I've made sure all these 6 functions compute the same thing, at least in the most simple case. After simply replac...