| at_least_one | R Documentation |
Combines probabilities of multiple events assuming independence, using the formula P(A or B) = 1 - (1-P(A))*(1-P(B)). It matches dimensions automatically.
at_least_one(
mcmodule,
mc_names,
name = NULL,
all_suffix = NULL,
prefix = NULL,
summary = TRUE
)
mcmodule |
Module containing node list and input data frames |
mc_names |
Vector of node names to combine |
name |
Optional custom name for combined node (default: NULL) |
all_suffix |
Suffix for combined node name (default: "all") |
prefix |
Optional prefix for output node name (default: NULL) |
summary |
Whether to calculate summary statistics (default: TRUE) |
Updated mcmodule with new combined probability node
module <- list(
node_list = list(
p1 = list(
mcnode = mcstoc(runif,
min = mcdata(c(0.1, 0.2, 0.3), type = "0", nvariates = 3),
max = mcdata(c(0.2, 0.3, 0.4), type = "0", nvariates = 3),
nvariates = 3
),
data_name = "data_x",
keys = c("category")
),
p2 = list(
mcnode = mcstoc(runif,
min = mcdata(c(0.5, 0.6, 0.7), type = "0", nvariates = 3),
max = mcdata(c(0.6, 0.7, 0.8), type = "0", nvariates = 3),
nvariates = 3
),
data_name = "data_y",
keys = c("category")
)
),
data = list(
data_x = data.frame(
category = c("A", "B", "C"),
scenario_id = c("0", "0", "0")
),
data_y = data.frame(
category = c("B", "B", "B"),
scenario_id = c("0", "1", "2")
)
)
)
module <- at_least_one(module, c("p1", "p2"), name = "p_combined")
print(module$node_list$p_combined$summary)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.