ForwardSampling.toarray

ForwardSampling.toarray(val=None)

Return the samples of variable <val>.

Parameters:

val (int | str | None) – Name or id of the variable.

Returns:

If val is given: 1-D array of N samples for that variable. If val is None: 2-D array of shape (N, nb_variables) where columns follow the insertion order of variables (same as CLG.nodes()). Use topandas() for named column access.

Return type:

np.ndarray

Example

import pyagrum as gum
import pyagrum.clg as gclg

gum.initRandom(42)  # the draws of pyagrum.clg come from the random generator of aGrUM
clg = gclg.SEM.toclg("""
A = 2[1]
B = 1 + 0.5A[2]
C = 3 + B[1]
""")
fs = gclg.ForwardSampling(clg).makeSample(100)
fs.toarray().shape  # one column per variable
# (100, 3)
fs.toarray("A").shape
# (100,)

Class

ForwardSampling