I am currently going over this paper, and in fact have already tried to implement it:
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4634483/ [1]
Paper looks at the amplitude of the step and the time between the swings. ALthough I seem to understand the general idea, I am slightly confused about one of the formulas, which describes time between steps, namely:
"To extract only one valley from a gathered group of valley candidates in a very short time range, every valley candidate is validated by checking the time distance to the recent valley using the following threshold.
$Th_v = \mu_v - (\sigma_v/\beta)$
where $\mu_v$ and $\sigma_v$ represent the average and the standard deviation of the time interval between adjacent valleys in the magnitude of acceleration, respectively. These averages and the standard deviations are calculated for recent M peaks or valleys."*
Except time threshold obviously magnitude is also taken into consideration.
So I have produced magnitudes that I obtain from my sensor: 
where red dots correspond to initially discovered valleys and purple to points that should re-evaluate last valley.
So what I currently have is something like this:
1) I obtain valley at point 20. I obtain valley at Point 49. This should mean that the average distance between two valleys is 29 readings, and therefore I set my $\mu_v = 29 and \sigma = 0$, which yields me a value of $Th_v=29$ ( my $\beta = 1/3$). I also store the difference (29).
2) Then I get to point 51, which should update the $Th_v$ value. So now I calculate the mean, which I think means $(29 + (51-49))/2 = 15.5$
And calculate standard deviation, which equals $19.09$. So then when I actually plug these values in the formula above I get $Th_v = -41.909$, which should not be possible as I believe this value should be always positive to indicate the time between two valleys.
Am I dong something incorrect or do you have any idea what's wrong with my or paper's approach?
References:
[1]: Lee H, Choi S, Lee M. Step Detection Robust against the Dynamics of Smartphones. Wang X, ed. Sensors (Basel, Switzerland). 2015;15(10):27230-27250. doi:10.3390/s151027230.