WP 34S linear regression bug


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)


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. ;-)



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.



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 ... ;-)


Edited: 12 May 2012, 2:28 p.m. after one or more responses were posted


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)


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. ;-)


We want to maintain compatibility with HP's scheme for this function to allow old program reuse.

- Pauli


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.



Hallo, Franz -

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). ;-)



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

Possibly Related Threads…
Thread Author Replies Views Last Post
  [WP-34S] Unfortunate key damage with update to V3 :( svisvanatha 5 3,207 12-10-2013, 11:37 PM
Last Post: Les Bell
  WP-34S (Emulator Program Load/Save) Barry Mead 1 1,809 12-09-2013, 05:29 PM
Last Post: Marcus von Cube, Germany
  DIY HP 30b WP 34s serial flash/programming cable Richard Wahl 2 2,537 12-04-2013, 11:14 AM
Last Post: Barry Mead
  HP prime: linear solver app Alberto Candel 1 1,444 11-21-2013, 01:57 AM
Last Post: Michael Carey
  HP Prime: Linear Solver app bug BruceH 0 1,154 11-15-2013, 06:36 PM
Last Post: BruceH
  WP 34S/43 ?'s Richard Berler 3 2,070 11-10-2013, 02:27 AM
Last Post: Walter B
  My FrankenCulator (wp-34s) FORTIN Pascal 4 2,172 11-09-2013, 06:18 PM
Last Post: FORTIN Pascal
  WP 34S Owner's Handbook Walter B 5 2,690 11-09-2013, 05:34 PM
Last Post: Harald
  wp 34s overlay and programming. FORTIN Pascal 6 2,914 11-08-2013, 01:28 PM
Last Post: Nick_S
  m.dy in display of WP-34S Harold A Climer 3 1,954 11-05-2013, 11:28 AM
Last Post: Andrew Nikitin

Forum Jump: