在 R 编程中计算卡方密度 – dchisq()函数
R 语言中的dchisq()
函数用于计算元素向量的卡方密度。它还为卡方分布创建密度图。
Syntax: dchisq(vec, df)
Parameters:
vec: Vector of x-values
df: Degree of Freedom
示例 1:
# R program to compute
# Chi Square Density
# Create a vector of x-values
x <- seq(0, 10, by = 1)
# Calling dchisq() Function
y <- dchisq(x, df = 5)
y
输出:
[1] 0.00000000 0.08065691 0.13836917 0.15418033 0.14397591 0.12204152
[7] 0.09730435 0.07437127 0.05511196 0.03988664 0.02833456
示例 2:
# R program to compute
# Chi Square Density
# Create a vector of x-values
x <- seq(0, 10, by = 0.1)
# Calling dchisq() Function
y <- dchisq(x, df = 5)
# Plot a graph
plot(y)
输出: