Learn R Programming

nuggets (version 2.0.1)

fire: Obtain truth-degrees of conditions

Description

Given a data frame or matrix of truth values for predicates, compute the truth values of a set of conditions expressed as elementary conjunctions.

Usage

fire(x, condition, t_norm = "goguen")

Value

A numeric matrix with entries in the interval \([0, 1]\) giving the truth degrees of the conditions. The matrix has nrow(x) rows and length(condition) columns. The element in row i and column j

corresponds to the truth degree of the j-th condition evaluated on the i-th row of x.

Arguments

x

A matrix or data frame containing predicate truth values. If x is a matrix, it must be numeric (double) or logical. If x is a data frame, all columns must be numeric (double) or logical.

condition

A character vector of conditions, each formatted according to format_condition(). For example, "{p1,p2,p3}" represents a condition composed of three predicates "p1", "p2", and "p3". Every predicate mentioned in condition must be present as a column in x.

t_norm

A string specifying the triangular norm (t-norm) used to compute conjunctions of predicate values. Must be one of "goedel" (minimum t-norm), "goguen" (product t-norm), or "lukas" (Łukasiewicz t-norm).

Author

Michal Burda

Details

Each element of condition must be a character string of the format "{p1,p2,p3}", where "p1", "p2", and "p3" are predicate names. The data object x must contain columns whose names correspond exactly to all predicates referenced in the conditions. Each condition is evaluated for every row of x as a conjunction of its predicates, with the conjunction operation determined by the t_norm argument. An empty condition ("{}") is always evaluated as 1 (i.e., fully true).

See Also

format_condition(), partition()

Examples

Run this code
d <- data.frame(
  a = c(1, 0.8, 0.5, 0.2, 0),
  b = c(0.5, 1, 0.5, 0, 1),
  c = c(0.9, 0.9, 0.1, 0.8, 0.7)
)

# Evaluate conditions with different t-norms
fire(d, c("{a,c}", "{}", "{a,b,c}"), t_norm = "goguen")
fire(d, c("{a,c}", "{a,b}"), t_norm = "goedel")
fire(d, c("{b,c}"), t_norm = "lukas")

Run the code above in your browser using DataLab