在 R 编程中计算随机绘制的卡方密度 – rchisq()函数
R 语言中的rchisq()
函数用于计算一组值的随机卡方密度。
Syntax: rchisq(N, df)
Parameters:
N: Sample Size
df: Degree of Freedom
示例 1:
# R program to generate
# random chi square density points
# Setting seed for
# random number generation
set.seed(1000)
# Set sample size
N <- 20
# Calling rchisq() Function
y <- rchisq(N, df = 10)
y
输出:
[1] 7.208082 11.236799 3.780669 5.972266 12.174243 14.308333 3.886482
[8] 4.117081 13.015581 3.864009 8.494487 17.713528 2.411329 7.096494
[15] 4.546996 11.542960 9.683502 9.073933 11.120782 9.193626
示例 2:
# R program to generate
# random chi square density points
# Setting seed for
# random number generation
set.seed(1000)
# Set sample size
N <- 500
# Calling rchisq() Function
y <- rchisq(N, df = 10)
# Plotting graph
plot(y)
输出: