DerApproximator




This page displays all DerApproximator versions from Softpedia
Soft85 only provide legal software, please help us keeping pur site legal, if you think this page is violating copyrights please let us know by clicking here Here





All DerApproximator versions from Softpedia sources and versions


DerApproximator

  • OS:
  • Version: 0.502
  • File size:
  • Date Added: 2013-28-07
Download DerApproximator DerApproximator

DerApproximator Description

DerApproximator is a Python library for finite-differences derivatives approximation.Example:from DerApproximator import *print get_d1(lambda x: (x**2).sum(), [1,2,3])print get_d1(lambda x: x**2, [1,2,3])Expected output: [ 1.99999993 3.99999998 5.99999996][[ 2. 0. 0. ][ 0. 3.99999996 0. ][ 0. 0. 5.99999996]] * check_d1 checks user-provided routing for obtaining 1st derivatives of a functionExample:from numpy import *from DerApproximator import *func = lambda x: (x**4).sum()func_d = lambda x: 40 * x**3x = arange(1.0, 6.0)r = check_d1(func, func_d, x)func = lambda x: x**4func_d = lambda x: 40 * diag(x**3)x = arange(1.0, 6.0)r = check_d1(func, func_d, x)Expected output:func num user-supplied numerical RD0 +4.000e+01 +4.000e+00 31 +3.200e+02 +3.200e+01 32 +1.080e+03 +1.080e+02 33 +2.560e+03 +2.560e+02 34 +5.000e+03 +5.000e+02 3max(abs(d_user - d_numerical)) = 4499.9999861(is registered in func number 4)func num i,j: dfunc[i]/dx[j] user-supplied numerical RD0 0 / 0 +4.000e+01 +4.000e+00 36 1 / 1 +3.200e+02 +3.200e+01 312 2 / 2 +1.080e+03 +1.080e+02 318 3 / 3 +2.560e+03 +2.560e+02 324 4 / 4 +5.000e+03 +5.000e+02 3max(abs(d_user - d_numerical)) = 4499.9999861(is registered in func number 24) * 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:from numpy import *from DerApproximator import get_d1func = lambda x: (x**4).sum()x = arange(1.0, 6.0)r1 = get_d1(func, x, stencil = 1, diffInt = 1e-5)print(r1)r2 = get_d1(func, x, stencil = 2, diffInt = 1e-5)print(r2)Expected output:[ 4.00005999 32.00024 108.00054 256.00095998 500.00149998][ 4. 32. 108. 256. 499.99999998] * 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.Product's homepage Requirements: · Python · NumPy What's New in This Release: [ read full changelog ] · Add parameter exactShape (prevents flattering operations on result). �.You can free download DerApproximator from Softpedia now.
Source: Softpedia

Share DerApproximator



DerApproximator

  Keywords


comments powered by Disqus

Most downloaded this week