I have two animal running trajectories. A regular one with repeated back and forth running between point A and B, like the one on top in the figure. The other one is very irregular, animal paused and turned around a lot in the middle.  Is there any algorithm to measure the regularity of a trajectory, like repeated activity on the top?  And compare the extend of regularity between the two trajectories?  Thanks in advance. 
How to measure trajectory regularity?
algorithms
One possibility is measuring the change in slope at each point in the trajectory and then taking the average at the end. In the first one which you've described as regular the slope remains constant for a good part of it. That's not the case in the second one which is irregular.So at each point in the x-y trajectory find the change in slope and then take the average. At the end the a more regular trajectory will have an average change closer to 0 (because the animal walks in a straight line for a good part of it, so his slope is constant). Here is some example code.change_in_slope = 0.0for i in 2:no_points-1    change_in_slope += (y[i] - y[i-1])/(x[i] - x[i-1]) - (y[i+1] - y[i])/(x[i+1] - x[i])endchange_in_slope = change_in_slope / (no_points - 2)