How to measure trajectory regularity? 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. 

 A: I think you could measure the curvature of that curve $\gamma(t)$ with $t\in[0,1]$.
First you have to build the derivate (or gradient), by computing:
$$ \gamma'(t) = \left(\frac{\partial \gamma_1}{\partial t},\frac{\partial \gamma_2}{\partial t}\right)\approx\frac{\gamma(t+h)-\gamma(t)}{h}$$
Where you try to choose $h$ as small as possible.
Now you build the second derivative:
$$ \gamma''(t) \approx \frac{\gamma'(t+h)-\gamma'(t)}{h}$$
Now just integrate that thing:
$$ K=\int\limits_{\gamma(\mathbb{R})} \big\Vert\gamma''(t)\big\Vert\text{d}t = \int\limits_{\gamma(\mathbb{R})} \sqrt{\big(\gamma''_1(t)\big)^2+\big(\gamma''_2(t)\big)^2} \text{d} t \approx \sum_{t=0}^{\lfloor\frac{1}{h}\rfloor} \sqrt{\big(\gamma''_1(th)\big)^2+\big(\gamma''_2(th)\big)^2}$$
I think that $K$ will be big if the curve is bending a lot! A straight line for instance has $K=0$. A circle will have bendiness 1.
Edit:
As pointed out your need to "walk" the curve by constant speed (if you intend to measure the curve out of a geometrical aspect), hence:
$$\forall t\in[0,1]\quad\quad\big\Vert \gamma'(t)\big\Vert = c\in\mathbb{R}$$
This is done by inverting $s(t):=\Vert\gamma'(t)\Vert$ than you get the desired curve $\widetilde{\gamma}(l) := \gamma(s^{-1}(l))$ for $l\in[0,s(1)]$.
Algorithm:
The following code is in python with a simple vector type, so I hope it's readable enought. Given a path by a set of points P with n=len(P) you could do:
v = (P[0]-P[1])/h
k = 0
for i in range(1,n-1):
    p = P[i]
    q = P[i+1]
    w = (p-q)/h
    k += abs((v-w)/h)
    v = w

The variable k is $K$. If you want to take speed differences out of the computation as pointed out by LucasVB, just normalize v,w like this k+=abs((v/abs(v)-w/abs(w))/h). I think it is possible to add some more precision by using more complex numerical analysis, but this is hopefully something that gets you started.
