[R] Maximum of Maximum

arun smartpink111 at yahoo.com
Fri Jan 10 21:31:46 CET 2014


Hi,

May be this helps:
set.seed(42)
 vec1 <- sapply(1:1000,function(x) max(rnorm(1000,0,1)))
#or
set.seed(42)
 vec2 <- replicate(1000,max(rnorm(1000,0,1)))
identical(vec1,vec2)
#[1] TRUE

set.seed(598)
res <- sample(vec1,100,replace=FALSE)

 max(res)
#[1] 4.408794
A.K.

Hello I need some help in programming: 

I want to after take a rnorm(1000,0,1) sample want to save the 
max of it in a vector, this was difficult to me, then I need to repeat 
this process 1000 times, so I shall have 1000 maximum from the normal of
 samples of size 1000. 
Then I want to sample from this maximum series a new sample, this time of size 100. 

I drive a programm: 

sample<-rnorm(1000,0,1) 
for(i in 1:length(sample)){ 
   maxim<-vector(mode="numeric",length(sample)) 
   maxim[i]<-max(sample) 
} 

then my result was a vector with n-1 zeroes and the last one 
value was a maximum. I think it took the last value, but I don't know 
how to repair it. 

I need most help, thanks 




More information about the R-help mailing list