为什么分位数不会显示不同的结果?

发布于 2025-02-13 12:12:31 字数 465 浏览 3 评论 0 原文

我正在尝试在此处使用此解决方案

 dat[, .(quant = quants, val = ecdf(dist)(quantile(dist, quants))), by = rowval]

但是,这给出了每个Rowval的不同结果

,但是,当我将其应用于数据时,我总是得到相同的输出

示例:

     ecdf(gg)(quantile(gg, quants))
     ecdf(ff)(quantile(ff, quants))

为什么我对FF和GG都相同?

I am trying to use this solution here

How to rank based on ecdf in r?

 dat[, .(quant = quants, val = ecdf(dist)(quantile(dist, quants))), by = rowval]

This gives diffent results for each rowval

However, when i apply it to my data, I always got the same output

example:

     ecdf(gg)(quantile(gg, quants))
     ecdf(ff)(quantile(ff, quants))

Why I am getting the same for both ff and gg?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

趴在窗边数星星i 2025-02-20 12:12:31

“分布距离(数据集)与参考数据集的

距离”是最简单的:

quants <- seq(0, 1, length.out = 51)
ref <- quantile(tt, quants)
sumsq <- sapply(list(gg=gg, ff=ff, ps=ps), function(z) sum( (quantile(z, quants) - ref)^2 ))
sumsq
#        gg        ff        ps 
# 76290.859 29150.399  4237.075 

SO PS 是您参考 tt 的“最接近”分发/数据集。

对此的视觉确认:

library(ggplot2)
alldat <- rbind(data.frame(id="ff",x=ff), data.frame(id="gg",x=gg), data.frame(id="ps",x=ps), data.frame(id="tt",x=tt))
ggplot(alldat, aes(x, color = id)) + stat_ecdf(geom = "step")

“

"Distance of distributions (dataset) from a reference dataset"

Sum-of-squares seems easiest:

quants <- seq(0, 1, length.out = 51)
ref <- quantile(tt, quants)
sumsq <- sapply(list(gg=gg, ff=ff, ps=ps), function(z) sum( (quantile(z, quants) - ref)^2 ))
sumsq
#        gg        ff        ps 
# 76290.859 29150.399  4237.075 

So ps is the "closest" distribution/dataset from your reference tt.

Visual confirmation of this:

library(ggplot2)
alldat <- rbind(data.frame(id="ff",x=ff), data.frame(id="gg",x=gg), data.frame(id="ps",x=ps), data.frame(id="tt",x=tt))
ggplot(alldat, aes(x, color = id)) + stat_ecdf(geom = "step")

comparison of ECDF curves

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文