Stats resid() does not work for median-median
11-12-2015, 01:37 AM
Post: #1
 mkokot Junior Member Posts: 2 Joined: Sep 2014
Stats resid() does not work for median-median
In the process of helping my daughter with her Advance Algebra course we found that the Resid() function does not work with the Statistics 2Var App when Median-Median is the method used. We get "Error: Invalid input" when entering Resid(S1).

This works just fine when using the Linear mode or other types.

I am using the latest firmware of rev: 8151.

After researching this more it would appear the median-median mode in Statistics 2Var app was something just recently added and it has not fully been integrated in with the rest of the stats functions and resid is not the only function that does not work with this mode. The median-median line method of solving a set of points seems to be popular with high school algebra texts books so I took the time to write this simple little program to resolve this. Maybe in the near future a new firmware will fix this but until then here is a simple way to work around this. I also create a spread sheet with results, but it is to ugly to share. I will paste the code for residmed() below.

To use this properly first go into your Statistics 2Var App and enter your x & y values and generate the y=mx+b formula for a Median-Median line. Place your cursor in the Fit1 field and copy the formula generated when using the Type1: Median-Median. To copy use the Shift/Copy keys. Next go to your home key and on the line type "residmed(" here paste back your formula but replace the "*x" with a "," to pass the function the slope and the y intercept values to this new program I created called residmed(). Then close the function call with a ")"

So it will look something like this "residmed(.025, 3)". This function then returns a list of residuals based on the x & y values you intered in the Stats 2Var App. If you wanted the sum of all the residuals you would type something like this. -> sum(residmed(.025, 3))

Here is the simple code from the program residmed().

//sl Passed in slope value
//yin Passed in y intercept
EXPORT residmed(sl,yin)
BEGIN

local n;

L1 :={}; // list of X values
L2 :={}; // list of Y values
L3 :={}; // list of residuals

//Get list of X values from Stats 2Var app
L1 := Statistics_2Var.C1;

//Get list of Y values from Stats 2Var app
L2 := Statistics_2Var.C2;

// Compute list of y^ and build list of residuals
n:=1;
while (n <= Statistics_2Var.NbItem) do
L3(n) := L2(n) - ((L1(n)*sl) +yin);
n:= n+1;
end;

return L3;

END;

I noticed this thread below seems to reference the same issue.
11-12-2015, 02:09 AM
Post: #2
 Tim Wessman Senior Member Posts: 2,225 Joined: Dec 2013
RE: Stats resid() does not work for median-median
Thanks. It's on the list to investigate. Most likely is a simple "off by 1" with the types internally or something (since was recently added as you said).

TW

Although I work for the HP calculator group, the views and opinions I post here are my own.
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)