R语言 计算随机抽样的芝罘区密度–rchisq()函数
R语言中的 rchisq() 函数用于计算一组数值的随机方程密度。
语法: rchisq(N, df)
参数:
N: 样本量
df: 自由度
例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)
输出: