Re: [R] Simulation based on runif to get mean

2018-01-30 Thread ruipbarradas
dl...@gmail.com>, smart hendsome <putra_autum...@yahoo.com>, r-help@r-project.org Assunto: Re: [R] Simulation based on runif to get mean Or a shorter version of Rui's approach: set.seed(2511)    # Make the results reproduciblefun <- function(n){  f <- function(){    c(mean(run

Re: [R] Simulation based on runif to get mean

2018-01-30 Thread Eric Berger
Or a shorter version of Rui's approach: set.seed(2511)# Make the results reproducible fun <- function(n){ f <- function(){ c(mean(runif(5,1,10)),mean(runif(5,10,20))) } replicate(n, f()) } fun(10) On Tue, Jan 30, 2018 at 12:03 PM, Rui Barradas wrote: >

Re: [R] Simulation based on runif to get mean

2018-01-30 Thread Rui Barradas
Hello, Another way would be to use ?replicate and ?colMeans. set.seed(2511)# Make the results reproducible fun <- function(n){ f <- function(){ a <- runif(5, 1, 10) b <- runif(5, 10, 20) colMeans(cbind(a, b)) } replicate(n, f()) } fun(10) Hope this

Re: [R] Simulation based on runif to get mean

2018-01-30 Thread Daniel Nordlund
On 1/29/2018 9:03 PM, smart hendsome via R-help wrote: Hello everyone, I have a question regarding simulating based on runif.  Let say I have generated matrix A and B based on runif. Then I find mean for each matrix A and matrix B.  I want this process to be done let say 10 times. Anyone can

[R] Simulation based on runif to get mean

2018-01-29 Thread smart hendsome via R-help
Hello everyone, I have a question regarding simulating based on runif.  Let say I have generated matrix A and B based on runif. Then I find mean for each matrix A and matrix B.  I want this process to be done let say 10 times. Anyone can help me.  Actually I want make the function that I can