WP 34S linear regression bug - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: WP 34S linear regression bug (/thread-221018.html) WP 34S linear regression bug - Nigel J Dowrick - 05-12-2012 The WP 34S (VERS returning 3018, and also build 2935) seems to return incorrect values for slope and intercept when doing linear regression calculations. To see this, clear the stats registers, then enter (1,1), (2,4), (3,6), and (4,8) using sigma+. Executing L.R. returns strange numbers for slope and intercept; using y-hat also gives incorrect answers. Incidentally, congratulations on passing build 3000! I hope that the end is now in sight... Nigel (UK) Re: WP 34S linear regression bug - fhub - 05-12-2012 Hi Nigel, I've just tried your dataset (with the same build as you) and I get -1 and 2.3 as results - looks quite ok for me. I could imagine a few possible sources for your problem: 1) maybe you wanted (1,2) as first point instead of (1,1), because then all 4 points would give a straight line and the L.R. result would be 0 and 2 (maybe this is what you expected when you say "strange numbers"?) 2) have you cleared the stat-regs before? 3) have you set the correct regression 'LinF' mode in [h]MODE ? (but you would certainly have found this problem yourself, because the current mode is displayed in the alpha-register) 4) maybe you entered x ENTER y instead of y ENTER x ? (I always use x ENTER y x<>y for such functions that need a (x,y)-pair as argument, like e.g. complex numbers) 5) finally maybe the old RPN vs. RPL problem, i.e. did you enter y ENTER x ENTER SIGMA+ ? (the 2nd ENTER would be the problem here) I hope you find the reason for your "strange result" in this list. ;-) Franz Re: WP 34S linear regression bug - Dieter - 05-12-2012 Nigel, these "strange numbers" do not happen to be 0,458 and 0,43, do they ?-) I am almost certain you simply entered your data the wrong way round: x-value ENTER y-value. This is a common error - that way the y-value is stored in X and the x-value in Y. If you do it right you should get -1 (intercept) returned in X and 2,3 (slope) in Y. Dieter Re: WP 34S linear regression bug - fhub - 05-12-2012 A short remark for the WP34s team about this L.R. function: I've used this the first time today and I really wondered about the order how the results were returned. IMO it would be better to swap both returned values, i.e. come back with the y-interception in Y and the slope in X. Firstly it's rather usual to write a linear function as y=k*x+d (or c1*x+c0), so the slope k (or c1) comes first in this equation, and furthermore it would better fit to their meanings: the slope is the factor for x and the interception is with the y-axis. And one more advantage: with swapped values you could just enter any x-value and press * and + to get the estimated y-value. (I know, for more x-values there's a function y-hat ...) Just my 2 cents ... ;-) Franz Edited: 12 May 2012, 2:28 p.m. after one or more responses were posted Re: WP 34S linear regression bug - Nigel J Dowrick - 05-12-2012 I withdraw the bug report! That will teach me to post bug reports without question marks in the title. All works fine, now. I'm still not sure what the problem was - I was already aware of the need to reverse x and y, so probably I simply didn't clear the statistics registers first. Sorry! Thank you both very much for your helpful comments. Nigel (UK) Re: WP 34S linear regression bug - Marcus von Cube, Germany - 05-12-2012 Nigel, if you ever find something like a 12 digit number with a 3 digit negative exponent instead of a small integer than the reason might be some memory corruption and we are happy to fix any issue. In the past there were such problems and we fixed them when we were pointed to them by our testers in the wild. ;-) Re: WP 34S linear regression bug - Paul Dale - 05-12-2012 We want to maintain compatibility with HP's scheme for this function to allow old program reuse. - Pauli Re: WP 34S linear regression bug - Paul Dale - 05-12-2012 Quote:Incidentally, congratulations on passing build 3000! I hope that the end is now in sight... I hope so. We have discussed a feature freeze last week -- then the user catalogue popped up overnight :-) - Pauli Re: WP 34S linear regression bug - fhub - 05-12-2012 Quote: We want to maintain compatibility with HP's scheme for this function to allow old program reuse. Ok, that's of course an important argument - I didn't know that HP used to return those 2 values in this (for me unusual) order in their other calculators. Franz Re: WP 34S linear regression bug - Dieter - 05-12-2012 Hallo, Franz - Quote: Firstly it's rather usual to write a linear function as y=k*x+d (or c1*x+c0) Is it? I'd say that depends on the book you read. In general, a simple linear regression is just a special case of a multiple linear regression with several independent variables. Where the usual notation is ``` y = a0 + a1*x1 + a2*x2 + a3*x3 + ... + an*xn ``` At least in my books. But even Wikipedia writes it this way, both in German and in English. Even Austria (university of Innsbruck) seems to agree (cf. this PDF). ;-) Dieter