medil.sample.biadj

medil.sample.biadj(num_meas: int, density: float = 0.2, one_pure_child: bool = True, num_latent: int = 0, rng: numpy.random.Generator = numpy.random.default_rng) numpy.typing.NDArray[source]

Randomly generate a biadjacency matrix for a minimum MeDIL causal model.

Parameters:
  • num_meas (int) – Number of measurement (observed) variables.

  • density (float, optional) – Controls how many measurement variables share latent parents. 0 gives one latent per measurement (no sharing); 1 gives maximum sharing. Default 0.2.

  • one_pure_child (bool, optional) – If True (default), each latent variable has at least one measurement variable that it is the sole parent of (the one-pure-child assumption). If False, the graph is drawn from an Erdős–Rényi random graph over observed variables and the minimum edge clique cover is computed.

  • num_latent (int, optional) – Number of latent variables. Only used when one_pure_child=True. If 0 (default), drawn uniformly from [1, num_meas).

  • rng (numpy.random.Generator, optional) – Random number generator. Default is default_rng(0).

Returns:

biadj – Boolean biadjacency matrix where biadj[i, j] is True iff latent variable i is a parent of measurement variable j.

Return type:

ndarray of shape (num_latent, num_meas), dtype bool