ecdf

How to plot CCDF graph on a logarithmic scale?

為{幸葍}努か 提交于 2020-06-11 10:41:46
问题 I want to plot a CCDF graph for some of my simulated power-law tail data on a log-log axis, below is my R code of plotting a CCDF graph on a normal axis, I used the code on the link: (How to plot a CCDF gragh?) > load("fakedata500.Rda") > x<-fakedata500 > f<-ecdf(x) > f Empirical CDF Call: ecdf(x) x[1:500] = 0.50174, 0.50307, 0.50383, ..., 81.674, 140.63 > plot(f) Below is the ECDF graph: > plot(sort(x), 1-f(sort(x)), type="s", lwd=1) and this command gives me the CCDF graph: However, I would

Create a table with values from ecdf graph

丶灬走出姿态 提交于 2020-05-24 06:30:12
问题 I am trying to create a table using values from an ecdf plot. I've recreated an example below. #Data data(mtcars) #Sort by mpg mtcars <- mtcars[order(mtcars$mpg),] #Make arbitrary ranking variable based on mpg mtcars <- mtcars %>% mutate(Rank = dense_rank(mpg)) #Make variable for percent picked mtcars <- mutate(mtcars, Percent_Picked = Rank/max(mtcars$Rank)) #Make cyl categorical mtcars$cyl<-cut(mtcars$cyl, c(3,5,7,9), right=FALSE, labels=c(4,6,8)) #Make the graph ggplot(mtcars, aes(Percent

Get data associated to ggplot + stat_ecdf()

拜拜、爱过 提交于 2020-02-24 18:21:55
问题 I like the stat_ecdf() feature part of ggplot2 package, which I find quite useful to explore a data series. However this is only visual, and I wonder if it is feasible - and if yes how - to get the associated table? Please have a look to the following reproducible example p <- ggplot(iris, aes_string(x = "Sepal.Length")) + stat_ecdf() # building of the cumulated chart p attributes(p) # chart attributes p$data # data is iris dataset, not the serie used for displaying the chart 回答1: We can

Input to fit a power-law to degree distribution of a network

北城余情 提交于 2020-01-24 10:31:32
问题 I would like to use R to test whether the degree distribution of a network behaves like a power-law with scale-free property. Nonetheless, I've read different people doing this in many different ways, and one confusing point is the input one should use in the model. Barabasi, for example, recommends fitting a power-law to the 'complementary cumulative distribution' of degrees (see Advanced Topic 3.B of chapter 4, figure 4.22). However, I've seen people fit a power-law to the degrees of the

quantile vs ecdf results

三世轮回 提交于 2020-01-03 18:46:49
问题 I am trying to use ecdf, but I am not sure if I am doing it right. My ultimate purpose is to find what quantile corresponds to a specific value. As an example: sample_set <- c(20, 40, 60, 80, 100) # Now I want to get the 0.75 quantile: quantile(x = sample_set, probs = 0.75) #result: 75% 80 # Let's use ecdf ecdf(x = sample_set) (80) #result 0.8 Why is there this discrepancy? Am I doing some trivial mistake, or it depends on the way quantile makes its calculations? Thanks, Max 回答1: There are

Plotting CCDF of walking durations

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-03 05:28:20
问题 I have plotted the CCDF as mentioned in question part of the maximum plot points in R? post to get a plot(image1) with this code: ccdf<-function(duration,density=FALSE) { freqs = table(duration) X = rev(as.numeric(names(freqs))) Y =cumsum(rev(as.list(freqs))); data.frame(x=X,count=Y) } qplot(x,count,data=ccdf(duration),log='xy') Now, on the basis of answer by teucer on Howto Plot “Reverse” Cumulative Frequency Graph With ECDF I tried to plot a CCDF using the commands below: f <- ecdf(duration

How to find in which quantile bin does a number fall

旧街凉风 提交于 2019-12-23 03:45:16
问题 I know how to find quantile of an empirical distribution. set.seed(1) x = rnorm(100) q = quantile(x, prob=seq(0,1,.01)) Is there a function that would give me the quantile bin a number of the training set belongs to ? In this example R) x[1] [1] -0.6264538107 R) q 0% 1% 2% 3% 4% 5% 6% 7% 8% -2.214699887177 -1.991605177777 -1.808646490230 -1.532008555284 -1.472864960560 -1.381744198182 -1.282620249360 -1.255240516814 -1.226934277726 9% 10% 11% 12% 13% 14% 15% 16% 17% -1.137935552774 -1

How to plot multiple ECDF's on one plot in different colors in R

拜拜、爱过 提交于 2019-12-21 18:32:53
问题 I am trying to plot 4 ecdf functions on one plot but can't seem to figure out the proper syntax. If I have 4 functions "A, B, C, D" what would be the proper syntax in R to get them to be plotted on the same chart with different colors. Thanks! 回答1: The package latticeExtra provides the function ecdfplot. library(lattice) library(latticeExtra) set.seed(42) vals <- data.frame(r1=rnorm(100)*0.5, r2=rnorm(100), r3=rnorm(100)*2) ecdfplot(~ r1 + r2 + r3, data=vals, auto.key=list(space='right') 回答2:

R: Plotting one ECDF on top of another in different colors

此生再无相见时 提交于 2019-12-21 09:24:51
问题 I have a couple of cumulative empirical density functions which I would like to plot on top of each other in order to illustrate differences in the two curves. As was pointed out in a previous question, the function to draw the ECDF is simply plot(Ecdf()) And as I read the fine manual page, I determined that I can plot multiple ECDFs on top of each other using something like the following: require( Hmisc ) set.seed(3) g <- c(rep(1, 20), rep(2, 20)) Ecdf(c( rnorm(20), rnorm(20)), group=g)

How can I plot two cumulative distributions curve as line type in same plot

纵饮孤独 提交于 2019-12-12 04:42:41
问题 I want to plot cumulative distributions curve for Weibull distribution over empirical cumulative distribution curve. I have tried with this several times but it does not serve the way I want. Here is the command: x<-(SIZEDIST$AVG.µm.) x plot(x,pweibull(x,shape=1.120662,scale=18.496778),type="l",col=4) plot(ecdf(x),add=TRUE) 回答1: Use lines instead of plot plot(x,pweibull(x,shape=1.120662,scale=18.496778),type="l",col=4) lines(ecdf(x),col='red') 回答2: Like this? set.seed(1) # for reproducibility