CorrelatedContext#

class sdm.prior.CorrelatedContext(*, generator: Generator | None = None)#

Bases: object

Share sampling parameters within a scope.

Numerical samplers reuse Beta parameters. Correlated mixtures reuse selection probabilities. Values and selected items can still differ between draws. Keys share parameters only within the same kind of sampling operation.

Parameters:

generator (Generator | None) – Pseudorandom generator. Calls within the scope may omit it or pass the same object.

params(key: Hashable, size: tuple[int, ...]) → tuple[Tensor, Tensor]#

Return the shared Beta parameters for a numerical sampler.

Parameters:
  • key (Hashable) – Identity of the shared parameter set.

  • size (tuple[int, ...]) – Leading sample shape, excluding the final draw dimension.

Return type:

tuple[Tensor, Tensor]

mixture_weight(key: Hashable, weights: Tensor) → Tensor#

Return shared probabilities drawn from the mixture’s weights.

Samples w ~ Dirichlet(s * weight / mean(weight)) with \(s \sim \text{LogUniform}[0.1, 3]\) sampled once per key and shared across components.

Parameters:
  • key (Hashable) – Identity of the shared mixture probabilities.

  • weights (Tensor) – Tensor of relative weights with shape [K] for K options. Shared keys must keep their option order and weights.

Return type:

Tensor