Wikipedia:Reference desk/Archives/Mathematics/2008 October 10

Source: Wikipedia, the free encyclopedia.
<
Mathematics
Mathematics desk
< October 9 << Sep | October | Nov >> October 11 >
Welcome to the Wikipedia Mathematics Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


October 10

The real deal with fitting lines to observed data points

I have a set of (x, y) data points with corresponding experimental uncertanties (dx, dy) which are different for the different points. I want to estimate the slope of the line that best approximates them. I want an estimation method with the following properties:

  1. It should take into account the errors in both x and y (unlike linear regression).
  2. It should be symmetric under the exchange of x and y (unlike linear regression).
  3. The method should be scale-invariant; that is, even if x and y have different units, the best-fit line should not change if they are measured in different scales (unlike total least squares).
  4. More accurate points (those with smaller uncertainties) should contribute more to the fit.

This doesn't seem like much to ask, but I can't find any method that actually satisfies these.

Something called "diagonal regression", "geometric mean functional relationship", "least areas line", "least products regression", "line of organic correlation", "neutral data fitting", or "reduced major axis" (do we have an article on it?) seems close, but I need a weighted version of it to satisfy the last criterion. —Keenan Pepper 06:54, 10 October 2008 (UTC)[reply]

I numbered your points. Point 3 is satified even by linear regression. To allow for point 2, try minimize Σzi2 where zi=f(xi,yi)=axi+byi+c and a2+b2=1. This is symmetrical in x and y. It provides the same result as linear regression, however, unless the line is vertical. Take account of point 1 = point 4 by minimizing a weighted sum Σaizi2 where ai is the weigth of the (xi,yi). Bo Jacoby (talk) 08:02, 10 October 2008 (UTC).[reply]

No no no. This clearly does not satisfy 3, because if x has units of length and y has units of time, then a must have units of 1/length and b must have units of 1/time to make the first equation dimensionally consistent. In the second equation, however, a2 and b2 are added together, so they should have the same units, which is a contradiction. Therefore your method is not dimensionally consistent, and if I change the scale of x or y, the best-fit line will change. Also, there must be some mistake when you say it's symmetrical, yet provides the same result as linear regression. The result given by linear regression is NOT symmetrical (i.e. the slope of y as a function of x and the slope of x as a function of y are NOT inverses), except in the special case when all the points lie exactly on a line already. —Keenan Pepper 15:11, 10 October 2008 (UTC)[reply]

Have you looked at
Errors-in-variables model? 155.91.45.231 (talk) 17:03, 10 October 2008 (UTC)[reply
]
Keenan Pepper may be right but I am not quite convinced. Do you have a simple example where 'the slope of y as a function of x and the slope of x as a function of y are NOT inverses' ? Bo Jacoby (talk) 23:20, 10 October 2008 (UTC).[reply]
{(0,0), (1,1), (1,0)}. If you apply linear regression, i.e. minimize:
or its inverse
Then the normal solution is y = 0.5*x, and the inverse solution is x = 0.5*y + 0.5. This is because this way of formulating the problem intrinsically treats uncertainty in x and y asymmetrically. Dragons flight (talk) 00:00, 11 October 2008 (UTC)[reply]
You can get a correct solution by minimzing the function:
You'll note that the goodness-of-fit function is dimensionless and changing the dimensions of x or y can always be exactly compensated by the corresponding dimensional changes in a and b. You can also show it works under x, y interchange by writing the inverse form and showing that identifying a' = 1/a and b' = -b/a restores the original fit function, exactly as using y = a x + b => x = a' y + b'. This is the form most often seen in research applications, and satisfies your conditions. You can also minimize the derivatives of to get algebraic solutions for a and b. Dragons flight (talk) 00:40, 11 October 2008 (UTC)[reply]
This is exactly what I'm looking for. Thanks, Dragons flight. I think this method is called element-wise weighted total least squares or EW-TLS. Does that sound right? —Keenan Pepper 01:19, 12 October 2008 (UTC)[reply]
Thank you. I stand corrected. Bo Jacoby (talk) 09:15, 11 October 2008 (UTC).[reply]

Use of atan2 in a maths article

Bit of a dispute I'd like some advice on I'd like to use atan2 as used in complex number#Conversion from the Cartesian form to the polar form in the form there in another article

In fact I wanted to have the multivaluedness explicit so I could refer to k by saying

And another editor undoes the edit saying atan2 is not mathematical saying

I understand quite well why the arctangent is not the correct function to use. However "atan2" is a not a commonly used mathematical function. I also know there are several computer programming languages that have this function in their library. Using atan2 in a math article is fully unnecessary and makes a strange impression. The intention of the angle is much clearer explained by defining it as one that together with the radius yields back the coordinates by the cosine and sine functions

and

I am not against mentioning the atan2 function as a way to calculate the angle, but it should not appear in the definition.

My main point is

The article is not solely for pure maths people, it is for a general audience including people who want to actually use the information. Defining a value by saying the conditions it must satisfy rather than giving a well defined function that just produces it is not very useful in applied mathematics.. And arg is not as well defined as atan2 as it could be multivalued or map to [0, 2π) even if the principle value is conventionally (-π,π].

What do you feel about using atan2 the way it is in the complex number article? Could you frame it differently to make it more mathematical and less programmerish?

Dmcq (talk) 22:44, 10 October 2008 (UTC)[reply
]

What the hell is atan2? Algebraist 22:47, 10 October 2008 (UTC)[reply]
atan2. My question is, why is this being asked here rather than at Talk:Complex number? siℓℓy rabbit (talk) 22:50, 10 October 2008 (UTC)[reply]
It has been used in the
Dmcq (talk) 23:00, 10 October 2008 (UTC)[reply
]
Another problem with the tan-1(y/x) is that it blows up if x is zero. Arg is formally undefined for z=0 but the conventional value is 0. atan2 just gives all the conventional values without the messing around.
Dmcq (talk) 23:06, 10 October 2008 (UTC)[reply
]
This should really be on
Wikipedia:Wikiproject Mathematics, but oh well... I would be against using atan2 in an article, since only programmers are going to have the faintest idea what you're talking about. Don't be afraid to use words when describing mathematics - just explain how to choose the appropriate quadrant in English. --Tango (talk) 23:08, 10 October 2008 (UTC)[reply
]
Sorry, will do that if I ever come across a problem like this again. I've been trying to think of a good way to frame it and I also worry about giving a rigmarole to people when most good calculators have the function on them.
Dmcq (talk) 23:25, 10 October 2008 (UTC)[reply
]
I just had a look via google and atan2 had more hits than atan, 12 mllion versus 7 million.
Dmcq (talk) 23:36, 10 October 2008 (UTC)[reply
]
So? Neither atan nor atan2 are common terms in mathematics. The common term is arctan, which has 25 million ghits. Algebraist 23:38, 10 October 2008 (UTC)[reply]
Re Dmcq: I'm not surprised about that; there's a reason atan2 is included in so many programming languages. But mathematicians by and large will never have heard of it. They will be familiar with the ordinary arctangent, which is a function of a single variable, not two.
The main concern for me isn't mathematicians, but high school students. Most of them will also not know about atan2, even if they have learned about arctangent in trigonometry class. But I had left the atan2 function in the complex number article when I edited it; I think I may be biased by already knowing what atan2 is. — Carl (
CBM · talk) 23:51, 10 October 2008 (UTC)[reply
]
My concern is people using tan-1(y/x). See for example this one I found on the first page with a google of 'polar form' at [1] where a science and engineering encyclopaedia encourages people to get it all wrong.
Dmcq (talk) 00:07, 11 October 2008 (UTC)[reply
]
Yes, that page is all bad. — Carl (
CBM · talk) 00:16, 11 October 2008 (UTC)[reply
]
Well, that is the correct formula, you just need to include details of how to choose between the multiple values it returns (and what to do if x=0). --Tango (talk) 00:25, 11 October 2008 (UTC)[reply]
I think of arctan as a normal, single-valued, function. There are other ways of defining the argument of a complex number than using arctan, and I expect that's how a lot of math texts do it. — Carl (
CBM · talk) 01:30, 11 October 2008 (UTC)[reply
]
The reasons programmers love atan2 is that it's so well behaved. According to the C manual page:
"The atan2() function calculates the arc tangent of the two variables x and y. It is similar to calculating the arc tangent of y / x, except that the signs of both arguments are used to determine the quadrant of the result."
Using a regular atan function produces all sorts of annoying practical nightmares. I can understand that mathematicians don't use it - but it's really their loss. It's a perfectly reasonable function - it's just a matter of history that it's not a part of the standard canon. SteveBaker (talk) 02:23, 11 October 2008 (UTC)[reply]
As a mathematician, I'd say we do use it, we just call it 'the principal value of the argument' and have it act on complex numbers rather than pairs of reals. Algebraist 07:32, 11 October 2008 (UTC)[reply]
True, but I'd been looking at
Dmcq (talk) 08:01, 11 October 2008 (UTC)[reply
]
Where I come from, arg and log are single-valued while Arg and Log are multi-valued. Are other practices in use? Algebraist 08:28, 11 October 2008 (UTC)[reply]
The
Dmcq (talk) 13:23, 11 October 2008 (UTC)[reply
]
My university uses Arg and Log for the principal values, arg and log for multi-valued. Eric. 131.215.159.187 (talk) 03:48, 12 October 2008 (UTC)[reply]