@@ -42,18 +42,20 @@ def __exit__(self, *args):
4242
4343
4444class Copula :
45- """Base class for Archimedean copulas in φ -notation.
45+ r """Base class for Archimedean copulas in $\varphi$ -notation.
4646
47- Subclasses must implement generator(u) which returns φ(u), where
48- u ∈ (0, 1], φ: (0,1] → [0, ∞), strictly decreasing, convex, φ(1)=0.
47+ Subclasses must implement `generator(u)`, which returns $\varphi(u)$,
48+ where $u \in (0, 1]$ and $\varphi:(0,1] \to [0,\infty)$ is strictly
49+ decreasing and convex with $\varphi(1)=0$.
4950 """
5051
5152 def generator (self , u : jax .Array ) -> jax .Array : # pragma: no cover - abstract
52- """Return the Archimedean generator φ (u).
53+ r """Return the Archimedean generator $\varphi (u)$ .
5354
54- Subclasses **must** implement this. φ maps (0, 1] → [0, ∞), is
55- strictly decreasing and convex, with φ(1) = 0. Everything else
56- (density, inverse, sampling) is derived from it automatically.
55+ Subclasses **must** implement this. $\varphi$ maps $(0,1] \to
56+ [0,\infty)$, is strictly decreasing and convex, with $\varphi(1)=0$.
57+ Everything else (density, inverse, sampling) is derived from it
58+ automatically.
5759 """
5860 raise NotImplementedError
5961
@@ -62,40 +64,41 @@ def generator_inv(self, t: jax.Array) -> jax.Array:
6264 return _invert_generator (self .generator , t )
6365
6466 def log_generator_kth_derivative (self , t : jax .Array , k : int ) -> jax .Array :
65- """Return log |ψ ^{(k)}(t)|, the log absolute k -th derivative.
67+ r """Return $\ log|\psi ^{(k)}(t)|$ , the log absolute $k$ -th derivative.
6668
6769 Override this with a closed-form expression to bypass jet for
68- specific families. For example, Clayton can use::
70+ specific families. For example, Clayton can use
6971
70- lgamma(k + 1/theta) - lgamma(1/theta) - (k + 1/theta) * log1p(t)
72+ $$\log\Gamma(k + 1/\theta) - \log\Gamma(1/\theta)
73+ - (k + 1/\theta)\,\log(1+t).$$
7174
72- The default returns None, which tells the framework to use
75+ The default returns `` None`` , which tells the framework to use
7376 Taylor-mode AD via jet.
7477 """
7578 return None # sentinel: use jet
7679
7780 def generator_taylor_coefficients (
7881 self , t : jax .Array , k_max : int
7982 ) -> jax .Array :
80- """Return Taylor coefficients ``[ψ (t), ψ '(t)/1!, …, ψ ^{(k_max )}(t)/k_max!]`` .
83+ r """Return Taylor coefficients $[\psi (t),\, \psi '(t)/1!,\, \ldots,\, \psi ^{(k_{\max} )}(t)/k_{\max}!]$ .
8184
82- Override this when the closed-form ψ has a numerically stable
85+ Override this when the closed-form $\psi$ has a numerically stable
8386 series representation that avoids the cancellations Taylor-mode
8487 AD on the closed form would produce at high derivative order.
85- For example, AMH's ψ is the Laplace transform of Geometric(1−θ),
86- so all Taylor coefficients are sums of same-sign terms (no
87- cancellation):
88+ For example, AMH's $\psi$ is the Laplace transform of
89+ $\mathrm{Geometric}(1-\theta)$, so all Taylor coefficients are
90+ sums of same-sign terms (no cancellation):
8891
89- ψ ^{(k)}(t) = (-1)^k Σ_ {x=1}^∞ x^k (1−θ) θ ^{x−1} e^{− tx}
92+ $$\psi ^{(k)}(t) = (-1)^k \sum_ {x=1}^{\infty} x^k\,(1-\theta)\,\theta ^{x-1}\, e^{- tx}.$$
9093
9194 The framework consults this hook everywhere it would otherwise
9295 call ``jet_array.jet`` on ``self.generator`` to get a Taylor
9396 expansion: the root density (``bell._root_assembly``) and the
9497 nesting composition (``compose.compute_composition_taylor``).
9598 Returning ``None`` (the default) tells those call sites to
9699 fall back to the jet path, which is correct but loses
97- precision when ψ 's derivatives have large alternating-sign
98- cancellations (e.g. AMH past d≈30 in float64).
100+ precision when $\psi$ 's derivatives have large alternating-sign
101+ cancellations (e.g. AMH past $d \approx 30$ in float64).
99102
100103 Args:
101104 t: scalar input point.
@@ -111,11 +114,11 @@ def generator_taylor_coefficients(
111114 def log_generator_taylor_coefficients (
112115 self , t : jax .Array , k_max : int
113116 ) -> Optional [Tuple [jax .Array , jax .Array ]]:
114- """Log-space variant of :meth:`generator_taylor_coefficients`.
117+ r """Log-space variant of :meth:`generator_taylor_coefficients`.
115118
116119 Return ``(sign, log_abs)``, two arrays of shape ``(k_max + 1,)`` with
117120
118- ψ ^{(k)}(t) / k! == sign[k] * exp(log_abs [k]).
121+ $$\psi ^{(k)}(t) / k! \;=\; \mathrm{ sign} [k]\,\ exp(\mathrm{log\_abs} [k]).$$
119122
120123 The Bell density consumes the Taylor coefficients as ``(sign, log|c|)``
121124 pairs internally, so a family whose normalized coefficients are
0 commit comments