bayinx 0.2.21__py3-none-any.whl → 0.2.22__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/normal.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import jax.lax as _lax
|
2
2
|
from jaxtyping import Array, ArrayLike, Float, Real
|
3
3
|
|
4
|
-
|
4
|
+
__PI = 3.141592653589793
|
5
5
|
|
6
6
|
|
7
7
|
def prob(
|
@@ -20,7 +20,7 @@ def prob(
|
|
20
20
|
"""
|
21
21
|
|
22
22
|
return _lax.exp(-0.5 * _lax.square((x - mu) / sigma)) / ( # pyright: ignore
|
23
|
-
sigma * _lax.sqrt(2.0 *
|
23
|
+
sigma * _lax.sqrt(2.0 * __PI)
|
24
24
|
)
|
25
25
|
|
26
26
|
|
@@ -39,7 +39,7 @@ def logprob(
|
|
39
39
|
The log of the PDF evaluated at `x`. The output will have the broadcasted shapes of `x`, `mu`, and `sigma`.
|
40
40
|
"""
|
41
41
|
|
42
|
-
return -_lax.log(sigma * _lax.sqrt(2.0 *
|
42
|
+
return -_lax.log(sigma * _lax.sqrt(2.0 * __PI)) - 0.5 * _lax.square((x - mu) / sigma) # pyright: ignore
|
43
43
|
|
44
44
|
|
45
45
|
def uprob(
|
bayinx/dists/uniform.py
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
import jax.lax as _lax
|
2
|
+
import jax.numpy as jnp
|
3
|
+
from jaxtyping import Array, ArrayLike, Float, Real
|
4
|
+
|
5
|
+
|
6
|
+
def prob(
|
7
|
+
x: Real[ArrayLike, "..."], lb: Real[ArrayLike, "..."], ub: Real[ArrayLike, "..."]
|
8
|
+
) -> Float[Array, "..."]:
|
9
|
+
"""
|
10
|
+
The probability density function (PDF) for a Uniform distribution.
|
11
|
+
|
12
|
+
# Parameters
|
13
|
+
- `x`: Value(s) at which to evaluate the PDF.
|
14
|
+
- `lb`: The lower bound parameter(s).
|
15
|
+
- `ub`: The upper bound parameter(s).
|
16
|
+
|
17
|
+
# Returns
|
18
|
+
The PDF evaluated at `x`. The output will have the broadcasted shapes of `x`, `lb`, and `ub`.
|
19
|
+
"""
|
20
|
+
|
21
|
+
return 1.0 / (ub - lb) # pyright: ignore
|
22
|
+
|
23
|
+
|
24
|
+
def logprob(
|
25
|
+
x: Real[ArrayLike, "..."], lb: Real[ArrayLike, "..."], ub: Real[ArrayLike, "..."]
|
26
|
+
) -> Float[Array, "..."]:
|
27
|
+
"""
|
28
|
+
The log of the probability density function (log PDF) for a Uniform distribution.
|
29
|
+
|
30
|
+
# Parameters
|
31
|
+
- `x`: Value(s) at which to evaluate the PDF.
|
32
|
+
- `lb`: The lower bound parameter(s).
|
33
|
+
- `ub`: The upper bound parameter(s).
|
34
|
+
|
35
|
+
# Returns
|
36
|
+
The log of the PDF evaluated at `x`. The output will have the broadcasted shapes of `x`, `lb`, and `ub`.
|
37
|
+
"""
|
38
|
+
|
39
|
+
return _lax.log(1.0) - _lax.log(ub - lb) # pyright: ignore
|
40
|
+
|
41
|
+
|
42
|
+
def uprob(
|
43
|
+
x: Real[ArrayLike, "..."], lb: Real[ArrayLike, "..."], ub: Real[ArrayLike, "..."]
|
44
|
+
) -> Float[Array, "..."]:
|
45
|
+
"""
|
46
|
+
The unnormalized probability density function (uPDF) for a Uniform distribution.
|
47
|
+
|
48
|
+
# Parameters
|
49
|
+
- `x`: Value(s) at which to evaluate the PDF.
|
50
|
+
- `lb`: The lower bound parameter(s).
|
51
|
+
- `ub`: The upper bound parameter(s).
|
52
|
+
|
53
|
+
# Returns
|
54
|
+
The uPDF evaluated at `x`. The output will have the broadcasted shapes of `x`, `lb`, and `ub`.
|
55
|
+
"""
|
56
|
+
|
57
|
+
return jnp.ones(jnp.broadcast_arrays(x,lb,ub))
|
58
|
+
|
59
|
+
|
60
|
+
def ulogprob(
|
61
|
+
x: Real[ArrayLike, "..."], lb: Real[ArrayLike, "..."], ub: Real[ArrayLike, "..."]
|
62
|
+
) -> Float[Array, "..."]:
|
63
|
+
"""
|
64
|
+
The log of the unnormalized probability density function (log uPDF) for a Uniform distribution.
|
65
|
+
|
66
|
+
# Parameters
|
67
|
+
- `x`: Value(s) at which to evaluate the PDF.
|
68
|
+
- `lb`: The lower bound parameter(s).
|
69
|
+
- `ub`: The upper bound parameter(s).
|
70
|
+
|
71
|
+
# Returns
|
72
|
+
The log uPDF evaluated at `x`. The output will have the broadcasted shapes of `x`, `lb`, and `ub`.
|
73
|
+
"""
|
74
|
+
|
75
|
+
return jnp.zeros(jnp.broadcast_arrays(x,lb,ub))
|
@@ -10,7 +10,8 @@ bayinx/dists/bernoulli.py,sha256=xMV9BgtVX_1XkPdZ43q0meMIEkgMyuUPx--dyo6_DKs,100
|
|
10
10
|
bayinx/dists/binomial.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
bayinx/dists/gamma.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
12
|
bayinx/dists/gamma2.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
|
-
bayinx/dists/normal.py,sha256=
|
13
|
+
bayinx/dists/normal.py,sha256=rtSDi0NAObH1LGRWiPZk_6cbSVv2dOPHkgxtWn6gFgM,2662
|
14
|
+
bayinx/dists/uniform.py,sha256=PSZIIc2QfNF5XYi-TLGltnr_vnAIA-MZsn1rKV8QXAo,2353
|
14
15
|
bayinx/mhx/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
15
16
|
bayinx/mhx/vi/__init__.py,sha256=YfkXKsqo9Dk_AmQGjZKm4vfG8eLer2ez92G-cOExphs,193
|
16
17
|
bayinx/mhx/vi/meanfield.py,sha256=LNLwfjKO9os7YBmRBpGEiFxlxonuN7DHVFEmXV3hvfI,3876
|
@@ -21,6 +22,6 @@ bayinx/mhx/vi/flows/fullaffine.py,sha256=2QbOtA1Jmu-yRcJeFmCKc8N1atm8G7JXYMLEZaE
|
|
21
22
|
bayinx/mhx/vi/flows/planar.py,sha256=qmtWpIBXRct2seI78pkmtF0X7cASUBELqmZmf2QS5Gs,1918
|
22
23
|
bayinx/mhx/vi/flows/radial.py,sha256=c-SWybGn_jmgBQk9ZMQ5uHKPzcdhowNp8MD8t1-8VZM,2501
|
23
24
|
bayinx/mhx/vi/flows/sylvester.py,sha256=ppK0BmS_ThvrCEhJiP_-p-kj67TQHSlU_RUZpDbIhsQ,469
|
24
|
-
bayinx-0.2.
|
25
|
-
bayinx-0.2.
|
26
|
-
bayinx-0.2.
|
25
|
+
bayinx-0.2.22.dist-info/METADATA,sha256=TwM3DxTXPTttN0TGJOPpM1pRMzDvoUjFZWkWWCR9vNI,3058
|
26
|
+
bayinx-0.2.22.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
27
|
+
bayinx-0.2.22.dist-info/RECORD,,
|
File without changes
|