bayinx 0.3.9__tar.gz → 0.3.10__tar.gz

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.
Files changed (41) hide show
  1. {bayinx-0.3.9 → bayinx-0.3.10}/PKG-INFO +1 -1
  2. {bayinx-0.3.9 → bayinx-0.3.10}/pyproject.toml +2 -2
  3. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/dists/censored/posnormal/r.py +39 -1
  4. {bayinx-0.3.9 → bayinx-0.3.10}/tests/test_predictive.py +2 -2
  5. {bayinx-0.3.9 → bayinx-0.3.10}/.github/workflows/release_and_publish.yml +0 -0
  6. {bayinx-0.3.9 → bayinx-0.3.10}/.gitignore +0 -0
  7. {bayinx-0.3.9 → bayinx-0.3.10}/LICENSE +0 -0
  8. {bayinx-0.3.9 → bayinx-0.3.10}/README.md +0 -0
  9. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/__init__.py +0 -0
  10. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/constraints/__init__.py +0 -0
  11. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/constraints/lower.py +0 -0
  12. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/core/__init__.py +0 -0
  13. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/core/_constraint.py +0 -0
  14. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/core/_flow.py +0 -0
  15. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/core/_model.py +0 -0
  16. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/core/_parameter.py +0 -0
  17. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/core/_variational.py +0 -0
  18. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/dists/__init__.py +0 -0
  19. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/dists/bernoulli.py +0 -0
  20. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/dists/censored/__init__.py +0 -0
  21. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/dists/censored/gamma2/__init__.py +0 -0
  22. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/dists/censored/gamma2/r.py +0 -0
  23. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/dists/censored/posnormal/__init__.py +0 -0
  24. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/dists/gamma2.py +0 -0
  25. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/dists/normal.py +0 -0
  26. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/dists/posnormal.py +0 -0
  27. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/dists/uniform.py +0 -0
  28. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/mhx/__init__.py +0 -0
  29. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/mhx/vi/__init__.py +0 -0
  30. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/mhx/vi/flows/__init__.py +0 -0
  31. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/mhx/vi/flows/fullaffine.py +0 -0
  32. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/mhx/vi/flows/planar.py +0 -0
  33. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/mhx/vi/flows/radial.py +0 -0
  34. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/mhx/vi/flows/sylvester.py +0 -0
  35. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/mhx/vi/meanfield.py +0 -0
  36. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/mhx/vi/normalizing_flow.py +0 -0
  37. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/mhx/vi/standard.py +0 -0
  38. {bayinx-0.3.9 → bayinx-0.3.10}/src/bayinx/py.typed +0 -0
  39. {bayinx-0.3.9 → bayinx-0.3.10}/tests/__init__.py +0 -0
  40. {bayinx-0.3.9 → bayinx-0.3.10}/tests/test_variational.py +0 -0
  41. {bayinx-0.3.9 → bayinx-0.3.10}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bayinx
3
- Version: 0.3.9
3
+ Version: 0.3.10
4
4
  Summary: Bayesian Inference with JAX
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.12
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "bayinx"
3
- version = "0.3.9"
3
+ version = "0.3.10"
4
4
  description = "Bayesian Inference with JAX"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -19,7 +19,7 @@ build-backend = "hatchling.build"
19
19
  addopts = "-q --benchmark-min-rounds=30 --benchmark-columns=rounds,mean,median,stddev --benchmark-group-by=func"
20
20
 
21
21
  [tool.bumpversion]
22
- current_version = "0.3.9"
22
+ current_version = "0.3.10"
23
23
  parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
24
24
  serialize = ["{major}.{minor}.{patch}"]
25
25
  search = "{current_version}"
@@ -1,5 +1,6 @@
1
1
  import jax.numpy as jnp
2
- from jaxtyping import Array, ArrayLike, Float
2
+ import jax.random as jr
3
+ from jaxtyping import Array, ArrayLike, Float, Key
3
4
 
4
5
  from bayinx.dists import posnormal
5
6
 
@@ -76,3 +77,40 @@ def logprob(
76
77
  evals = jnp.where(censored, posnormal.logccdf(x, mu, sigma), evals)
77
78
 
78
79
  return evals
80
+
81
+ def sample(
82
+ n: int,
83
+ mu: Float[ArrayLike, "..."],
84
+ sigma: Float[ArrayLike, "..."],
85
+ censor: Float[ArrayLike, "..."] = jnp.inf,
86
+ key: Key = jr.PRNGKey(0)
87
+ ) -> Float[Array, "..."]:
88
+ """
89
+ Sample from a right-censored positive Normal distribution.
90
+
91
+ # Parameters
92
+ - `n`: Number of draws to sample per-parameter.
93
+ - `mu`: The mean.
94
+ - `sigma`: The standard deviation.
95
+ - `censor`: The censor.
96
+
97
+ # Returns
98
+ Draws from a right-censored positive Normal distribution. The output will have the shape of (n,) + the broadcasted shapes of `mu`, `sigma`, and `censor`.
99
+ """
100
+ # Cast to Array
101
+ mu, sigma, censor = (
102
+ jnp.asarray(mu),
103
+ jnp.asarray(sigma),
104
+ jnp.asarray(censor),
105
+ )
106
+
107
+ # Derive shape
108
+ shape = (n,) + jnp.broadcast_shapes(mu.shape, sigma.shape, censor.shape)
109
+
110
+ # Draw from positive normal
111
+ draws = jr.truncated_normal(key, 0.0, jnp.inf, shape) * sigma + mu
112
+
113
+ # Censor values
114
+ draws = jnp.where(censor <= draws, censor, draws)
115
+
116
+ return draws
@@ -1,4 +1,4 @@
1
- from typing import Dict
1
+ from typing import Any, Dict
2
2
 
3
3
  import jax.numpy as jnp
4
4
  from jaxtyping import Array
@@ -32,7 +32,7 @@ def test_predictive():
32
32
  vari = Standard(model)
33
33
 
34
34
  # Posterior predictive function
35
- def extract_first_x(model: NormalDist) -> Array:
35
+ def extract_first_x(model: NormalDist, data: Any = None) -> Array:
36
36
  return model.x()[0]
37
37
 
38
38
  # Sample from posterior
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes