KS_Lecture

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

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

View Full Document Right Arrow Icon
KS Lecture
Background image of page 1

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

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

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

View Full DocumentRight Arrow Icon
Step 1 2. Find your d. From our board work we know that d=0.2.
Background image of page 4
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
Background image of page 5

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

View Full DocumentRight Arrow Icon
Step 2 2. Find the empiracle cdf for this data: x=c(1.7126403, 0.4947011, 2.0737355, 0.2980405) plot.ecdf(x)
Background image of page 6
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
Background image of page 7

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

View Full DocumentRight Arrow Icon
Step 3 Repeat N=10000 times!
Background image of page 8
#***************** #**** 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 <-
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online