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?
quants
defined? What exactly are you trying to do? By usingquantile()
inside theecdf()
you are basically doing the inverse operation. Most likely you would be getting values very close to whatever values ofquants
you pass in. They basically cancel each other out.all.equal(ecdf(gg)(quantile(gg, quants)), ecdf(ff)(quantile(ff, quants)))
yields[1] "Mean relative difference: 0.01136364"
. They look the same but they are not. If you runecdf(gg)(quantile(gg, quants)) - ecdf(ff)(quantile(ff, quants))
you'll see that there are some minor differences. This to me suggests that theff
andgg
datasets are similarly (not identically) distributed.