version 3.22
This function acts as a DGS - Data Generating Structure for a certain SOP expression.
generate(expression, snames = "", noflevels)
expression |
String: a SOP - sum of products expression. | |||
snames |
A string containing the sets' names, separated by commas. | |||
noflevels |
Numerical vector containing the number of levels for each set. |
Using the power of SOP expressions, this function can generate the data for any type of expressions, either Boolean or multi-value.
Causal conditions should always be separated by a product sign
"*
", unless:
All conditions are considered binary crisp, unless the number of levels are
provided in conjunction with the set names, in the order of their specification from
the snames
argument.
This is an extension of the function expand()
,
the process of data generating process being essentially a Quine expansion to a Disjunctive
Normal Form.
generate("D + ~AB + B~C <=> Z")A B C D Z 1 0 0 0 0 0 2 0 0 0 1 1 3 0 0 1 0 0 4 0 0 1 1 1 5 0 1 0 0 1 6 0 1 0 1 1 7 0 1 1 0 1 8 0 1 1 1 1 9 1 0 0 0 0 10 1 0 0 1 1 11 1 0 1 0 0 12 1 0 1 1 1 13 1 1 0 0 1 14 1 1 0 1 1 15 1 1 1 0 0 16 1 1 1 1 1# same structure with different set names # (note the mandatory use of the product sign *) generate("Alpha + ~Beta*Gamma + Gamma*~Delta <=> Omicron")Alpha Beta Delta Gamma Omicron 1 0 0 0 0 0 2 0 0 0 1 1 3 0 0 1 0 0 4 0 0 1 1 1 5 0 1 0 0 0 6 0 1 0 1 1 7 0 1 1 0 0 8 0 1 1 1 0 9 1 0 0 0 1 10 1 0 0 1 1 11 1 0 1 0 1 12 1 0 1 1 1 13 1 1 0 0 1 14 1 1 0 1 1 15 1 1 1 0 1 16 1 1 1 1 1# Introducing an additional, irrelevant condition # note the product sign is not mandatory here setnames <- "Alpha, Beta, Gamma, Delta, Epsilon" dat <- generate("Alpha + ~BetaGamma + Gamma~Delta <=> Omicron", snames = setnames) head(dat)Alpha Beta Gamma Delta Epsilon Omicron 1 0 0 0 0 0 0 2 0 0 0 0 1 0 3 0 0 0 1 0 0 4 0 0 0 1 1 0 5 0 0 1 0 0 1 6 0 0 1 0 1 1minimize(dat, outcome = "Omicron")M1: Alpha + ~Beta*Gamma + Gamma*~Delta <=> Omicron