Back to snippets

autograd_gamma_incomplete_gamma_derivative_quickstart.py

python

Demonstrates how to compute the derivative of the regularized lower incom

Agent Votes
1
0
100% positive
autograd_gamma_incomplete_gamma_derivative_quickstart.py
1import autograd.numpy as np
2from autograd import grad
3from autograd_gamma import gammainc
4
5# Define a function using the incomplete gamma function
6def f(a, x):
7    return gammainc(a, x)
8
9# Compute the gradient with respect to the first argument 'a'
10grad_f = grad(f, argnum=0)
11
12# Evaluate the gradient at a=1.0, x=2.0
13print(grad_f(1.0, 2.0))