I have a huge list of times and would like to calculate an average or typical time. If I would just use the median (or other "normal" types of calculating an average), for example 23:59 and 00:01 would yield 12:00 when it should 00:00. Is there a better method?
2 Answers
I see two approaches for this. If there's some time of day when nothing happens, e.g. 4 a.m., you can let the wraparound occur at that time; for instance times from 1 a.m. to 4 a.m. would become times from 25:00 to 28:00.
If there's no such natural cutoff, you could use directional statistics; from the Wikipedia article:
Other examples of data that may be regarded as directional include statistics involving temporal periods (e.g. time of day, week, month, year, etc.), [...]
-
$\begingroup$ Unfortunately there is no such natural cutoff. However I'm interested in directional statistics. Do you know any starting ressources? $\endgroup$– NihuJan 3, 2012 at 12:27
-
1
-
$\begingroup$ Take a look at the answer I posted. I hope www.youtube.com/watch?v=cYVmcaRAbJg will be suitable as a starting resource. $\endgroup$– DruidAug 19, 2021 at 9:43
The variables you mention are points belonging to the manifold, which is the circle. Therefore, they cannot be treated as if they belonged to Euclidean space.
I recommend the material that I have prepared on this subject and today I am sharing it on YouTube: Circular means - Introduction to directional statistics.
There are two main types of circular mean: extrinsic and intrinsic.
Extrinsic mean is simply the mean calculated as the centroid of the points in the plane projected onto the circle. $$ \bar{\vec{x}}=\frac{1}{N}\sum_{j=1}^N \vec{x}_j=\frac{1}{N}\sum_{j=1}^N [x_j,y_j]=\frac{1}{N}\sum_{j=1}^N [\cos{\phi_j},\sin{\phi_j}] $$ $$ \hat{\bar{x}}=\frac{\bar{\vec{x}}}{|\bar{x}|} $$ $$ \DeclareMathOperator{\atantwo}{atan2} \bar{\phi}_{ex}=\atantwo(\hat{\bar{x}}) $$ It is NOT a mean calculated using the natural metric along the circle itself.
Intrinsic mean, on the other hand, does have this property. This mean can be obtained by minimizing the Fréchet function. $$ \DeclareMathOperator*{\argmin}{argmin} \bar{\phi}_{in}=\argmin_{\phi_0\in C} \sum_{j=1}^N (\phi_j-\phi_0)^2 $$
For discrete data, you can also analytically determine the $N$ points suspected of being the mean and then compare them using the Fréchet function.
$$ \bar{\phi}_k=\arg \sqrt[N]{\prod_{j=1}^N e^{i\phi_j} }=\bar{\phi}_0+k\frac{2\pi}{N} $$ Where the N-th root is a N-valued function with outputs indexed with $ k\in\{1,\dots,N\} $. They are distributed evenly on the circle. And $ \bar{\phi}_0 $ is a usual mean calculated in an arbitrary range of angle values of length of $2\pi$. If somebody dislikes the complex numbers $$ \bar{\phi}_k=\frac{1}{N} \left(\sum_{j=1}^N \phi_j+k2\pi\right) $$ The result is, of course, the same.
Then you have to compare the points suspected of being the mean using the Fréchet function. $$ \DeclareMathOperator*{\argmin}{argmin} \bar{\phi}_{in}=\argmin_{k\in\{1,\dots,N\}} \sum_{j=1}^N (\phi_j-\bar{\phi}_k)^2 $$ Where the search for minimum runs over $N$ discreet indices.
undefined
. However my data samples are rather huge so that would be rather unlikely. $\endgroup$