# Gaussian Copula Priors in Turing: Auto-differentiation Error with Beta Quantile Function

**URL:** <https://discourse.julialang.org/t/gaussian-copula-priors-in-turing-auto-differentiation-error-with-beta-quantile-function/132779>\
**Category:** Statistics\
**Created:** [September 30, 2025, 8:33am UTC](https://discourse.julialang.org/t/gaussian-copula-priors-in-turing-auto-differentiation-error-with-beta-quantile-function/132779 "2025-09-30T08:33:17Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Post date:** [October 4, 2025, 1:36pm UTC](https://discourse.julialang.org/t/gaussian-copula-priors-in-turing-auto-differentiation-error-with-beta-quantile-function/132779/6 "2025-10-04T13:36:15Z")

</div>

> [@giovannitinervia9](#):
>
> It appears that the Beta distribution’s `quantile` function (which relies on `_beta_inc_inv` internally) doesn’t support automatic differentiation with `ForwardDiff.Dual` numbers, which NUTS requires for computing gradients.

Yes you nailed it, this is exactly the problem. The _right_ thing to do would be to explain to ForwardDiff how to differentiate this function.

Also related, from 5 years ago, same issue : [Differentiation of incomplete Beta function](https://discourse.julialang.org/t/differentiation-of-incomplete-beta-function/49675) with some code for the gradients apparently. Also I have seen the same problem when working for Studient copulas, or when fitting multivariate students…

Opened an issue [there](https://github.com/JuliaMath/SpecialFunctions.jl/issues/505) to get some guidance, if we want to fix this once and for all.

Edit: aaaad did it myself in [this PR](https://github.com/JuliaMath/SpecialFunctions.jl/pull/506), which should solve your issue.

---

_[View the full topic](https://discourse.julialang.org/t/gaussian-copula-priors-in-turing-auto-differentiation-error-with-beta-quantile-function/132779)._
