Distance between ecdf and cdf in R

126 Views Asked by At

I want to calculate the distance between ecdf and cdf with kolmogorov–Smirnov and plot the distance as function of the number of samples.

This is my code so far: How I created "exp_v":

N = 10000
u = runif(10000,0,1)
lambda = 1
formula = (-1/lambda)*log(1-u)
exp_v = c()
for (i in 0:N){
  exp_v <- rep(formula)
}


x_t <- seq(from = 0.01, to = 10.001, by = 0.001)


y_t2 = 1 - exp(-x_t)

sortedArray = sort(exp_v)
sampleRange = sort(seq_along(exp_v)/N)

plot(sortedArray,sampleRange,type="l",lwd="5",color="blue")
lines(x_t,y_t2,type="l",lwd="1",col="white")

Now I want to calculate the distance between the "Theoretical cdf" and "empirical cdf" Can someone help me with that? y_t2 - is the theoretical cdf sampleRange is the empirical values of ecdf

0

There are 0 best solutions below