Skip to contents

Mirrors the C# Probability.JointProbability. The plain form dispatches on a dependency assumption alone ("independent" multiplies, "positive" takes the minimum, "negative" clamps the excess of the sum over 1). Passing indicators (a 0/1 flag per component, selecting which components participate) switches to the indicator-aware form; passing correlation too routes dependency = "correlation" through Haden Smith's modification of Pandey's Product-of-Conditional-Marginals method (HPCM).

Usage

joint_probability(
  p,
  dependency = c("independent", "positive", "negative", "correlation"),
  indicators = NULL,
  correlation = NULL
)

Arguments

p

numeric vector of marginal probabilities.

dependency

one of "independent" (default), "positive", "negative", "correlation". "correlation" requires both indicators and correlation – the underlying C# method itself returns NaN for that combination rather than raising an error, but this wrapper rejects it up front and names the missing argument(s), rather than handing back a silent NaN.

indicators

optional 0/1 vector, the same length as p.

correlation

optional length(p) by length(p) correlation matrix; requires indicators.

Value

a single numeric probability.

Examples

joint_probability(c(0.5, 0.5))
#> [1] 0.25
joint_probability(c(0.5, 0.5), dependency = "positive")
#> [1] 0.5