About Install Documentation Problems Tree Forum Save your money
via IT outsourcing!

Ukrainian HI-TECH Initiative

DerApproximator

From OpenOpt

Jump to: navigation, search
DerApproximator

  • DerApproximator is a small yet important package for getting/checking derivatives (currently only 1st ones), extracted from OpenOpt framework to be standalone Python module. It is required by FuncDesigner (for obtaining derivatives of oofuns beyond standard set without routines to yield them directly) and some OpenOpt solvers (when there are some functions without user-supplied derivatives).
  • Requirements for the package (as well as for OpenOpt and FuncDesigner) are NumPy and python-setuptools; OS - any where Python and numpy work (Linux, Windows, Mac OS X etc).
  • Currently it provides only 2 functions - get_d1 and check_d1. Two required arguments for get_d1 and check_d1 are the func involved and the point where derivatives are to be got / checked. If user provides Python list (as start point), it is automatically casted to NumPy array.
  • get_d1 returns 1st derivatives of a func f : R^n -> R^m Example


  • check_d1 checks user-provided routing for obtaining 1st derivatives of a function Example


  • Default diffInt is 1.5e-8, you can overwrite it by "diffInt" argument for get_d1 and check_d1. Another one argument is stencil, default value 2 for DerApproximator, FuncDesigner and OpenOpt NSP is 2, i.e. (f(x+diffInt)-f(x-diffInt)) / (2*diffInt), for OpenOpt NLP default is 1, i.e. (f(x+diffInt)-f(x)) / diffInt. Example
  • If it turns out that f(x+diffInt) is NaN (not a number) or f(x-diffInt) is NaN, than only one side will be involved into calculations. BTW this is a typical situation for lots of numerical optimization problems, and currently functions approx_fprime and check_grad from scipy.optimize are even more primitive - they have only one stencil and no handling of NaNs.
  • In future five-point_stencil is intended to be provided, mb along with some stencils for 2nd derivatives.
Made by Dmitrey


See also:

Personal tools
Latest OOSuite 0.27