The “runif” Function in R

  • Package: Base R (no specific package required)

  • Purpose: Generates random numbers from a uniform distribution.

  • General Class: Random Number Generation

  • Required Argument(s):

    • n: The number of random values to generate.

  • Notable Optional Arguments:

    • min: The minimum value of the distribution. The default is 0.

    • max: The maximum value of the distribution. The default is 1.

  • Example:

  • # Generate 100 random values from a uniform distribution between 1 and 10
    random_values <- runif(n = 100, min = 1, max = 10)
    print(random_values)

  • In this example, the runif function is used to generate 100 random values from a uniform distribution between 1 and 10. The generated values are then printed to the console.

Previous
Previous

The “rgeom” Function in R

Next
Next

The “rnorm” Function in R