home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / info / calc.info-20 (.txt) < prev    next >
GNU Info File  |  1994-12-22  |  49KB  |  803 lines

  1. This is Info file calc.info, produced by Makeinfo-1.55 from the input
  2. file calc.texinfo.
  3.    This file documents Calc, the GNU Emacs calculator.
  4.    Copyright (C) 1990, 1991 Free Software Foundation, Inc.
  5.    Permission is granted to make and distribute verbatim copies of this
  6. manual provided the copyright notice and this permission notice are
  7. preserved on all copies.
  8.    Permission is granted to copy and distribute modified versions of
  9. this manual under the conditions for verbatim copying, provided also
  10. that the section entitled "GNU General Public License" is included
  11. exactly as in the original, and provided that the entire resulting
  12. derived work is distributed under the terms of a permission notice
  13. identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions, except that the section entitled "GNU General Public License"
  17. may be included in a translation approved by the author instead of in
  18. the original English.
  19. File: calc.info,  Node: Standard Nonlinear Models,  Next: Curve Fitting Details,  Prev: Error Estimates for Fits,  Up: Curve Fitting
  20. Standard Nonlinear Models
  21. -------------------------
  22. The `a F' command also accepts other kinds of models besides lines and
  23. polynomials.  Some common models have quick single-key abbreviations;
  24. others must be entered by hand as algebraic formulas.
  25.    Here is a complete list of the standard models recognized by `a F':
  26.      Linear or multilinear.  a + b x + c y + d z.
  27. `2-9'
  28.      Polynomials.  a + b x + c x^2 + d x^3.
  29.      Exponential.  a exp(b x) exp(c y).
  30.      Base-10 exponential.  a 10^(b x) 10^(c y).
  31.      Exponential (alternate notation).  exp(a + b x + c y).
  32.      Base-10 exponential (alternate).  10^(a + b x + c y).
  33.      Logarithmic.  a + b ln(x) + c ln(y).
  34.      Base-10 logarithmic.  a + b log10(x) + c log10(y).
  35.      General exponential.  a b^x c^y.
  36.      Power law.  a x^b y^c.
  37.      Quadratic.  a + b (x-c)^2 + d (x-e)^2.
  38.      Gaussian.  (a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2).
  39.    All of these models are used in the usual way; just press the
  40. appropriate letter at the model prompt, and choose variable names if
  41. you wish.  The result will be a formula as shown in the above table,
  42. with the best-fit values of the parameters substituted.  (You may find
  43. it easier to read the parameter values from the vector that is placed
  44. in the trail.)
  45.    All models except Gaussian and polynomials can generalize as shown
  46. to any number of independent variables.  Also, all the built-in models
  47. have an additive or multiplicative parameter shown as `a' in the above
  48. table which can be replaced by zero or one, as appropriate, by typing
  49. `h' before the model key.
  50.    Note that many of these models are essentially equivalent, but
  51. express the parameters slightly differently.  For example, `a b^x' and
  52. the other two exponential models are all algebraic rearrangements of
  53. each other.  Also, the "quadratic" model is just a degree-2 polynomial
  54. with the parameters expressed differently.  Use whichever form best
  55. matches the problem.
  56.    The HP-28/48 calculators support four different models for curve
  57. fitting, called `LIN', `LOG', `EXP', and `PWR'.  These correspond to
  58. Calc models `a + b x', `a + b ln(x)', `a exp(b x)', and `a x^b',
  59. respectively.  In each case, `a' is what the HP-48 identifies as the
  60. "intercept," and `b' is what it calls the "slope."
  61.    If the model you want doesn't appear on this list, press `'' (the
  62. apostrophe key) at the model prompt to enter any algebraic formula,
  63. such as `m x - b', as the model.  (Not all models will work,
  64. though--see the next section for details.)
  65.    The model can also be an equation like `y = m x + b'.  In this case,
  66. Calc thinks of all the rows of the data matrix on equal terms; this
  67. model effectively has two parameters (`m' and `b') and two independent
  68. variables (`x' and `y'), with no "dependent" variables.  Model equations
  69. do not need to take this `y =' form.  For example, the implicit line
  70. equation `a x + b y = 1' works fine as a model.
  71.    When you enter a model, Calc makes an alphabetical list of all the
  72. variables that appear in the model.  These are used for the default
  73. parameters, independent variables, and dependent variable (in that
  74. order).  If you enter a plain formula (not an equation), Calc assumes
  75. the dependent variable does not appear in the formula and thus does not
  76. need a name.
  77.    For example, if the model formula has the variables `a,mu,sigma,t,x',
  78. and the data matrix has three rows (meaning two independent variables),
  79. Calc will use `a,mu,sigma' as the default parameters, and the data rows
  80. will be named `t' and `x', respectively.  If you enter an equation
  81. instead of a plain formula, Calc will use `a,mu' as the parameters, and
  82. `sigma,t,x' as the three independent variables.
  83.    You can, of course, override these choices by entering something
  84. different at the prompt.  If you leave some variables out of the list,
  85. those variables must have stored values and those stored values will be
  86. used as constants in the model.  (Stored values for the parameters and
  87. independent variables are ignored by the `a F' command.) If you list
  88. only independent variables, all the remaining variables in the model
  89. formula will become parameters.
  90.    If there are `$' signs in the model you type, they will stand for
  91. parameters and all other variables (in alphabetical order) will be
  92. independent.  Use `$' for one parameter, `$$' for another, and so on.
  93. Thus `$ x + $$' is another way to describe a linear model.
  94.    If you type a `$' instead of `'' at the model prompt itself, Calc
  95. will take the model formula from the stack.  (The data must then appear
  96. at the second stack level.)  The same conventions are used to choose
  97. which variables in the formula are independent by default and which are
  98. parameters.
  99.    Models taken from the stack can also be expressed as vectors of two
  100. or three elements, `[MODEL, VARS]' or `[MODEL, VARS, PARAMS]'.  Each of
  101. VARS and PARAMS may be either a variable or a vector of variables.  (If
  102. PARAMS is omitted, all variables in MODEL except those listed as VARS
  103. are parameters.)
  104.    When you enter a model manually with `'', Calc puts a 3-vector
  105. describing the model in the trail so you can get it back if you wish.
  106.    Finally, you can store a model in one of the Calc variables `Model1'
  107. or `Model2', then use this model by typing `a F u' or `a F U'
  108. (respectively).  The value stored in the variable can be any of the
  109. formats that `a F $' would accept for a model on the stack.
  110.    Calc uses the principal values of inverse functions like `ln' and
  111. `arcsin' when doing fits.  For example, when you enter the model `y =
  112. sin(a t + b)' Calc actually uses the easier form `arcsin(y) = a t + b'.
  113. The `arcsin' function always returns results in the range from -90 to
  114. 90 degrees (or the equivalent range in radians).  Suppose you had data
  115. that you believed to represent roughly three oscillations of a sine
  116. wave, so that the argument of the sine might go from zero to 3*360
  117. degrees.  The above model would appear to be a good way to determine the
  118. true frequency and phase of the sine wave, but in practice it would
  119. fail utterly.  The righthand side of the actual model `arcsin(y) = a t
  120. + b' will grow smoothly with `t', but the lefthand side will bounce
  121. back and forth between -90 and 90.  No values of `a' and `b' can make
  122. the two sides match, even approximately.
  123.    There is no good solution to this problem at present.  You could
  124. restrict your data to small enough ranges so that the above problem
  125. doesn't occur (i.e., not straddling any peaks in the sine wave).  Or,
  126. in this case, you could use a totally different method such as Fourier
  127. analysis, which is beyond the scope of the `a F' command.
  128. (Unfortunately, Calc does not currently have any facilities for taking
  129. Fourier and related transforms.)
  130. File: calc.info,  Node: Curve Fitting Details,  Next: Interpolation,  Prev: Standard Nonlinear Models,  Up: Curve Fitting
  131. Curve Fitting Details
  132. ---------------------
  133. Calc's internal least-squares fitter can only handle multilinear
  134. models.  More precisely, it can handle any model of the form `a
  135. f(x,y,z) + b g(x,y,z) + c h(x,y,z)', where `a,b,c'