在 R 编程中计算随机绘制的 F 密度 – rf()函数
R 语言中的rf()
函数用于计算 F 分布的随机密度。
Syntax: rf(N, df1, df2)
Parameters:
N: Sample Size
df: Degree of Freedom
示例 1:
# R Program to compute random values
# of F Density
# Setting seed for
# random number generation
set.seed(1000)
# Set sample size
N <- 20
# Calling rf() Function
y <- rf(N, df1 = 2, df2 = 3)
y
输出:
[1] 0.2254501 19.1565944 0.1462503 0.1443822 0.5184883 0.9231497
[7] 4.0047848 1.5749135 1.8080354 0.6584719 2.5080273 0.8327536
[13] 0.9125265 7.8437920 4.8880169 0.1858029 0.2296163 12.4537679
[19] 0.4680668 12.6245564
示例 2:
# R Program to compute random values
# of F Density
# Setting seed for
# random number generation
set.seed(1000)
# Set sample size
N <- 100
# Calling rf() Function
y <- rf(N, df1 = 2, df2 = 3)
# Plot a graph
plot(y)
输出: