[Maxima-commits] CVS: maxima/doc/info lsquares.texi,1.3,1.4

 [Maxima-commits] CVS: maxima/doc/info lsquares.texi,1.3,1.4 From: Robert Dodier - 2007-07-30 04:31:57 ```Update of /cvsroot/maxima/maxima/doc/info In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13381/doc/info Modified Files: lsquares.texi Log Message: Change convention for residuals to lhs minus rhs (was rhs minus lhs). New convention is consistent with definition of error as y = foo(x) + error which is typical in statistics texts. Code, tests, and documentation all changed. Index: lsquares.texi =================================================================== RCS file: /cvsroot/maxima/maxima/doc/info/lsquares.texi,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- lsquares.texi 30 Jul 2007 02:57:52 -0000 1.3 +++ lsquares.texi 30 Jul 2007 04:31:53 -0000 1.4 @@ -61,7 +61,6 @@ @c ===end=== @example (%i1) load (lsquares)\$ - (%i2) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); [ 1 1 1 ] [ ] @@ -92,7 +91,6 @@ @c ===end=== @example (%i1) load (lsquares)\$ - (%i2) M : matrix ([1, 1], [2, 7/4], [3, 11/4], [4, 13/4]); [ 1 1 ] [ ] @@ -108,8 +106,8 @@ [ 4 -- ] [ 4 ] (%i3) lsquares_estimates (M, [x, y], y = a*x^b + c, [a, b, c], initial = [3, 3, 3], iprint = [-1, 0]); -(%o3) [[a = 1.387365874920629, b = 0.71109566395938, - c = - 0.4142705622439]] +(%o3) [[a = 1.387365874920637, b = .7110956639593767, + c = - .4142705622439105]] @end example @end deffn @@ -143,7 +141,6 @@ @c ===end=== @example (%i1) load (lsquares)\$ - (%i2) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); [ 1 1 1 ] [ ] @@ -159,14 +156,14 @@ [ ] [ 2 2 1 ] (%i3) mse : lsquares_mse (M, [z, x, y], (z + D)^2 = A*x + B*y + C); - 5 - ==== - \ 2 2 - > (- (D + M ) + C + M B + M A) - / i, 1 i, 3 i, 2 - ==== - i = 1 -(%o3) ----------------------------------------------- + 5 + ==== + \ 2 2 + > ((D + M ) - C - M B - M A) + / i, 1 i, 3 i, 2 + ==== + i = 1 +(%o3) --------------------------------------------- 5 (%i4) lsquares_estimates_exact (mse, [A, B, C, D]); 59 27 10921 107 @@ -218,7 +215,6 @@ @c ===end=== @example (%i1) load (lsquares)\$ - (%i2) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); [ 1 1 1 ] [ ] @@ -234,14 +230,14 @@ [ ] [ 2 2 1 ] (%i3) mse : lsquares_mse (M, [z, x, y], (z + D)^2 = A*x + B*y + C); - 5 - ==== - \ 2 2 - > (- (D + M ) + C + M B + M A) - / i, 1 i, 3 i, 2 - ==== - i = 1 -(%o3) ----------------------------------------------- + 5 + ==== + \ 2 2 + > ((D + M ) - C - M B - M A) + / i, 1 i, 3 i, 2 + ==== + i = 1 +(%o3) --------------------------------------------- 5 (%i4) lsquares_estimates_approximate (mse, [A, B, C, D], iprint = [-1, 0]); (%o4) [[A = - 3.67850494740174, B = - 1.683070351177813, @@ -261,7 +257,7 @@ n ==== \ 2 - > (rhs(e ) - lhs(e )) + > (lhs(e ) - rhs(e )) / i i ==== i = 1 @@ -284,50 +280,50 @@ @c ''mse, nouns; @c ===end=== @example -(%i1) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); +(%i1) load (lsquares)\$ +(%i2) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); [ 1 1 1 ] [ ] [ 3 ] [ - 1 2 ] [ 2 ] [ ] -(%o1) [ 9 ] +(%o2) [ 9 ] [ - 2 1 ] [ 4 ] [ ] [ 3 2 2 ] [ ] [ 2 2 1 ] -(%i2) mse : lsquares_mse (M, [z, x, y], (z + D)^2 = A*x + B*y + C); - 5 - ==== - \ 2 2 - > (- (D + M ) + C + M B + M A) - / i, 1 i, 3 i, 2 - ==== - i = 1 -(%o2) ----------------------------------------------- +(%i3) mse : lsquares_mse (M, [z, x, y], (z + D)^2 = A*x + B*y + C); + 5 + ==== + \ 2 2 + > ((D + M ) - C - M B - M A) + / i, 1 i, 3 i, 2 + ==== + i = 1 +(%o3) --------------------------------------------- 5 -(%i3) diff (mse, D); -(%o3) - 5 - ==== - \ 2 - 4 > (D + M ) (- (D + M ) + C + M B + M A) - / i, 1 i, 1 i, 3 i, 2 - ==== - i = 1 - - ------------------------------------------------------------ +(%i4) diff (mse, D); + 5 + ==== + \ 2 + 4 > (D + M ) ((D + M ) - C - M B - M A) + / i, 1 i, 1 i, 3 i, 2 + ==== + i = 1 +(%o4) ---------------------------------------------------------- 5 -(%i4) ''mse, nouns; - 2 2 -(%o4) ((- (D + 3) + C + 2 B + 2 A) - 9 2 2 2 2 - + (- (D + -) + C + B + 2 A) + (- (D + 2) + C + B + 2 A) - 4 - 3 2 2 2 2 - + (- (D + -) + C + 2 B + A) + (- (D + 1) + C + B + A) )/5 - 2 +(%i5) ''mse, nouns; + 2 2 9 2 2 +(%o5) (((D + 3) - C - 2 B - 2 A) + ((D + -) - C - B - 2 A) + 4 + 2 2 3 2 2 + + ((D + 2) - C - B - 2 A) + ((D + -) - C - 2 B - A) + 2 + 2 2 + + ((D + 1) - C - B - A) )/5 @end example @end deffn @@ -345,7 +341,7 @@ The residuals are defined as: @example - rhs(e ) - lhs(e ) + lhs(e ) - rhs(e ) i i @end example @@ -364,28 +360,29 @@ @c lsquares_residuals (M, [z, x, y], (z + D)^2 = A*x + B*y + C, first (a)); @c ===end=== @example -(%i1) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); +(%i1) load (lsquares)\$ +(%i2) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); [ 1 1 1 ] [ ] [ 3 ] [ - 1 2 ] [ 2 ] [ ] -(%o1) [ 9 ] +(%o2) [ 9 ] [ - 2 1 ] [ 4 ] [ ] [ 3 2 2 ] [ ] [ 2 2 1 ] -(%i2) a : lsquares_estimates (M, [z, x, y], (z + D)^2 = A*x + B*y + C, [A, B, C, D]); +(%i3) a : lsquares_estimates (M, [z, x, y], (z + D)^2 = A*x + B*y + C, [A, B, C, D]); 59 27 10921 107 -(%o2) [[A = - --, B = - --, C = -----, D = - ---]] +(%o3) [[A = - --, B = - --, C = -----, D = - ---]] 16 16 1024 32 -(%i3) lsquares_residuals (M, [z, x, y], (z + D)^2 = A*x + B*y + C, first (a)); - 13 13 13 13 13 -(%o3) [- --, --, --, - --, - --] - 64 64 32 64 64 +(%i4) lsquares_residuals (M, [z, x, y], (z + D)^2 = A*x + B*y + C, first (a)); + 13 13 13 13 13 +(%o4) [--, - --, - --, --, --] + 64 64 32 64 64 @end example @end deffn @@ -401,7 +398,7 @@ n ==== \ 2 - > (rhs(e ) - lhs(e )) + > (lhs(e ) - rhs(e )) / i i ==== i = 1 @@ -424,27 +421,28 @@ @c lsquares_residual_mse (M, [z, x, y], (z + D)^2 = A*x + B*y + C, first (a)); @c ===end=== @example -(%i1) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); +(%i1) load (lsquares)\$ +(%i2) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); [ 1 1 1 ] [ ] [ 3 ] [ - 1 2 ] [ 2 ] [ ] -(%o1) [ 9 ] +(%o2) [ 9 ] [ - 2 1 ] [ 4 ] [ ] [ 3 2 2 ] [ ] [ 2 2 1 ] -(%i2) a : lsquares_estimates (M, [z, x, y], (z + D)^2 = A*x + B*y + C, [A, B, C, D]); +(%i3) a : lsquares_estimates (M, [z, x, y], (z + D)^2 = A*x + B*y + C, [A, B, C, D]); 59 27 10921 107 -(%o2) [[A = - --, B = - --, C = -----, D = - ---]] +(%o3) [[A = - --, B = - --, C = -----, D = - ---]] 16 16 1024 32 -(%i3) lsquares_residual_mse (M, [z, x, y], (z + D)^2 = A*x + B*y + C, first (a)); +(%i4) lsquares_residual_mse (M, [z, x, y], (z + D)^2 = A*x + B*y + C, first (a)); 169 -(%o3) ---- +(%o4) ---- 2560 @end example ```

 [Maxima-commits] CVS: maxima/doc/info lsquares.texi,1.3,1.4 From: Robert Dodier - 2007-07-30 04:31:57 ```Update of /cvsroot/maxima/maxima/doc/info In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13381/doc/info Modified Files: lsquares.texi Log Message: Change convention for residuals to lhs minus rhs (was rhs minus lhs). New convention is consistent with definition of error as y = foo(x) + error which is typical in statistics texts. Code, tests, and documentation all changed. Index: lsquares.texi =================================================================== RCS file: /cvsroot/maxima/maxima/doc/info/lsquares.texi,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- lsquares.texi 30 Jul 2007 02:57:52 -0000 1.3 +++ lsquares.texi 30 Jul 2007 04:31:53 -0000 1.4 @@ -61,7 +61,6 @@ @c ===end=== @example (%i1) load (lsquares)\$ - (%i2) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); [ 1 1 1 ] [ ] @@ -92,7 +91,6 @@ @c ===end=== @example (%i1) load (lsquares)\$ - (%i2) M : matrix ([1, 1], [2, 7/4], [3, 11/4], [4, 13/4]); [ 1 1 ] [ ] @@ -108,8 +106,8 @@ [ 4 -- ] [ 4 ] (%i3) lsquares_estimates (M, [x, y], y = a*x^b + c, [a, b, c], initial = [3, 3, 3], iprint = [-1, 0]); -(%o3) [[a = 1.387365874920629, b = 0.71109566395938, - c = - 0.4142705622439]] +(%o3) [[a = 1.387365874920637, b = .7110956639593767, + c = - .4142705622439105]] @end example @end deffn @@ -143,7 +141,6 @@ @c ===end=== @example (%i1) load (lsquares)\$ - (%i2) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); [ 1 1 1 ] [ ] @@ -159,14 +156,14 @@ [ ] [ 2 2 1 ] (%i3) mse : lsquares_mse (M, [z, x, y], (z + D)^2 = A*x + B*y + C); - 5 - ==== - \ 2 2 - > (- (D + M ) + C + M B + M A) - / i, 1 i, 3 i, 2 - ==== - i = 1 -(%o3) ----------------------------------------------- + 5 + ==== + \ 2 2 + > ((D + M ) - C - M B - M A) + / i, 1 i, 3 i, 2 + ==== + i = 1 +(%o3) --------------------------------------------- 5 (%i4) lsquares_estimates_exact (mse, [A, B, C, D]); 59 27 10921 107 @@ -218,7 +215,6 @@ @c ===end=== @example (%i1) load (lsquares)\$ - (%i2) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); [ 1 1 1 ] [ ] @@ -234,14 +230,14 @@ [ ] [ 2 2 1 ] (%i3) mse : lsquares_mse (M, [z, x, y], (z + D)^2 = A*x + B*y + C); - 5 - ==== - \ 2 2 - > (- (D + M ) + C + M B + M A) - / i, 1 i, 3 i, 2 - ==== - i = 1 -(%o3) ----------------------------------------------- + 5 + ==== + \ 2 2 + > ((D + M ) - C - M B - M A) + / i, 1 i, 3 i, 2 + ==== + i = 1 +(%o3) --------------------------------------------- 5 (%i4) lsquares_estimates_approximate (mse, [A, B, C, D], iprint = [-1, 0]); (%o4) [[A = - 3.67850494740174, B = - 1.683070351177813, @@ -261,7 +257,7 @@ n ==== \ 2 - > (rhs(e ) - lhs(e )) + > (lhs(e ) - rhs(e )) / i i ==== i = 1 @@ -284,50 +280,50 @@ @c ''mse, nouns; @c ===end=== @example -(%i1) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); +(%i1) load (lsquares)\$ +(%i2) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); [ 1 1 1 ] [ ] [ 3 ] [ - 1 2 ] [ 2 ] [ ] -(%o1) [ 9 ] +(%o2) [ 9 ] [ - 2 1 ] [ 4 ] [ ] [ 3 2 2 ] [ ] [ 2 2 1 ] -(%i2) mse : lsquares_mse (M, [z, x, y], (z + D)^2 = A*x + B*y + C); - 5 - ==== - \ 2 2 - > (- (D + M ) + C + M B + M A) - / i, 1 i, 3 i, 2 - ==== - i = 1 -(%o2) ----------------------------------------------- +(%i3) mse : lsquares_mse (M, [z, x, y], (z + D)^2 = A*x + B*y + C); + 5 + ==== + \ 2 2 + > ((D + M ) - C - M B - M A) + / i, 1 i, 3 i, 2 + ==== + i = 1 +(%o3) --------------------------------------------- 5 -(%i3) diff (mse, D); -(%o3) - 5 - ==== - \ 2 - 4 > (D + M ) (- (D + M ) + C + M B + M A) - / i, 1 i, 1 i, 3 i, 2 - ==== - i = 1 - - ------------------------------------------------------------ +(%i4) diff (mse, D); + 5 + ==== + \ 2 + 4 > (D + M ) ((D + M ) - C - M B - M A) + / i, 1 i, 1 i, 3 i, 2 + ==== + i = 1 +(%o4) ---------------------------------------------------------- 5 -(%i4) ''mse, nouns; - 2 2 -(%o4) ((- (D + 3) + C + 2 B + 2 A) - 9 2 2 2 2 - + (- (D + -) + C + B + 2 A) + (- (D + 2) + C + B + 2 A) - 4 - 3 2 2 2 2 - + (- (D + -) + C + 2 B + A) + (- (D + 1) + C + B + A) )/5 - 2 +(%i5) ''mse, nouns; + 2 2 9 2 2 +(%o5) (((D + 3) - C - 2 B - 2 A) + ((D + -) - C - B - 2 A) + 4 + 2 2 3 2 2 + + ((D + 2) - C - B - 2 A) + ((D + -) - C - 2 B - A) + 2 + 2 2 + + ((D + 1) - C - B - A) )/5 @end example @end deffn @@ -345,7 +341,7 @@ The residuals are defined as: @example - rhs(e ) - lhs(e ) + lhs(e ) - rhs(e ) i i @end example @@ -364,28 +360,29 @@ @c lsquares_residuals (M, [z, x, y], (z + D)^2 = A*x + B*y + C, first (a)); @c ===end=== @example -(%i1) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); +(%i1) load (lsquares)\$ +(%i2) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); [ 1 1 1 ] [ ] [ 3 ] [ - 1 2 ] [ 2 ] [ ] -(%o1) [ 9 ] +(%o2) [ 9 ] [ - 2 1 ] [ 4 ] [ ] [ 3 2 2 ] [ ] [ 2 2 1 ] -(%i2) a : lsquares_estimates (M, [z, x, y], (z + D)^2 = A*x + B*y + C, [A, B, C, D]); +(%i3) a : lsquares_estimates (M, [z, x, y], (z + D)^2 = A*x + B*y + C, [A, B, C, D]); 59 27 10921 107 -(%o2) [[A = - --, B = - --, C = -----, D = - ---]] +(%o3) [[A = - --, B = - --, C = -----, D = - ---]] 16 16 1024 32 -(%i3) lsquares_residuals (M, [z, x, y], (z + D)^2 = A*x + B*y + C, first (a)); - 13 13 13 13 13 -(%o3) [- --, --, --, - --, - --] - 64 64 32 64 64 +(%i4) lsquares_residuals (M, [z, x, y], (z + D)^2 = A*x + B*y + C, first (a)); + 13 13 13 13 13 +(%o4) [--, - --, - --, --, --] + 64 64 32 64 64 @end example @end deffn @@ -401,7 +398,7 @@ n ==== \ 2 - > (rhs(e ) - lhs(e )) + > (lhs(e ) - rhs(e )) / i i ==== i = 1 @@ -424,27 +421,28 @@ @c lsquares_residual_mse (M, [z, x, y], (z + D)^2 = A*x + B*y + C, first (a)); @c ===end=== @example -(%i1) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); +(%i1) load (lsquares)\$ +(%i2) M : matrix ([1, 1, 1], [3/2, 1, 2], [9/4, 2, 1], [3, 2, 2], [2, 2, 1]); [ 1 1 1 ] [ ] [ 3 ] [ - 1 2 ] [ 2 ] [ ] -(%o1) [ 9 ] +(%o2) [ 9 ] [ - 2 1 ] [ 4 ] [ ] [ 3 2 2 ] [ ] [ 2 2 1 ] -(%i2) a : lsquares_estimates (M, [z, x, y], (z + D)^2 = A*x + B*y + C, [A, B, C, D]); +(%i3) a : lsquares_estimates (M, [z, x, y], (z + D)^2 = A*x + B*y + C, [A, B, C, D]); 59 27 10921 107 -(%o2) [[A = - --, B = - --, C = -----, D = - ---]] +(%o3) [[A = - --, B = - --, C = -----, D = - ---]] 16 16 1024 32 -(%i3) lsquares_residual_mse (M, [z, x, y], (z + D)^2 = A*x + B*y + C, first (a)); +(%i4) lsquares_residual_mse (M, [z, x, y], (z + D)^2 = A*x + B*y + C, first (a)); 169 -(%o3) ---- +(%o4) ---- 2560 @end example ```