[英]Determine jumps in empirical distribution
Assuming we have a randomly sampled distribution, we can calculate and plot the associated ecdf as follows: 假设我们有一个随机抽样的分布,我们可以如下计算和绘制相关的ecdf:
set.seed(1)
t1 <- rnorm(10000,mean=20)
t1 <- sort(t1)
t1[1:1000] <- t1[1:1000]*(-100)
t1[1001:7499] <- t1[1001:7499]*50
t1[7500:10000] <- t1[7500:10000]*100
cdft1 <- ecdf(t1)
plot(cdft1)
Now in this case, there are jumps (created by intention) in the empirical distribution. 现在,在这种情况下,经验分布中存在跳跃(有意创建)。 By jumps I mean, that it increases by a lot, let's say by more than 100% of the value from before. 我的意思是跳跃,它增加了很多,比以前增加了100%。 This happens in the example at position 7,500. 该示例在位置7,500处发生。 My question is: How can I find these 'jump' indices most effectively? 我的问题是:如何最有效地找到这些“跳跃”指标?
You can get close to what you want just by looking at diff
of the sorted t1 values. 通过查看排序的t1值的diff
,您可以接近所需的值。
St1 = sort(t1)
which(diff(St1) > abs(St1[-length(St1)]))
[1] 1000 7499
At point 1000, St1 switches from -1632.8700 to 934.6916, which technically meets your criterion of "more than 100% change". 在点1000,St1从-1632.8700切换到934.6916,从技术上来说,它满足“超过100%变化”的标准。 It does not seem clear to me what is wanted when there is a sign change like this. 在我看来,当出现这样的标志变化时,想要什么是不清楚的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.