Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #16136

Re: Another little puzzle

From Richard Heathfield <rjh@cpax.org.uk>
Newsgroups comp.programming
Subject Re: Another little puzzle
Date 2022-12-24 17:14 +0000
Organization Fix this later
Message-ID <to7c29$2avch$1@dont-email.me> (permalink)
References (1 earlier) <algorithm-20221221130021@ram.dialup.fu-berlin.de> <86pmcczcak.fsf@linuxsc.com> <87wn6krsc5.fsf@bsb.me.uk> <868riwzxu3.fsf@linuxsc.com> <to7ar5$aqn$1@gioia.aioe.org>

Show all headers | View raw


On 24/12/2022 4:53 pm, Mike Terry wrote:
> On 24/12/2022 14:21, Tim Rentsch wrote:
>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>> 
>>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>> 
>>>> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>>>> 
>>>>> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>>>>> 
>>>>>> Given n times of the 24-hour day, print their
>>>>>> average. For example, the average of "eight o'clock"
>>>>>> and "ten o'clock" (n=2) would be "nine o'clock". 
>>>>>> (You can choose any representation, for example
>>>>>> "HH:MM" or "seconds since midnight".)
>>>>> 
>>>>> Thanks for all replies!
>>>>> 
>>>>> I waited a few days before answering to allow 
>>>>> sufficient time to think about the problem.
>>>>> 
>>>>> There were not enough tests written and run.  As a
>>>>> result, the puzzle has not yet been solved (unless I
>>>>> have overlooked a contribution or misworded
>>>>> expectations).
>>>>> 
>>>>> So, here are two possible test cases.
>>>>> 
>>>>> average( 23.5,  1.5 )==  0.5 average( 11.5, 13.5 )==
>>>>> 12.5
>>>>> 
>>>>> (I use hours as units, so "0.5" means, "half past 
>>>>> midnight".)
>>>>> 
>>>>> I hope that these test cases encode sensible
>>>>> expectations for an average of two times on a 24-hour
>>>>> clock in the spirit of the example given in the OP,
>>>>> which was, "the average of eight o'clock and ten
>>>>> o'clock would be nine o'clock", since these test cases
>>>>> just have rotated that example by 3.5 and 15.5 hours.
>>>>> 
>>>>> I believe that I have not seen an algorithm so far in
>>>>> this thread that would pass these tests.
>>>> 
>>>> As before, the problem is underspecified.
>>> 
>>> Some remarks not specifically in reply to you, Tim...
>> 
>> I didn't really say very much.  Your comments are a lot
>> more interesting.
>> 
>>> The input is a collection, t(n), of n > 1 numbers in [0,
>>> 24). The average should be a number, A, in [0, 24) that
>>> minimises
>>> 
>>> Sum_{i=1,n} distance(A, t(i))
>>> 
>>> (or Sum_{i=1,n} difference(A, t(i))^2 if you prefer to
>>> think in terms of variance).  So far, this is just what an
>>> average is.  The key point is what is the distance (or
>>> difference) whose sum (or sum of squares) we want to
>>> minimise?  For times, I would say it is the length of the 
>>> shorter arc round an imaginary 24-hour clock face.
>> 
>> Minimizing the square of the distance (aka length of the 
>> shorter arc) is one metric, and I think a reasonable one.
>> (Minimizing the absolute value of the distance gives a
>> result more like the median than the mean, IIANM.)
> 
> Yes - perhaps Ben was thinking of making
> 
> Sum_{i=1,n} signed_distance(A, t(i))  =  0
> 
> rather than minimising the (absolute) distance.

And so perhaps you are closer to what Ben was thinking of, but as
far as we know you are no closer to knowing what Stefan was
thinking of.

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

Back to comp.programming | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: Another little puzzle Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-12-21 13:17 -0800
  Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-22 04:10 +0000
    Re: Another little puzzle Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-12-24 06:21 -0800
      Re: Another little puzzle Mike Terry <news.dead.person.stones@darjeeling.plus.com> - 2022-12-24 16:53 +0000
        Re: Another little puzzle Richard Heathfield <rjh@cpax.org.uk> - 2022-12-24 17:14 +0000
        Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-24 22:30 +0000
          Re: Another little puzzle Mike Terry <news.dead.person.stones@darjeeling.plus.com> - 2022-12-25 00:02 +0000
            Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-25 01:30 +0000
            Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-25 01:55 +0000
        Re: Another little puzzle Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-12-25 00:37 -0800
      Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-25 00:41 +0000
        Re: Another little puzzle Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-12-25 01:05 -0800
          Re: Another little puzzle Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-12-25 09:30 -0800
          Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-25 21:44 +0000
            Re: Another little puzzle Richard Damon <Richard@Damon-Family.org> - 2022-12-25 17:59 -0500
              Re: Another little puzzle Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-12-25 18:39 -0800
              Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-26 03:18 +0000
            Re: Another little puzzle Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-12-25 18:35 -0800
              Re: Another little puzzle Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-12-26 03:49 +0000

csiph-web