KS_Lecture

# KS_Lecture - KS Lecture Putting the Board(Borred Example...

This preview shows pages 1–10. Sign up to view the full content.

KS Lecture

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Putting the Board (Borred!) Example Together You obtain the following data: 1, 4, 9, 16 You believe it is exponential.
Step 1 1. Find the ecdf. x=c(1,2,3,4)^2 plot.ecdf(x)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Step 1 2. Find your d. From our board work we know that d=0.2.
Step 2 1. Create data from an exponential with rate lambda=1/7.5. e.g. rexp(4,1/7.5) 1.7126403, 0.4947011, 2.0737355, 0.2980405

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Step 2 2. Find the empiracle cdf for this data: x=c(1.7126403, 0.4947011, 2.0737355, 0.2980405) plot.ecdf(x)
Step 2 3. Calculate the KS distance: F=sort(pexp(x,1/7.5)) Fhat1=c(1:4)/4 Fhat2=c(0:3)/4 d=max(abs(F- Fhat1),abs(F-Fhat2)) d = 0.76

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Step 3 Repeat N=10000 times!
#***************** #**** KS Code * #***************** #KS exp will preform a KS test and return the Pvalue KSEXP <- function (data,N,d) { data <- sort(data) #Sort the data in order rate <- 1/mean(data) #Calculate the mean #ks is the set of all ks distances ks <- NULL for (i in 1:N) { #generate data from EXP(rate) #rdata is the random data set.seed(i) rdata <-

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 25

KS_Lecture - KS Lecture Putting the Board(Borred Example...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online