1
$\begingroup$

I have been trying to create 500 samples of length 50 (each sample is exp(50, 3)) but I have failed so many times. I do not know how to create a vector of length 500 of samples. I´m a rookie in R. Any help will be highly appreciated.

$\endgroup$

1 Answer 1

5
$\begingroup$

The following command creates a $50 \times 500$ matrix. The columns correspond to the samples.

replicate(500, rexp(50, 3))

The random values are distributed exponentially with rate $\lambda = 3$.

The command exp(50, 3) creates a vector with 50 random values. The function replicate is used to repeat the command 500 times.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.