Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.programming    |    Programming issues that transcend langua    |    57,431 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 56,791 of 57,431    |
|    Mike Terry to Dmitry A. Kazakov    |
|    Re: Another little puzzle    |
|    21 Dec 22 19:55:56    |
   
   From: news.dead.person.stones@darjeeling.plus.com   
      
   On 21/12/2022 17:55, Dmitry A. Kazakov wrote:   
   > On 2022-12-21 18:05, Ben Bacarisse wrote:   
   >   
   >> There is a   
   >> perfectly plausible interpretation of "average" that gives 0.5.   
   >   
   > Not very plausible as it violates two properties of:   
   >   
   > min({Xi}) <= avr({Xi}) <= max({Xi})   
   >   
   > and   
   >   
   > avr({C * Xi}) = C * avr({Xi})   
   >   
   > The second one allows calculation of the average as:   
   >   
   > 23.5 / 2 + 1.5 / 2 = ?   
   >   
      
   Dmitri: while I'm replying to /your/ post, my points are not especially   
   addressed to you - it's more   
   of an accumulation of "frustration" at what I consider to be "unimaginative"   
   misinterpretations and   
   dogmatic claims of what was originally requested... (I pretty much just chose   
   a recent post and   
   responded due to some internal threshold being reached! :) So don't be   
   personally offended!)   
      
   A lot of people here have treated the problem as saying "find the numeric   
   average of the number of   
   seconds past midnight for a given set of times". Well, clearly (to me) that   
   is NOT what the OP   
   intended, and I would say it's by no means the required meaning of the words   
   he actually used.   
      
   It was pretty clear to me that the intention was (somehow) to look at the   
   problem of averaging   
   values in some kind of modular setting, e.g. times given with a 24 hour   
   clock. Such times wrap at   
   midnight and common sense would say that we are to consider times a couple of   
   minutes apart as   
   "close" in this modular setting. I.e. 2 minutes to midnight and 2 minutes   
   past midnight should be   
   considered separated by 4 minutes, not 23 hours 56 minutes.   
      
   The OP was probably deliberately rather vague on this point! The easiest   
   definition for "average"   
   literally doesn't make sense in a modulo context: we can ADD the modular   
   values, but in general   
   dividing in such a mathematical setting doesn't make much sense, so   
      
    Average ([i=1,2,..n] x_i) =[def]= Sum ([i=1,2,..n] x_i) /n   
      
   would be inappropriate due to the /n operation.   
      
   HOWEVER, there's another characterisation for the average of a set, which   
   looks more promising in a   
   modular (or other more general) setting: the average is the value of V which   
   MINIMISES THE "ERROR"   
   calculated by   
      
    error = Sum ([i=1,2,..n] (V - x_i)^2)   
      
   that is, minimises the sum of squares of differences from V. [Incidentally,   
   if we minimise the sum   
   of absolute differeces from V, that characterises the mode (aka "midpoint") of   
   the sample, but I   
   think the median is more what is wanted here...]   
      
   So I'll suggest a precise wording of what was (I think) wanted: find the time   
   V that minimises the   
   error function above, based on "distances" in a modular setting. We also need   
   to make clear what   
   "distance" means in that setting, but put like that I think there would be   
   less disagreement that   
   the sensible way to define the distance between two times, would be in the   
   expected "wrapping"   
   manor. E.g. we could say the distance is the LEAST positive D such that V +-   
   D = x_i, with the   
   arithmetic + or - being modular arithmetic, i.e. mod 24hours. Obviously this   
   makes the distance   
   between 23:58 and 00:02 4 minutes, like we want...   
      
   Had the OP suggested that the times in question were EVENTS, then obviously   
   averaging the time for   
   them is a concretely defined operation, but to interpret the OP like that, we   
   would then need to   
   turn "times" into "event occurences date+times" and there was no mention of   
   dates anywhere - to me   
   it's clear the times are just intended as modular 24hour times, not applying   
   to specific events.   
      
   And for those that go further and suggest what was said was that the times   
   were all events occuring   
   on one and the same day, and that is what OP asked to be averaged - well! (I   
   don't think that is   
   reasonable at all, to put it mildly.)   
      
   Now, as to how to CALCULATE the V above???   
      
   [I haven't got a definitive approach - obviously we could calculate the normal   
   arithmetic "number of   
   seconds past midnight" average, then look at adjusting it as we flip various   
   x_i by 24hours, but   
   there could be a lot of x_i to flip (problem grows exponentially). Or maybe   
   we sample V at a fixed   
   number of places like on each hour, and (with luck) there may be an obvious   
   minimum - at that point   
   we could make a good guess for exactly which x_i should be "flipped" by   
   24hours, and then calculate   
   using normal arithmetic averaging??? Well that's my first idea.]   
      
   Regards,   
   Mike.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca