sample_model_dep_random

pyoptex.utils.model.sample_model_dep_random(dep, size, n_samples=1, forced=None, mode=None)[source]

Sample a model given the dependency matrix of a fixed size. The terms are as follows:

  • First you uniformly sample any term.

  • Then you look at the necessary dependencies and add these one-by-one.

  • If multiple dependencies exist, you sample from them uniformly.

  • Go back to step one and continue until you sampled size terms.

Note

The mode must be weak heredity as of now.

Parameters

depnp.array(2d)

The dependency matrix of size (N, N) with N the number of terms in the encoded model (output from Y2X). Term i depends on term j if dep(i, j) = true.

sizeint

The size of the model to sample.

n_samplesint

The number of samples to draw.

forcednp.array(1d)

A model which must be included at all times.

modeNone or ‘weak’ or ‘strong’

The heredity mode during sampling.

Returns

modelnp.array(2d)

The sampled model which is an array of integers of size (n_samples, size).