Skip to content

ENH/Recipe tools chainrule for derivatives of nested parameterized functions #7245

Open

Description

@josef-pkt

we don't use automatic differentiation, but we use chain rule with pieces quite heavily

We might need something reusable when we use parameterized links or transformations.

example f(g(x, b), a)
where x is scalar and a and b are parameters

e.g.

  • likelihood function with parameterized links and x is the linear predictor
  • chained transformation f and g which both have parameters, simple example g is standardize transformation with b=(loc, scale)
  • transformation of distribution where both transformation and base distribution have parameter,
    e.g. BirnbaumSaunders-t where f is transform with skew parameter and g is t-distribution with df parameter

Wolfram alpha is helpful
https://www.wolframalpha.com/input/?i=table+d%5En%2Fdb%5En+f%28g%28x%2C+b%29%2C+a%29+for+n+%3D+1+...+2

derivatives wrt. params b
table d^n/db^n f(g(x, b), a) for n = 1 ... 2

g^(0, 1)(x, b) f^(1, 0)(g(x, b), a)
g^(0, 1)(x, b)^2 f^(2, 0)(g(x, b), a) + g^(0, 2)(x, b) f^(1, 0)(g(x, b), a)

notation
g^(0, 1)(x, b) is 0th derivative of g wrt. first argument x and 1st derivative wrt. second argument b

We can get a dictionary of derivative (i,j) for i,j = 0, 1, 2 with i+j <= 2 to have all first and second partial derivatives

chained case without params is simpler

derivatives of f(g(x)) w.r.t. x

g'(x) f'(g(x))
g'(x)^2 f''(g(x)) + g''(x) f'(g(x))

(Just an idea. I don't have code yet that uses parameterized links)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions