### Name: segment
### Title: Fit a piecewise constant curve: segmentation by dynamic
###   programming
### Aliases: segment
### Keywords: manip

### ** Examples

  x = rep( sin((0:4)/2*pi), each=3) + rnorm(3*5, sd=0.1)
  res = segment(x, maxseg=6, maxk=15)



