R语言 计算经验累积分布函数的值 – ecdf()函数
R语言中的 ecdf() 函数用于计算和绘制数字向量的经验累积分布函数的值。
语法: ecdf(x)
参数:
x: 数值向量
例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)
输出:

极客教程