@@ -2064,6 +2064,7 @@ def make_node(self, rng, size, dtype, mu, W, alpha, tau):
2064
2064
W = Assert (msg )(W , pt .allclose (W , W .T ))
2065
2065
2066
2066
tau = pt .as_tensor_variable (floatX (tau ))
2067
+
2067
2068
alpha = pt .as_tensor_variable (floatX (alpha ))
2068
2069
2069
2070
return super ().make_node (rng , size , dtype , mu , W , alpha , tau )
@@ -2080,6 +2081,9 @@ def rng_fn(cls, rng: np.random.RandomState, mu, W, alpha, tau, size):
2080
2081
Journal of the Royal Statistical Society Series B, Royal Statistical Society,
2081
2082
vol. 63(2), pages 325-338. DOI: 10.1111/1467-9868.00288
2082
2083
"""
2084
+ if np .any (alpha >= 1 ) or np .any (alpha <= - 1 ):
2085
+ raise ValueError ("the domain of alpha is: -1 < alpha < 1" )
2086
+
2083
2087
if not scipy .sparse .issparse (W ):
2084
2088
W = scipy .sparse .csr_matrix (W )
2085
2089
s = np .asarray (W .sum (axis = 0 ))[0 ]
@@ -2146,8 +2150,9 @@ class CAR(Continuous):
2146
2150
:func:`~pytensor.sparse.basic.as_sparse_or_tensor_variable` is
2147
2151
used for this sparse or tensorvariable conversion.
2148
2152
alpha : tensor_like of float
2149
- Autoregression parameter taking values between -1 and 1. Values closer to 0 indicate weaker
2150
- correlation and values closer to 1 indicate higher autocorrelation. For most use cases, the
2153
+ Autoregression parameter taking values greater than -1 and less than 1.
2154
+ Values closer to 0 indicate weaker correlation and values closer to
2155
+ 1 indicate higher autocorrelation. For most use cases, the
2151
2156
support of alpha should be restricted to (0, 1).
2152
2157
tau : tensor_like of float
2153
2158
Positive precision variable controlling the scale of the underlying normal variates.
@@ -2214,10 +2219,10 @@ def logp(value, mu, W, alpha, tau):
2214
2219
logquad = (tau * delta * tau_dot_delta ).sum (axis = - 1 )
2215
2220
return check_parameters (
2216
2221
0.5 * (logtau + logdet - logquad ),
2217
- - 1 <= alpha ,
2218
- alpha <= 1 ,
2222
+ - 1 < alpha ,
2223
+ alpha < 1 ,
2219
2224
tau > 0 ,
2220
- msg = "-1 <= alpha <= 1, tau > 0" ,
2225
+ msg = "-1 < alpha < 1, tau > 0" ,
2221
2226
)
2222
2227
2223
2228
0 commit comments