home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / sci / optics / 1200 < prev    next >
Encoding:
Text File  |  1992-11-24  |  1.5 KB  |  39 lines

  1. Newsgroups: sci.optics
  2. Path: sparky!uunet!stanford.edu!EE.Stanford.EDU!siegman
  3. From: siegman@EE.Stanford.EDU (Anthony E. Siegman)
  4. Subject: Re: Zernike fitting routine (wanted)
  5. Message-ID: <1992Nov23.182731.2742@EE.Stanford.EDU>
  6. Keywords: zernike, curve fitting
  7. Organization: Stanford University
  8. References: <a1pq!v#@lynx.unm.edu>
  9. Date: Mon, 23 Nov 92 18:27:31 GMT
  10. Lines: 27
  11.  
  12. >I am looking for a routine to fit Zernike polynomials to data on a grid,
  13. >perferably with sources and *documentation*. Does anyone have such a
  14. >critter that they might share with me? Fortran or C are both cool.
  15.  
  16. 1) Zernike polynomials are not built into Mathematica, but could be
  17. easily added; and then the "Fit" routine that is in Mathematica could
  18. be used to fit data to these polynomials as a basis set.  This routine
  19. is remarkably good.
  20.  
  21. 2) In addition, given below is a "SimpleFit" routine which is a subset
  22. of "Fit" supplied to me by somefrom from Wolfram Research, which is
  23. even more useful in that it returns the list of coefficients for the
  24. expansion of "data" in terms of the "basis" functions and the
  25. "variables".  The syntax is more or less like "Fit".
  26.  
  27.  
  28. SimpleFit[data_, basis_, vars_] :=
  29.   Block[{purebasis, designmatrix, designinverse, response,
  30. fitcoefficients},
  31.     purebasis = Function[Evaluate[vars], Evaluate[basis]];  
  32.     designmatrix = Apply[purebasis, data, 1];
  33.     designinverse = PseudoInverse[designmatrix];  
  34.     response = Last /@ data;
  35.     fitcoefficients = designinverse . response; 
  36.     fitcoefficients 
  37.   ]
  38.  
  39.