{"id":2870,"library":"autograd-gamma","title":"Autograd Gamma","description":"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.","status":"active","version":"0.5.0","language":"en","source_language":"en","source_url":"https://github.com/CamDavidsonPilon/autograd-gamma","tags":["autodiff","autograd","special-functions","gamma-function","beta-function","mathematics"],"install":[{"cmd":"pip install autograd-gamma","lang":"bash","label":"Install autograd-gamma"}],"dependencies":[{"reason":"Core dependency for automatic differentiation capabilities.","package":"autograd","optional":false},{"reason":"Fundamental library for numerical operations; autograd-gamma functions typically operate on numpy arrays, specifically autograd.numpy arrays.","package":"numpy","optional":false}],"imports":[{"symbol":"gammainc","correct":"from autograd_gamma import gammainc"},{"symbol":"gammaincln","correct":"from autograd_gamma import gammaincln"},{"note":"Common misspelling, functions use 'inc' suffix directly.","wrong":"from autograd_gamma import beta_inc","symbol":"betainc","correct":"from autograd_gamma import betainc"}],"quickstart":{"code":"import autograd.numpy as np\nfrom autograd import grad\nfrom autograd_gamma import gammainc\n\n# Define a function using autograd-gamma's gammainc\ndef calculate_value(x):\n    # For autograd, inputs to gammainc should be autograd.numpy arrays\n    # The 'a' parameter (first argument) is the shape parameter, 'x' is the integral upper limit\n    return gammainc(2.0, x) # Example: incomplete gamma function for a=2.0\n\n# Compute the gradient of the function with respect to x\ngradient_function = grad(calculate_value)\n\n# Test with a value (must be an autograd.numpy array for gradient)\nx_val = np.array(0.5)\nvalue = calculate_value(x_val)\ngradient = gradient_function(x_val)\n\nprint(f\"Function value gammainc(2.0, {x_val}) = {value}\")\nprint(f\"Gradient d/dx gammainc(2.0, x) at x={x_val} = {gradient}\")\n","lang":"python","description":"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`."},"warnings":[{"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.","message":"For 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure `autograd-gamma` is updated to version 0.4.0 or newer by running `pip install --upgrade autograd-gamma` to access beta functions.","message":"Functions 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`.","severity":"gotcha","affected_versions":"<0.4.0"},{"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`.","message":"The 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`.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}