The “rt” Function in R
Package: Base R (no specific package required)
Purpose: Generates random numbers from a Student’s t-distribution.
General Class: Random Number Generation
Required Argument(s):
n: The number of random values to generate.
df: The degrees of freedom.
Notable Optional Arguments:
ncp: The non-centrality parameter. The default is 0.
Example:
# Generate 100 random values from a t-distribution with 10 degrees of freedom
random_values <- rt(n = 100, df = 10)
print(random_values)In this example, the rt function is used to generate 100 random values from a Student’s t-distribution with 10 degrees of freedom. The generated values are then printed to the console.