根据Plotting CCDF of walking durations,我生成了这样的ccdf图:
ccdf<-function(views,density=FALSE)
{
freq = table(views)
X = rev(as.numeric(names(freq)))
Y =cumsum(rev(as.list(freq)));
data.frame(x=X,count=Y)
}
library(ggplot2)
qplot(x,count,data=ccdf(views),log='xy')
Y轴= x值的计数,但我想得到Y = P [X> = x],我该怎么做?
答案 0 :(得分:0)
我不确切知道您的数据是什么样的,但听起来像是您想要的:
ccdf<-function(views,density=FALSE)
{
freq = table(views)
X = rev(as.numeric(names(freq)))
Y =cumsum(as.list(freq)); #not reversed
Y=(max(Y)-Y)/max(Y) #proportion, beware recursion!
data.frame(x=X,Cum.Prop=Y) #name change
}
qplot(x,Cum.Prop ,data=ccdf(views),log='xy')
如果您告诉我有关views
变量的更多信息,我可以确保它正常工作。