hyperiax.prebuilt.bffg.init_discrete_tree

hyperiax.prebuilt.bffg.init_discrete_tree(tree, leaf_obs, obs_var, *, d, root_val=None, anchor_init=None)[source]

Seed a discrete-edge BFFG tree with leaf observations and initial anchors.

Writes leaves’ canonical-form message (prec, ptnl, log_norm) from the isotropic-Gaussian likelihood \(y \sim \mathcal N(x, \tau^2 I)\) and seeds every node’s anchor (leaves at their observation, others at anchor_init). Optionally pins the root state.

Parameters:
  • tree (Tree) – Empty tree with the schema returned by discrete_schema().

  • leaf_obs (Array) – (n_leaves, d) leaf observations in BFS leaf order.

  • obs_var (float | Array) – Scalar observation variance \(\tau^2\).

  • d (int) – State dimension.

  • root_val (Array | None) – Optional (d,) value to pin at the root (writes the val field). Required by samplers that condition on a fixed root.

  • anchor_init (Array | None) – Optional (d,) initial anchor for non-leaf nodes (defaults to root_val if given, else zeros).

Return type:

Tree

Returns:

Tree with leaf canonical messages set, anchors seeded, and (optionally) the root pinned.