KS Code

# KS Code - # set.seed(i) s rdata &amp;amp;lt;-...

This preview shows page 1. Sign up to view the full content.

#***************** # #**** KS Code * #***************** # #KS exp will preform a KS test and return the Pvalue t KSEXP <- function (data,N,d) K { { data <- sort(data) #Sort the data in order o rate <- 1/mean(data) #Calculate the mean #ks is the set of all ks distances # ks <- NULL k for (i in 1:N) ( { { #generate data from EXP(rate) # #rdata is the random data
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: # set.seed(i) s rdata &lt;- sort(rexp(length(data),rate=rate)) s rrate &lt;- 1/mean(rdata) r D &lt;- max(abs(1-exp(-rrate*rdata)-seq(1/ length(data),1,by=1/length(data))), l abs(1-exp(-rrate*rdata)-seq(0,1-1/length(data),by=1/length(data)))) 1 ks&lt;-cbind(D, ks) k } } #end for # Pvalue &lt;- mean(ks&gt;d) P return(Pvalue) r }#end fn KSexp # KSEXP(c(1,4,9,16),10000,0.2)...
View Full Document

Ask a homework question - tutors are online