由买买提看人间百态

topics

全部话题 - 话题: combn
(共0页)
P********l
发帖数: 452
1
来自主题: JobHunting版 - 求教一个算法面试问题,被难住了
受益匪浅。
非常佩服han6,redcloud的数学推导。
这是按照han6的思路写的代码。
http://code.google.com/p/sureinterview/source/browse/test/test1/Matrix1.java#22
======
void generate(int n, int m) {
Integer[] segEnd = new Integer[n - 1];
for (int i = 0; i < n - 1; i++) {
segEnd[i] = i;
}
CombinationImpl combn = new CombinationImpl(Lists
.newArrayList(segEnd), m - 1);
for (List lastPos : combn) {
Integer[] codeSeed = new ... 阅读全帖
e********o
发帖数: 12
2
来自主题: Statistics版 - got a problem in R ><
Dear all,
I got a problem in R.
我想让R做出 4 choose 2
(我用了perm<-permutations(4,2)和combn(4, 2, replace=F))
(都没办法完全的弄出我要的形式)
(我要再把做出的1,2改成0
3,4改成1)
I would like to make a 6*4 matrix as below:(by permutation or combn指令)
(希望最终形态是长这样)
0011
0101
0110
1001
1010
1100
Can anyone help me??? Thank you so much!!!!!!!
g**r
发帖数: 425
3
来自主题: Statistics版 - R question
Thaks; following ur lead, i searched a few more fuctions and the following
seems to work:
x3=combn(3,3)
tx4=combn(5,4)
ttx4=tx4[1:nrow(x3),]
k=0
for (i in 1:ncol(ttx4))
if (sum(apply(y,2,setequal,x=ttx4[,i]))>0 ) k=c(k,-1*i)
x4=tx4[,k]
g**r
发帖数: 425
4
来自主题: Statistics版 - R question
If I have the result x=combn(3,3); and y=comb(5,4).
(x=1,2,3; y={1 2 3 4; 1 2 3 5; 1 2 4 5; 1 3 4 5; 2 3 4 5}
How can I remove those columns from y that the first 3 elements=X?
newy={1 2 4 5; 1 3 4 5; 2 3 4 5}
Any help is greatly appreciated...
(Bkgroud:
I have an experiment, and the total number of people in this experiment can
reach n, say 10.
Each result will be just Ber, say with p=0.2.
How ever, if I observe certain results, I will not continue the experiment.
Say if I see 3 out of 3 sucess
q**j
发帖数: 10612
5
来自主题: Statistics版 - R里面怎么construct power set?
combn(n,i) and
iterate on i
N******n
发帖数: 3003
6
get_quantiles <-function(diff_expr,diff_coex,klist,pop_size){
##### The function to get the "node_score_term" and "edge_score_term" of a
sub-network denoted by "vector"
my.fun<-function(vector){
return(diff_coex[vector[1],vector[2]])
}
# "vector" is a binary vector with length equal to the size of the whole
network.
# An element of value "1" indicates the inclusion of that gene in the
selected sub-network.
node_edge<-function(vector){
selected_subset<-which(vector==1)
n<-length(select... 阅读全帖
t*****w
发帖数: 254
7
来自主题: Statistics版 - 请问面试 R 应该怎么准备?
When I had my job interview, they always tested my SAS skill.However I use R
all the time. To help your preparation, read my R codes to see how much you
can understand it.
%in%
?keyword
a<-matrix(0,nrow=3,ncol=3,byrow=T)
a1 <- a1/(t(a1)%*%spooled%*%a1)^.5 #standadization in discrim
a1<- a>=2; a[a1]
abline(h = -1:5, v = -2:3, col = "lightgray", lty=3)
abline(h=0, v=0, col = "gray60")
abs(r2[i])>r0
aggregate(iris[,1:4], list(iris$Species), mean)
AND: &; OR: |; NOT: !
anova(lm(data1[,3]~data1[,1... 阅读全帖
(共0页)