1

I am looking for some pointers and resources on whether the following can be efficiently done in Python.

I have a custom function:

def outerfunc(innerfunc(<inputs>), arg1, arg2):

computing outerfunc returns a numeric value, let's call it result

innerfuncaccepts a few arguments, one of which is a list of numbers, [x1,x2,x3]and returns an object which is used to perform the calculation

objective:

calculate the sensitivity of result to a perturbation (finite amount) of each of [x1,x2,x3] so as to obtain a vector of 3 elements - the partial derivatives of result w.r.t. x1, x2, and x3

any resources, examples, advice would be appreciated!

edit: i should elaborate that innerfunc in this example could come from a third-party source and is not directly built on numpy or edit-able. this is where i am not able to find much references online

Mad Physicist
  • 107,652
  • 25
  • 181
  • 264
laszlopanaflex
  • 1,836
  • 3
  • 23
  • 34
  • 5
    Possible duplicate of [How do I compute derivative using Numpy?](https://stackoverflow.com/questions/9876290/how-do-i-compute-derivative-using-numpy) – mkrieger1 Aug 18 '18 at 19:53
  • 1
    thanks for the link. I am still a little bit unsure how this might work in the case where the innerfunc is not 'simple'/'closed-form. for example, what if internally it were performing some kind of monte-carlo simulation as opposed to a straightforward expression – laszlopanaflex Aug 18 '18 at 21:31
  • 1
    @laszlopanaflex. Numeric derivatives aren't all that useful if your function is not continuous. – Mad Physicist Aug 19 '18 at 15:49

0 Answers0