【问题标题】:how to draw ccdf in R with y axis showing probability如何在R中绘制ccdf,y轴显示概率
【发布时间】:2012-08-15 22:57:23
【问题描述】:

根据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],我该怎么做?

【问题讨论】:

    标签: r


    【解决方案1】:

    我不确切知道您的数据是什么样的,但听起来像您想要的:

    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 变量的信息,我可以确保它工作正常。

    【讨论】:

      猜你喜欢
      • 2021-03-03
      • 2013-02-05
      • 2016-09-28
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多