Stats

8 Contributors: 1 Wednesday, March 29, 2017
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

Randomization

Introduction

The R language is commonly used for statistical analysis. As such, it contains a robust set of options for randomization. For specific information on sampling from probability distributions, see the documentation for distribution functions.

Remarks

Users who are coming from other programming languages may be confused by the lack of a rand function equivalent to what they may have experienced before. Basic random number generation is done using the r* family of functions for each distribution (see the link above). Random numbers drawn uniformly from a range can be generated using runif, for "random uniform". Since this also looks suspiciously like "run if", it is often hard to figure out for new R users.

Related Examples