5
$\begingroup$

rnorm is an R language function defined as:

rnorm.X generates multivariate normal random variates in the space X.

Consider rnorm(1000, 50, 5), drawing 1000 values from a normal distribution with mean 50 and standard deviation 5.

Are these 1000 values iid? If they are then the sampling is done with replacement. Are rnorm and runif samples generated with replacement or without replacement?

$\endgroup$
3
  • $\begingroup$ That is not the normal distribution in base R package stats. $\endgroup$ Commented Feb 29, 2020 at 14:54
  • $\begingroup$ @RuiBarradas Care to explain? rnorm is the way you draw random numbers from a normal distribution in base R. $\endgroup$
    – Ingolifs
    Commented Feb 29, 2020 at 21:14
  • 2
    $\begingroup$ @Ingolifs The link is to a function in a contributed package, that help page list 9 rnorm.X, functions, not rnorm, the base R function. $\endgroup$ Commented Feb 29, 2020 at 22:54

2 Answers 2

14
$\begingroup$

Both the normal and uniform distributions are continuous; ie, any particular value has probability of zero. Obviously there is numerical precision and other considerations involved with a machine-specific implementation but for all intents and purposes, you can suppose that $\mathbb P(X = x) = 0$ for any particular $x$; ie, the probability that you randomly draw a value identical to any particular point you specify is $0$. Further, if you have any countable (ie, you could count it out, possibly infinite) or finite (ie, you have a set with a fixed number of elements) set $\mathcal X$, $\mathbb P(X \in \mathcal X) = 0$ as well. That is, for any countable set of real numbers within the support of the distribution (for the uniform case, this would be $[0, 1]$, and for the normal case, the support is just all of the reals) there is also a probability of $0$ that a "new draw" or any finite number of draws will be equal to any of them (this applies for all continuous distributions; one can define mixed distributions in which this is NOT the case, but for continuous random variables, this is always the case as by definition a continuous distribution is defined over uncountably infinitely many points). There is no such thing as "with replacement" and "without replacement" if the distn function is continuous; further, if the distribution is discrete "without replacement" explicitly violates $iid$ (as you are specifically and deliberately omitting values from the possible sets of values based completely on the values you have already obtained). rnorm and runif generate $iid$ samples.

$\endgroup$
1
  • $\begingroup$ “rnorm and runif generate iid samples” They are pseudo random number generators. They do not generate iid samples. See for instance stats.stackexchange.com/questions/465536 that speaks about repetitions with runif that are more often than expected. $\endgroup$ Commented Dec 26, 2023 at 21:30
12
$\begingroup$

For "with replacement" and "without replacement" to be distinct, you'd need a finite population. If you have a finite population, you don't have a normal distribution (nor any other continuous distribution).

[Implementation wise, however, there's only a finite number of different values that it's possible to generate on a computer -- at any fixed number of bits, the computer can only represent a finite number of different values, so in that sense you have a finite population, and strictly speaking the distribution is discrete rather than continuous. However the normal model is itself continuous even though we don't have a way to practically generate values that are truly/perfectly from it.]

$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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