Registry / ai-ml / autograd-gamma

autograd-gamma

JSON →
library0.5.0pypypi✓ verified 25d ago

autograd-gamma provides autograd-compatible approximations to the gamma and beta family of functions, enabling automatic differentiation for these special functions. The current version is 0.5.0, with a release cadence that is infrequent but active, releasing updates as new functions or fixes are integrated.

pip install autograd-gamma
INSTALL
IMPORT
SIG · AUTOGRAD-GAMMA
A
autograd-gamma
ai-mlpythonv0.5.0
Install
8.3s avg
Import
2718ms
Disk
231MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 2.748s · 232.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 8.3s · import 2.688s · 224MB
231MB installed
● package 231MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

gammainc
from autograd_gamma import gammainc
gammaincln
from autograd_gamma import gammaincln
betainc
from autograd_gamma import betainc
from autograd_gamma import beta_inc
Common misspelling, functions use 'inc' suffix directly.

This example demonstrates how to use `autograd-gamma` functions within the `autograd` framework to compute gradients. It uses `autograd.numpy` for array operations, which is crucial for automatic differentiation with `autograd`.

import autograd.numpy as np from autograd import grad from autograd_gamma import gammainc # Define a function using autograd-gamma's gammainc def calculate_value(x): # For autograd, inputs to gammainc should be autograd.numpy arrays # The 'a' parameter (first argument) is the shape parameter, 'x' is the integral upper limit return gammainc(2.0, x) # Example: incomplete gamma function for a=2.0 # Compute the gradient of the function with respect to x gradient_function = grad(calculate_value) # Test with a value (must be an autograd.numpy array for gradient) x_val = np.array(0.5) value = calculate_value(x_val) gradient = gradient_function(x_val) print(f"Function value gammainc(2.0, {x_val}) = {value}") print(f"Gradient d/dx gammainc(2.0, x) at x={x_val} = {gradient}")
Debug
Known issues
gotchaFor automatic differentiation, it is crucial to use `autograd.numpy` instead of standard `numpy` when defining functions that will be differentiated. `autograd-gamma` functions are designed to work with `autograd.numpy`'s array types.
fix
Replace `import numpy as np` with `import autograd.numpy as np` when constructing functions that will be passed to `autograd.grad` or similar functions.
affects: all
gotchaFunctions for the incomplete beta function (e.g., `betainc`, `betaincln`) were added in version 0.4.0. Attempting to import or use these functions in `autograd-gamma` versions prior to 0.4.0 will result in an `ImportError` or `AttributeError`.
fix
Ensure `autograd-gamma` is updated to version 0.4.0 or newer by running `pip install --upgrade autograd-gamma` to access beta functions.
affects: <0.4.0
gotchaThe functions provided by `autograd-gamma` are *approximations* to the gamma and beta functions, specifically optimized for compatibility with `autograd`. They are not intended for arbitrary precision computations where exact values are required, which might be found in libraries like `scipy.special`.
fix
Be aware of the approximate nature of the functions. For tasks not involving automatic differentiation and requiring high numerical precision, consider using `scipy.special`.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'autograd_gamma'
The 'autograd-gamma' package is not installed in the Python environment.
fix
Install the package using pip: 'pip install autograd-gamma'.
ImportError: cannot import name 'gammainc' from 'autograd_gamma'
The function 'gammainc' is not available in the 'autograd_gamma' module.
fix
Ensure you are using the correct function names as provided by the 'autograd_gamma' library.
AttributeError: module 'autograd_gamma' has no attribute 'gammainc'
Attempting to access a function that does not exist in the 'autograd_gamma' module.
fix
Verify the available functions in 'autograd_gamma' and use the correct function names.
TypeError: 'module' object is not callable
Trying to call the 'autograd_gamma' module as a function.
fix
Import and use specific functions from 'autograd_gamma' instead of calling the module directly.
ModuleNotFoundError: No module named 'autograd-gamma'
The `autograd-gamma` library is not installed in the Python environment or the environment where the code is being run.
fix
Install the library using pip: `pip install autograd-gamma`
Upgrade
Version history
0.5.0latest on PyPI · released Oct 15, 2020
Audit
Dependencies
autogradrequiredCore dependency for automatic differentiation capabilities.
numpyrequiredFundamental library for numerical operations; autograd-gamma functions typically operate on numpy arrays, specifically autograd.numpy arrays.
Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources