在 R 编程中计算经验累积分布函数的值 – ecdf()函数
R语言中的ecdf()
函数用于计算和绘制数值向量的经验累积分布函数的值。
Syntax: ecdf(x)
Parameters:
x: Numeric Vector
示例 1:
# R Program to compute the value of
# Empirical Cumulative Distribution Function
# Creating a Numeric Vector
x <- seq(1, 50, by = 2)
# Calling ecdf() Function
y <- ecdf(x)
y
输出:
Empirical CDF
Call: ecdf(x)
x[1:25] = 1, 3, 5, ..., 47, 49
示例 2:
# R Program to compute the value of
# Empirical Cumulative Distribution Function
# Creating a random vector
x <- rnorm(30)
# Calling ecdf() Function
y <- ecdf(x)
# Plot a graph
plot(y)
输出: