When averaging two times, yes, it's silly. But when averaging more than two, it comes out with a very different result.

... # your code thru the definition of sub circ_avg; print "@times"; print " => circle vs line"; print " => @{[angle2time circ_avg time2angle @times]} vs @{ +[angle2time( sum( time2angle @times ) / @times ) ]}"; for (; @times > 1; shift @times) { my @t = @times[0, 1]; print "@t => @{[angle2time circ_avg time2angle @t]} vs @{[angle2ti +me( sum( time2angle @t ) / @t ) ]}"; } __END__ __OUTPUT__ 17:00 19:00 11:00 13:00 23:00 01:00 10:30 13:00 19:40 01:20 16:00 02:0 +0 => circle vs line => 17:46 vs 12:12 17:00 19:00 => 18:00 vs 18:00 19:00 11:00 => 15:00 vs 15:00 11:00 13:00 => 12:00 vs 12:00 13:00 23:00 => 18:00 vs 18:00 23:00 01:00 => 00:00 vs 12:00 01:00 10:30 => 05:45 vs 05:45 10:30 13:00 => 11:45 vs 11:45 13:00 19:40 => 16:20 vs 16:20 19:40 01:20 => 22:30 vs 10:30 01:20 16:00 => 20:40 vs 08:40 16:00 02:00 => 21:00 vs 09:00

The pairs of times come out to a simple average that mostly matches the circles (except on the ones with midnight between time1 and time2); but you get very different results between the two averages for the entire list. Previously, I had compared my own implementation of the angular average (yours is better) to the results of salva's solution of finding the center-with-minimum-variance and found that the results for salva's example list (or a list of random times) gave very similar means to the angular average, which would be very different from the arithmetic mean for the same set of data


In reply to Re^3: Average start time handling midnight by pryrt
in thread Average start time handling midnight by chrisjej

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.