Build a transient model#

The modelling is based on the modeldag package.

Concept#

To generate data, the code reads model line-by-line and follows the instructions it contains.

In this SNeIa example, model contains 8 entries. So the generated data will contains at least 8 columns (see the as option).

model, param, as, input#

A model entry accepts 4 keywords:

  1. func: (name of) the function used to draw the sample, e.g. np.random.uniform ;

  2. kwargs: options that enter the function as kwargs , ‘@key’ could be used to get input as former entry result;

  3. as: (list of) name(s) of the column on the resulting data ;

“@” in “kwargs” to form a “DAG”#

The @ trick in kwargs enables you to generate self-consistent parameters.

For instance, the absolute magnitude of a SNeIa depends on its stretch and color (following the alpha*x_1 - beta*c Tripp’s relation). Hence, once the x_1and c (independent) variables have been drawn, the SNeIa absolute magnitude (magabs) can be obtained using as input the already drawn x_1 and c parameters. Same goes for the observed magnitude, it only dependents on the absolute magnitude magabs and the redshift z.

The (potentially complex) connections between the variables enabled by using @key (e.g. @c) corresponds to the creation a Directed acyclic graph. You can complexify your model creating as many variables and intermediate variables as you want.

the func option, where to define the function#

The func option is the function that will be used to generate the dataset. In principle, it should accept size as parameters and return N=size values except if a “@” is used in input (for its size is already defined by the initial called key)

In your model, the func option can be a function or a string.

  • a function will be used as such

  • a string will be converted in function, it typically means you input a method of the class ; though more advanced tools exist, see “Build a new Model” documentation.

See example in the Build a new Transient tutorial