search for: simmat

Displaying 2 results from an estimated 2 matches for "simmat".

Did you mean: sigmat
2011 Apr 17
2
Repeating a function
Hello all, I currently have this function: drift <-function(p0=0.4,N=40,ngen=55){ p = p0 for( i in 1:ngen){ p = rbinom(1,2*N,p)/(2*N) } return( p ) } I want to repeat it 1000 times, then do some analysis on the results. I've tried using the rep() function, but that only gives me repeats of the first value of p. How can I get 1000 values of p for different iterations of the
2011 Aug 25
2
How to store the output of a loop into a matrix??
Hello, I want to create a matrix of N random numbers with a uniform distributions. Later, I want to repeat T times each row of this matrix. For this I do the following loop: N<-45 T<-10 n<-N*T a<-matrix(runif(N,min=-1,max=1),nr=N) mymat<-matrix(rep(NA,n),nr=n,nc=1) for(i in i:N){ b<-rep(a[i,],T) mymat[i,]<-b } Mi problem is that with this loop I can see the output of the