ParameterSpec#

jeanspy.sampler_numpyro.ParameterSpec

See methods and properties for individual lookup pages, or the alphabetical API dictionary to search all classes. The full class contract and existing member anchors are retained below.

class jeanspy.sampler_numpyro.ParameterSpec(sample_name, distribution, param_name=None, transform=None, record_deterministic=None, deterministic_name=None)[source]#

Bases: object

Describe a parameter site and its physical representation.

Without param_name, transformed values keep the sample_name dictionary key and are recorded at sample_name + ‘_transformed’ to avoid a site collision.

Notes

Inputs and units. sample_name names a NumPyro sample site; distribution is a distribution or zero-argument factory; param_name names the physical parameter; transform is a callable; record_deterministic/deterministic_name control recorded transformed sites. exp and pow10 constructors set exponential/base-10 transforms.

Returns and shape. Specification object. build_distribution returns a NumPyro distribution; sample returns (physical_name, physical_value) and records its configured sample/deterministic sites.

Validity. Priors live in the sampled coordinate. Transforming the value does not turn a log-uniform prior into a uniform prior in physical units.

Errors. Invalid/duplicate names and inconsistent deterministic-site configuration raise.

Backend. NumPyro/JAX.

Differentiation. Transforms/distributions must support the intended JAX derivatives; discrete sample sites are not NUTS coordinates.

Examples. examples/docs_numpyro_inference.py

Parameters:
  • sample_name (str)

  • distribution (Any)

  • param_name (str | None)

  • transform (Callable[[Any], Any] | None)

  • record_deterministic (bool | None)

  • deterministic_name (str | None)

sample_name: str#
distribution: Any#
param_name: str | None = None#
transform: Callable[[Any], Any] | None = None#
record_deterministic: bool | None = None#
deterministic_name: str | None = None#
property records_deterministic: bool#

Whether this specification records a deterministic physical-parameter site.

An explicit deterministic_name enables recording; otherwise an explicit record_deterministic flag wins, then transform/renaming determines the default. Returns bool.

property resolved_deterministic_name: str#

Return the deterministic-site name without colliding with sample_name.

Explicit deterministic_name takes precedence, followed by param_name. If the inferred name equals sample_name, append _transformed. An explicit deterministic_name equal to sample_name raises ValueError.

classmethod exp(sample_name, distribution, *, param_name=None, deterministic_name=None)[source]#

Construct a specification whose physical value is exp(sample_value).

sample_name identifies the NumPyro site and distribution is its prior in natural-logarithmic coordinates. Optional param_name chooses the physical dictionary key; deterministic_name chooses the recorded physical site. Returns a ParameterSpec with deterministic recording enabled. The distribution is not a prior on the exponentiated value.

Parameters:
  • sample_name (str)

  • distribution (Any)

  • param_name (str | None)

  • deterministic_name (str | None)

Return type:

jeanspy.sampler_numpyro.ParameterSpec

classmethod pow10(sample_name, distribution, *, param_name=None, deterministic_name=None)[source]#

Construct a specification whose physical value is 10**sample_value.

sample_name identifies the NumPyro site and distribution is its prior in base-ten logarithmic coordinates. Optional param_name chooses the physical dictionary key; deterministic_name chooses the recorded physical site. Returns a ParameterSpec with deterministic recording enabled. The distribution is not a prior on the exponentiated value.

Parameters:
  • sample_name (str)

  • distribution (Any)

  • param_name (str | None)

  • deterministic_name (str | None)

Return type:

jeanspy.sampler_numpyro.ParameterSpec

build_distribution()[source]#

Resolve an existing distribution or call a zero-argument factory.

Returns the supplied NumPyro distribution unchanged, or the factory result. Factory exceptions propagate; downstream NumPyro execution checks whether the result is a usable distribution.

Return type:

Any

sample()[source]#

Create the NumPyro sample site and return its named physical value.

Returns (resolved parameter name, transformed value). The distribution is defined in sample coordinates; transform is then applied and, when configured, a deterministic site records the physical value. Execute under NumPyro inference or a seeded handler. Units/shapes follow the distribution and physical transform.

Return type:

tuple[str, Any]