Algorithm and code for segmenting sequential numerical data based on its characteristics.