Path: csiph.com!aioe.org!kK2lsnT783pDKEeO3mVMeA.user.46.165.242.91.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.programming Subject: Re: Another little puzzle Date: Sun, 8 Jan 2023 22:31:21 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <87tu1diu2s.fsf@bsb.me.uk> <864jtdtkt5.fsf@linuxsc.com> <87o7rlhtsv.fsf@bsb.me.uk> <878rioifnh.fsf@bsb.me.uk> <868rinskhk.fsf@linuxsc.com> <868ridni7g.fsf@linuxsc.com> <877cxwwyhc.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: gioia.aioe.org; logging-data="56101"; posting-host="kK2lsnT783pDKEeO3mVMeA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: csiph.com comp.programming:16274 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. 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. > 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. > 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); 2. What is "A"; 3. What operations(?) "x" and "." denote? >> 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. Not everybody's mind is easy read or worth reading... (:-)) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de