# Example of multiple changes in mean at 50,100,150 in simulated normal data
set.seed(1)
x=c(rnorm(50,0,1),rnorm(50,5,1),rnorm(50,10,1),rnorm(50,3,1))
PELT.mean.norm(x,pen=2*log(200)) # returns c(50,100,150,200)
PELT.mean.norm(x,pen=2*log(200),nprune=TRUE) # returns vector showing how many points are kept during pruing at each iteration of the method
# Example no change in mean
set.seed(10)
x=rnorm(200,0,1)
PELT.mean.norm(x,pen=2*log(200)) # returns 200 to show no change in mean has been found
PELT.mean.norm(x,pen=2*log(200),nprune=TRUE) # notice how the number of points kept it steadily increasing compare to the previous example where it almost resets when a true change has been found
Run the code above in your browser using DataLab