0
$\begingroup$

So, if for example I generate random sample of 1000 from exponential distribution and then simulate ks.test. for many times I get a normally distributed data, here is the code:

ks_test <-  function(n){
      df <-  rexp(n)
      st <-  sqrt(n)*(ks.test(izlase, "pexp", 1/mean(df))$statistic)
      return(st)
    }
    n <-  1000
    N <- 10000
    ks_stat <-  replicate(N,ks_test(n))
    hist(ks_stat, breaks = 25, col = "orange", prob = TRUE)
    lines(density(ks_stat),col = "black", lwd = 2)

But if I have a sample and I would like to see which distribution the data fits, I run into problem while creating the function. Here is the code I tried:

ks_test <-  function(n){
  
      st <-  sqrt(n)*(ks.test(df$x, "pexp", 1/mean(df$x))$statistic)
      return(st)
    }
    n <-  1000
    N <- 10000
    ks_stat <-  replicate(N,ks_test(n))
    hist(ks_stat, breaks = 25, col = "orange", prob = TRUE)
    lines(density(ks_stat),col = "black", lwd = 2)

I understand that the ks_stat gives the same number each time in this case, but I don't know what to do in case I need to check for the distribution if the only given is a sample of size 32. Anybody knows, how to construct the ks_test for numerous distribution to check if the data correspond to the distribution?

$\endgroup$
  • $\begingroup$ I remember that it is imperative for the Original source document to contain the CATEGORICAL SPECIFICS that ultimately will provide such successfully derived results. \\^..^// $\endgroup$ – Kti Pne Jun 17 at 0:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.