0
$\begingroup$

Is it possible generate to have a non-random, systematically spaced sequence of numbers that is more or less "normal" in its distribution?

I know I can pull say 10 numbers randomly from a normal distribution in r using rnorm(10). What I'd prefer for one application, if it is possible, is some sequence of ten (or N) numbers that is not random but rather has about the same characteristics (eg mean, variance, skewness and kurtosis, maybe others) as the random data.

Is this somehow possible or is there some reason one should never try this? If the former, I'd appreciate a hint for how one could code such a thing in R.

$\endgroup$
  • 2
    $\begingroup$ If you want systematically-spaced data, what about normal scores/(approximate) expected normal order statistics (as used in a Q-Q plot for example)? $\endgroup$ – Glen_b -Reinstate Monica Jan 4 '18 at 7:35
0
$\begingroup$

You can use the bayestestR package:

library(bayestestR)
x <-  rnorm_perfect(n = 10, mean = 0, sd = 1)
plot(density(x))

enter image description here

$\endgroup$
  • $\begingroup$ this is precisely the answer. variable x is a perfectly "normally distributed non-random sequence of numbers". i have no clue why the downvote $\endgroup$ – gaspar May 21 '19 at 15:59
3
$\begingroup$

It is hard to answer without knowing the motivation, 'why would you want to do that'?

If it helps, the random numbers generated by libraries (R or others) are not true random numbers but pseudo-random numbers. These are generated algorithmically and if you knew the first element in the sequence you can potentially know all future values. This is the reason why most of the random number generation functions take an argument to seed the psuedo-random sequence generator. Check documentation for setting seed here.

We don't care if the generated (pseudo) random numbers are really random. We check their statistical properties and as long as they are statistically random, we can use them. Aside, random number generators are not all equal and some are better than others (they generate statistically robust pseudo random numbers) and there are many tests for verifying bias of random number generators.

If your aim is to re-use the same set of random numbers again and again whenever you repeat an experiment, then use seed setting (link given above).

$\endgroup$
0
$\begingroup$

If you're not happy with standard library functions such as rnorm, which generates deterministic sequences that can fool anybody into thinking they're random, then you can do them yourself using linear congruental generators (LCG).

For instance, the simple one is Lehmer: $$X_{n+1} = a \cdot X_n ~~\bmod~~m$$ The author suggested values for parameters are: $m=2^{31}-1,a=48271 $. Note the use of a modulus operator. You start with any seed integer $X_0$ and keep iterating to get the sequences of numbers. Just avoid these parameters: $m=2^{31},a=65539$

Another approach is to use quasi-random sequences such as Sobol sequences. These are popular in Monte Carlo integration applications, and are slightly more difficult to generate

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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