分位数与 ecdf 结果
quantile vs ecdf results
我正在尝试使用 ecdf,但不确定是否正确。我的最终目的是找到与特定值对应的分位数。例如:
sample_set <- c(20, 40, 60, 80, 100)
# Now I want to get the 0.75 quantile:
quantile(x = sample_set, probs = 0.75)
#result:
75%
80
# Let's use ecdf
ecdf(x = sample_set) (80)
#result
0.8
为什么会出现这种差异?我是在犯一些小错误,还是取决于分位数的计算方式?
谢谢,
最大值
有两点。首先,如您所料,这取决于 quantile
进行计算的方式。具体取决于参数type
。您可能想要选择的是 type = 1
,因为它对应于 经验分布函数的逆函数 (参见 ?quantile
)。其次,由于 ecdf
给出了一个离散的阶跃函数,即 ecdf 不是严格递增的,由于分位数是 defined 的方式(参见第二个公式),您无法获得完全相等。
我正在尝试使用 ecdf,但不确定是否正确。我的最终目的是找到与特定值对应的分位数。例如:
sample_set <- c(20, 40, 60, 80, 100)
# Now I want to get the 0.75 quantile:
quantile(x = sample_set, probs = 0.75)
#result:
75%
80
# Let's use ecdf
ecdf(x = sample_set) (80)
#result
0.8
为什么会出现这种差异?我是在犯一些小错误,还是取决于分位数的计算方式?
谢谢, 最大值
有两点。首先,如您所料,这取决于 quantile
进行计算的方式。具体取决于参数type
。您可能想要选择的是 type = 1
,因为它对应于 经验分布函数的逆函数 (参见 ?quantile
)。其次,由于 ecdf
给出了一个离散的阶跃函数,即 ecdf 不是严格递增的,由于分位数是 defined 的方式(参见第二个公式),您无法获得完全相等。