由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - Help with R
相关主题
a R loop question[合集] 问excel牛人一个问题
求助 R sample in matrix form请教一个关于R的问题
R:matrixcopy and paste column in sas
大牛指点下面的R Code 怎么用Loop来实现求助!请教我这个SAS code哪里错了啊?
如何处理下面这种情况求问 sas _c_ 什么意思
[求助]R程序run着run着就自己killed了,可能是什么原因?sas help
[R] a row of a matrix is not a matrix?求助:sas不同格式的日期比较
【欢迎进来讨论】for loop in R问个r问题
相关话题的讨论汇总
话题: row话题: 100话题: column话题: matrix话题: being
进入Statistics版参与讨论
1 (共1页)
y***6
发帖数: 46
1
If I have the following 3 by 3 matrix
A=[100 1 .3 <-first row
100 1 .6 <-second row
100 1 .9]<-third row
And I want to use each row of A to generate Bernoulli random variables
(With values in column 1, 100 in this example, being the number of random
numbers generated, second column being the size, and third column being the
trial probability). How to perform this task without using loops?
To be more specific, the resulting matrix B(3 by 100 matrix) shou
C******t
发帖数: 72
2
t(apply(a,1,function(x) rbinom(x[1],x[2],x[3])))
D******n
发帖数: 2836
3
there u go
result<-t(mapply(rbinom,A[,1],A[,2],A[,3]))

variables
the
be

【在 y***6 的大作中提到】
: If I have the following 3 by 3 matrix
: A=[100 1 .3 <-first row
: 100 1 .6 <-second row
: 100 1 .9]<-third row
: And I want to use each row of A to generate Bernoulli random variables
: (With values in column 1, 100 in this example, being the number of random
: numbers generated, second column being the size, and third column being the
: trial probability). How to perform this task without using loops?
: To be more specific, the resulting matrix B(3 by 100 matrix) shou

y***6
发帖数: 46
4
Thanks, I appreciate!
1 (共1页)
进入Statistics版参与讨论
相关主题
问个r问题如何处理下面这种情况
SAS里怎么根据VALUE来选择需要OUTPUT的COLUMNS[求助]R程序run着run着就自己killed了,可能是什么原因?
求助关于Excel IF 的function[R] a row of a matrix is not a matrix?
please help on R subtable question !【欢迎进来讨论】for loop in R
a R loop question[合集] 问excel牛人一个问题
求助 R sample in matrix form请教一个关于R的问题
R:matrixcopy and paste column in sas
大牛指点下面的R Code 怎么用Loop来实现求助!请教我这个SAS code哪里错了啊?
相关话题的讨论汇总
话题: row话题: 100话题: column话题: matrix话题: being