home bbs files messages ]

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,913 of 57,431   
   Ben Bacarisse to Dmitry A. Kazakov   
   Re: Another little puzzle   
   09 Jan 23 03:25:10   
   
   From: ben.usenet@bsb.me.uk   
      
   "Dmitry A. Kazakov"  writes:   
      
   > On 2023-01-08 21:41, Ben Bacarisse wrote:   
   >   
   >> But   
   >> the problem is /finding/ a specific average -- the point (or angle) that   
   >> minimises the sum of squares of the distances (or angles) from that   
   >> average point (or angle).   
   >   
   > That is not a programming problem. It is a problem space's one. You   
   > must go to the corresponding part of science or engineering or   
   > economics etc and formulate it there in terms of that space.   
      
   I don't follow.  It's a mathematical problem for which an algorithm is   
   sought.  I don't see any connection to some science or engineering   
   space.  If it /came/ from some scientific study, it has already been   
   turned into what the programmer needs come up with.   
      
   > Average is just such formulation of finding a representative member   
   > from some set having some specific properties. E.g. least squares in   
   > physics usually has the meaning of least energy etc. So, it goes in   
   > this order (not in reverse):   
   >   
   > 1. You need the least energy representative.   
   > 2. An average gives you that.   
   > 3. You measure the inputs.   
   >   
   > After that you ask yourself given these measures how to compute the   
   > average? And only now it becomes a programming issue.   
      
   So if I asked you for code to calculate the arithmetic mean of an array   
   of numbers you would ask for all this first, declaring it not yet a   
   programming issue?  I really don't see where all this comes from.   
      
   >> The fact that it makes no odds (as everyone knows) whether we consider   
   >> angles (often called central angles in this context) or great circle   
   >> distances is not the issue.  It's finding the average that minimises the   
   >> sum of squares of differences that's the issue.   
   >   
   > Minimum of squares (Euclidean norm) is represented by the mathematical   
   > mean.   
      
   This problem obviously uses a different norm.   
      
   >> You say you need a formula, so I'll try...  Let P_n be a collection of n   
   >> unit vectors specifying n points on a unit sphere.  Find the unit vector   
   >> A that minimises   
   >>    Sum_{i=1,n} ( arctan( |A x P_n|  /  A . P_n ) )^2   
   >> (arctan is the "all quadrant" version that is often called atan2 in   
   >> programming languages.)   
   >   
   > 1. atan2 has two arguments (the adjacent and the opposite legs);   
      
   Obviously I can't guess how much I can safely assume so I expected there   
   might be questions.  arctan(p / q) is usually coded as atan2(p, q).   
      
   > 2. What is "A";   
      
   The unit vector that is being sought -- the result of the algorithm.  It   
   represents a point on the unit sphere that is the desired average of the   
   input points.   
      
   > 3. What operations(?) "x" and "." denote?   
      
   x denotes the cross product, and . the dot product.   
      
   Do you agree that this is not a trivial problem?  If not, please give   
   the trivial algorithm!   
      
   >>> Programs are written according to the specifications. Numeric programs   
   >>> require a properly stated problem, rather than a bunch of words   
   >>> arbitrarily thrown in a meaningless sentence as above.   
   >> Given the context, I think that's a very biased characterisation of   
   >> what's been said here.   
   >> My first job was as a "numerical analyst", and the very first program I   
   >> was employed to write was for a professor of statistics.  It was to   
   >> calculate a novel kind of fit line.  The specification was just a few   
   >> sentences.  No formulas.  It was perfectly clear, and I could get the   
   >> job done.  I don't think this is unusual.  Words are often enough, and   
   >> they can avoid undue over specification.  For example, the problem in   
   >> question is essentially the same if the points are given by latitude and   
   >> longitude on a non-unit sphere, but the formula would look very   
   >> different.   
   >   
   > This just means that you formulated the specifications yourself, being   
   > able to read your professor's mind.   
      
   No, I did not have to read his mind because he told me what he wanted.   
   To my mind "find the point on the sphere that minimises the sum of the   
   squares of the great-circle distances between that point and the input   
   points" is clearer than the formula I gave because the formula says too   
   much.   
      
   Of course, no specification is 100% precise.  You didn't know what x and   
   . denoted above and I have answered you with mere words.  Will you need   
   the formulas for X x Y and X . Y before accepting the specification?   
   What symbols in /those/ formulas might you want to have formally   
   specified?   
      
   > Not everybody's mind is easy read or worth reading... (:-))   
      
   --   
   Ben.   
      
   --- 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