Turning point test of randomness (source code)

= Turning point test of randomness
{title2=$E[P_T]=2(T-2)/3,\quad\operatorname{Var}(P_T)=(16T-29)/90$}

For independent identically distributed continuous observations, count strict local maxima and minima at interior positions. Each turning indicator has probability $2/3$, adjacent indicators have joint probability $5/12$, indicators two positions apart have joint probability $9/20$, and more distant indicators are independent. Summing these covariances gives the displayed variance for $T\ge4$. The indicators form a bounded 2-dependent sequence, giving an asymptotically normal standardized count. Too few turns suggests persistent trends; too many suggests alternation. Ties and dependent observations require a different calibration.