home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 81 / basic / math / minquad.81 < prev    next >
Encoding:
Text File  |  2001-07-01  |  1.7 KB  |  85 lines

  1. Hi!
  2. This program is a superset of others like QUADREG or CUBICREG
  3. by Peter L.A. Oakes. It will fit almost any regression to the
  4. given data.
  5.  
  6. -> OK, some examples:
  7.  
  8.  1) A quadratic regression
  9.  
  10.  Data: (0,14.8) (10,13.9) (20,13.4) (30,13.5) (40,15.5) (46,18.3)
  11.  Functions: Y1=1     (add them to the Y= menu)
  12.             Y2=X
  13.             Y3=X^2
  14.  NUM.FUNCTIONS: 3
  15.  Result: [ 15.10365385 ]
  16.          [ -.2246085165]
  17.          [ .0061710165 ]
  18.  
  19.  So it is: Y = 15.10365385 - 0.2246085165X + 0.0061710165X^2    
  20.  (from QUADREG file)
  21.  
  22.  2) periodic data
  23.  
  24.  Data: (-2,-0.07) (-1.5,-0.53) (-0.5,0.10) (0,1.05) (0.5,2)
  25.  Functions: Y1=1
  26.             Y2=sin X
  27.             Y3=cos X
  28.  NUM.FUNCTIONS: 3
  29.  Result: [ 1.514274536 ]
  30.          [ 1.992831885 ]
  31.          [ -.5068796265]
  32.  
  33.  That's it: Y = 1.514274536 + 1.992831885*sin(X) - 0.5068796265*cos(X)
  34.  or ~ Y = 1.5 + 2sin(X) - 0.5cos(x)
  35.  
  36. -> Notes: 
  37.  
  38.  Be carefull with [B]T , [A]-1, Y1, Y2, Y3 and Y4 (see notes)    
  39.  
  40. -> Program
  41.  
  42. :NAME: MINQUAD
  43. :ClrHome
  44. :Disp "NUM. FUNCTIONS:"      <- from 2 to 4
  45. :Input F
  46. :F->Arow
  47. :F->Acol
  48. :F->Brow
  49. :F->Bcol
  50. :F->Crow
  51. :1->Ccol
  52. :0->[A]
  53. :0->[C]
  54. :1->N
  55. :Lbl 1
  56. :1->[B]
  57. :{x}(N)->X
  58. :{y}(N)->Y
  59. :1->C
  60. :Lbl 2
  61. :*Row(Y1,[B],1)->[B]
  62. :*Row(Y2,[B],2)->[B]
  63. :If F>2
  64. :*Row(Y3,[B],3)->[B]
  65. :If F>3
  66. :*Row(Y4,[B],4)->[B]
  67. :[B]T->[B]                  <- TRANSP([B]) -> [B]
  68. :IS>(C,2)
  69. :Goto 2
  70. :YY1+[C](1,1)->[C](1,1)     <- Y * Ysub1 + ...
  71. :YY2+[C](2,1)->[C](2,1)
  72. :If F>2
  73. :YY3+[C](3,1)->[C](3,1)
  74. :If F>3
  75. :YY4+[C](4,1)->[C](4,1)
  76. :[B]+[A]->[A]
  77. :IS>(N,Dim{x})
  78. :Goto 1
  79. :[A]-1[C]->[A]               <- INV([A]) * [C] -> [A]
  80. :ClrHome
  81. :Disp "COEFICIENTS:"
  82. :Disp [A]
  83. :End
  84.  
  85. -> Any comments to xosem@cablecat.com