Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Simulation in R and find the min values

$
0
0

everyone here. Here is the question:

(a)For a sample size of n = 1, generate N = 1000 data sets from an exp(1) distribution. (b) For each data set, find the min value (for a sample of size 1 that will just be the value itself). (c) Save these minimum values for plotting.

I have a question about understanding part a. Does it mean that only generate one sample size (observation) from exp(1) each time and then repeat the process for 1000 times to obtain 1000 data sets or just directly generate 1000 observations from exp(1)? Here is my code for this part:

set.seed(1000)

N <- 1000

mins <- rep(0,N)

for (i in 1:N){
  mins[i] <- min(rexp(1))

}

plot(x=1:N, y=mins)

Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>