bayinx 0.3.12__py3-none-any.whl → 0.3.13__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bayinx/dists/censored/posnormal/r.py +5 -6
- bayinx/dists/uniform.py +39 -5
- {bayinx-0.3.12.dist-info → bayinx-0.3.13.dist-info}/METADATA +1 -1
- {bayinx-0.3.12.dist-info → bayinx-0.3.13.dist-info}/RECORD +6 -6
- {bayinx-0.3.12.dist-info → bayinx-0.3.13.dist-info}/WHEEL +0 -0
- {bayinx-0.3.12.dist-info → bayinx-0.3.13.dist-info}/licenses/LICENSE +0 -0
@@ -1,8 +1,9 @@
|
|
1
1
|
import jax.numpy as jnp
|
2
2
|
import jax.random as jr
|
3
|
+
from jax.scipy.special import ndtri
|
3
4
|
from jaxtyping import Array, ArrayLike, Float, Key
|
4
5
|
|
5
|
-
from bayinx.dists import posnormal
|
6
|
+
from bayinx.dists import normal, posnormal
|
6
7
|
|
7
8
|
|
8
9
|
def prob(
|
@@ -108,10 +109,8 @@ def sample(
|
|
108
109
|
# Derive shape
|
109
110
|
shape = (n,) + jnp.broadcast_shapes(mu.shape, sigma.shape, censor.shape)
|
110
111
|
|
111
|
-
#
|
112
|
-
draws = jr.
|
113
|
-
|
114
|
-
# Censor values
|
115
|
-
draws = jnp.where(censor <= draws, censor, draws)
|
112
|
+
# Construct draws
|
113
|
+
draws = jr.uniform(key, shape)
|
114
|
+
draws = mu + sigma * ndtri(normal.cdf(-mu/sigma, 0.0, 1.0) + draws * normal.cdf(mu/sigma, 0.0, 1.0))
|
116
115
|
|
117
116
|
return draws
|
bayinx/dists/uniform.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import jax.lax as _lax
|
2
2
|
import jax.numpy as jnp
|
3
|
-
|
3
|
+
import jax.random as jr
|
4
|
+
from jaxtyping import Array, ArrayLike, Float, Key
|
4
5
|
|
5
6
|
|
6
7
|
def prob(
|
@@ -17,8 +18,10 @@ def prob(
|
|
17
18
|
# Returns
|
18
19
|
The PDF evaluated at `x`. The output will have the broadcasted shapes of `x`, `lb`, and `ub`.
|
19
20
|
"""
|
21
|
+
# Cast to Array
|
22
|
+
x, lb, ub = jnp.asarray(x), jnp.asarray(lb), jnp.asarray(ub)
|
20
23
|
|
21
|
-
return 1.0 / (ub - lb)
|
24
|
+
return 1.0 / (ub - lb)
|
22
25
|
|
23
26
|
|
24
27
|
def logprob(
|
@@ -35,8 +38,10 @@ def logprob(
|
|
35
38
|
# Returns
|
36
39
|
The log of the PDF evaluated at `x`. The output will have the broadcasted shapes of `x`, `lb`, and `ub`.
|
37
40
|
"""
|
41
|
+
# Cast to Array
|
42
|
+
x, lb, ub = jnp.asarray(x), jnp.asarray(lb), jnp.asarray(ub)
|
38
43
|
|
39
|
-
return _lax.log(1.0) - _lax.log(ub - lb)
|
44
|
+
return _lax.log(1.0) - _lax.log(ub - lb)
|
40
45
|
|
41
46
|
|
42
47
|
def uprob(
|
@@ -53,8 +58,10 @@ def uprob(
|
|
53
58
|
# Returns
|
54
59
|
The uPDF evaluated at `x`. The output will have the broadcasted shapes of `x`, `lb`, and `ub`.
|
55
60
|
"""
|
61
|
+
# Cast to Array
|
62
|
+
x, lb, ub = jnp.asarray(x), jnp.asarray(lb), jnp.asarray(ub)
|
56
63
|
|
57
|
-
return jnp.ones(jnp.
|
64
|
+
return jnp.ones(jnp.broadcast_shapes(x.shape, lb.shape, ub.shape))
|
58
65
|
|
59
66
|
|
60
67
|
def ulogprob(
|
@@ -71,5 +78,32 @@ def ulogprob(
|
|
71
78
|
# Returns
|
72
79
|
The log uPDF evaluated at `x`. The output will have the broadcasted shapes of `x`, `lb`, and `ub`.
|
73
80
|
"""
|
81
|
+
# Cast to Array
|
82
|
+
x, lb, ub = jnp.asarray(x), jnp.asarray(lb), jnp.asarray(ub)
|
74
83
|
|
75
|
-
return jnp.zeros(jnp.
|
84
|
+
return jnp.zeros(jnp.broadcast_shapes(x.shape, lb.shape, ub.shape))
|
85
|
+
|
86
|
+
def sample(
|
87
|
+
n: int, lb: Float[ArrayLike, "..."], ub: Float[ArrayLike, "..."], key: Key = jr.PRNGKey(0),
|
88
|
+
) -> Float[Array, "..."]:
|
89
|
+
"""
|
90
|
+
Sample from a Uniform distribution.
|
91
|
+
|
92
|
+
# Parameters
|
93
|
+
- `n`: Number of draws to sample per-parameter.
|
94
|
+
- `lb`: The lower bound parameter(s).
|
95
|
+
- `ub`: The upper bound parameter(s).
|
96
|
+
|
97
|
+
# Returns
|
98
|
+
Draws from a Uniform distribution. The output will have the shape of (n,) + the broadcasted shapes of `lb` and `ub`.
|
99
|
+
"""
|
100
|
+
# Cast to Array
|
101
|
+
lb, ub = jnp.asarray(lb), jnp.asarray(ub)
|
102
|
+
|
103
|
+
# Derive shape
|
104
|
+
shape = (n,) + jnp.broadcast_shapes(lb.shape, ub.shape)
|
105
|
+
|
106
|
+
# Construct draws
|
107
|
+
draws = jr.uniform(key, shape, minval = lb, maxval = ub)
|
108
|
+
|
109
|
+
return draws
|
@@ -14,12 +14,12 @@ bayinx/dists/bernoulli.py,sha256=xMV9BgtVX_1XkPdZ43q0meMIEkgMyuUPx--dyo6_DKs,100
|
|
14
14
|
bayinx/dists/gamma2.py,sha256=MuFudL2UTfk8HgWVofNaR36JTmUpmtxvg1Mifu98MvM,1567
|
15
15
|
bayinx/dists/normal.py,sha256=Yc2X8F7JoLYwprtK8bA2BPva1tAY7MEs3oSk5pMortI,3822
|
16
16
|
bayinx/dists/posnormal.py,sha256=w9plA1EctXwXOiY0doc4ZndjnwptbEZBHHCGdc4gviY,7292
|
17
|
-
bayinx/dists/uniform.py,sha256=
|
17
|
+
bayinx/dists/uniform.py,sha256=2ZQxEfAX5TFgSPuQ8joFDuFbd_NfmQ1GvmGGjusqvNQ,3461
|
18
18
|
bayinx/dists/censored/__init__.py,sha256=UVihMbQgAzCoOk_Zt5wrumPv5-acuTzV3TYMB-U1gOc,49
|
19
19
|
bayinx/dists/censored/gamma2/__init__.py,sha256=GO3jIF1En0ZxYF5JqvC0helLAL6yv8-LG6Ih2NOUYQc,33
|
20
20
|
bayinx/dists/censored/gamma2/r.py,sha256=dKAOYstufwgDwibQZHrJxA1d2gawj-7K3IkaCRCzNTg,2446
|
21
21
|
bayinx/dists/censored/posnormal/__init__.py,sha256=GO3jIF1En0ZxYF5JqvC0helLAL6yv8-LG6Ih2NOUYQc,33
|
22
|
-
bayinx/dists/censored/posnormal/r.py,sha256=
|
22
|
+
bayinx/dists/censored/posnormal/r.py,sha256=wMDt2Am1TD376ms8B-o6PFCJZXmUJd2-aBC-t9kidH4,3456
|
23
23
|
bayinx/mhx/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
24
24
|
bayinx/mhx/opt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
25
25
|
bayinx/mhx/vi/__init__.py,sha256=3T1dEpiiRge4tW-vpS0xBob_RbO1iVFnL3fVCRUawCM,205
|
@@ -31,7 +31,7 @@ bayinx/mhx/vi/flows/fullaffine.py,sha256=11y_A0oO3bkKDSz-EQ6Sf4Ec2M7vHZxw94EdvAD
|
|
31
31
|
bayinx/mhx/vi/flows/planar.py,sha256=2I2WzIskl8MRpJkK13FQE3vSF-077qo8gRed_EL1Pn8,1920
|
32
32
|
bayinx/mhx/vi/flows/radial.py,sha256=e0GfuO-CL8SVr3YnEfsxStpyKcJlFpzMyjMp3sa38hg,2503
|
33
33
|
bayinx/mhx/vi/flows/sylvester.py,sha256=ppK0BmS_ThvrCEhJiP_-p-kj67TQHSlU_RUZpDbIhsQ,469
|
34
|
-
bayinx-0.3.
|
35
|
-
bayinx-0.3.
|
36
|
-
bayinx-0.3.
|
37
|
-
bayinx-0.3.
|
34
|
+
bayinx-0.3.13.dist-info/METADATA,sha256=1mcHMTXrzMGPcibMy_vHdBJMNPtT0VUF83eVBS_MJlg,3080
|
35
|
+
bayinx-0.3.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
36
|
+
bayinx-0.3.13.dist-info/licenses/LICENSE,sha256=VMhLhj5hx6VAENZBaNfXrmsNl7ov9uRh0jZ6D3ltgv4,1070
|
37
|
+
bayinx-0.3.13.dist-info/RECORD,,
|
File without changes
|
File without changes
|