Title: | Using the Theory of Belief Functions |
---|---|
Description: | Using the Theory of Belief Functions for evidence calculus. Basic probability assignments, or mass functions, can be defined on the subsets of a set of possible values and combined. A mass function can be extended to a larger frame. Marginalization, i.e. reduction to a smaller frame can also be done. These features can be combined to analyze small belief networks and take into account situations where information cannot be satisfactorily described by probability distributions. |
Authors: | Peiyuan Zhu [aut, cre], Claude Boivin [aut] |
Maintainer: | Peiyuan Zhu <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.8.0 |
Built: | 2025-01-15 07:01:58 UTC |
Source: | https://github.com/rapler/dst-1 |
Given a previously defined basic chance assignment (bca), the user may want to add some elements of the set of possible values or some subsets, even if they have zero mass value. This feature is useful, for example, to examine the measure of plausibility of these elements or subsets of zero mass value.
addTobca(x, tt, f)
addTobca(x, tt, f)
x |
A basic chance assignment (see |
tt |
A matrix constructed in a boolean style (0,1) or a boolean matrix. The number of columns of the matrix |
f |
Deprecated. Old name for |
x The original basic chance assignment x
augmented with the added subsets defined by tt
.
Claude Boivin
y <- bca(tt = matrix(c(1,0,0,1,1,1),nrow=2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), idvar = 1) addTobca(y, matrix(c(0,1,0,0,0,1, 0,1,1), nrow = 3, byrow = TRUE)) x <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow=3, byrow = TRUE), m=c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), idvar = 1) xy <- dsrwon(x,y) xy1 <- addTobca(nzdsr(xy), matrix(c(0,1,0,0,0,1), nrow = 2, byrow = TRUE)) xy1 # add all singletons to a bca addTobca(x, tt = diag(rep(1, ncol(x$tt) ) ) )
y <- bca(tt = matrix(c(1,0,0,1,1,1),nrow=2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), idvar = 1) addTobca(y, matrix(c(0,1,0,0,0,1, 0,1,1), nrow = 3, byrow = TRUE)) x <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow=3, byrow = TRUE), m=c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), idvar = 1) xy <- dsrwon(x,y) xy1 <- addTobca(nzdsr(xy), matrix(c(0,1,0,0,0,1), nrow = 2, byrow = TRUE)) xy1 # add all singletons to a bca addTobca(x, tt = diag(rep(1, ncol(x$tt) ) ) )
ads
: Relation between variables Arrival (A), Departure delay (D) and Sailing delay (S)This dataset is the tt
matrix establishing the relation A = D + S, where A = 0:6, D = 0:3 and S = 0:3. The subset made of all the triplets (a,d,s) of (A x D x S) where a = d + s is true has a mass value of 1. To construct the tt
matrix, we put the variables A, D, S side by side, as in a truth table representation. Each triplet of the subset is described by a row of the matrix as a vector of zeros and ones.
ads
ads
An integer matrix with 18 rows and 17 columns
value = 0, not used
Identification numbers of the three variables. Column 3 to 9: variable 1; column 10 to 13: variable 2; column 14 to 17: variable 3.
identification number of the specification
the value of the specification, a number between 0 and 1
1 if 6 is part of the specification, 0 otherwise
1 if 5 is part of the specification, 0 otherwise
1 if 4 is part of the specification, 0 otherwise
1 if 3 is part of the specification, 0 otherwise
1 if 2 is part of the specification, 0 otherwise
1 if 1 is part of the specification, 0 otherwise
1 if 0 is part of the specification, 0 otherwise
Claude Boivin, Stat.ASSQ
Almond, R.G. [1988] Fusion and Propagation in Graphical Belief Models. Computing Science and Statistics: Proceedings of the 20th Symposium on the Interface. Wegman, Edward J., Gantz, Donald T. and Miller, John J. (ed.). American Statistical Association, Alexandria, Virginia. pp 365–370.
Find upset, downset of a set among a lattice
arrow(x, M, method = NULL)
arrow(x, M, method = NULL)
x |
A binary vector encoding an element of a poset |
M |
Binary matrix encoding the lattice from which the supset or downset is found |
method |
Return supremum or infimum |
b Binary vector of sup or inf
Peiyuan Zhu
M <- matrix(c(0,1,1,1,1,1),nrow=2) x <- c(0,1,0) arrow(x,M,"up")
M <- matrix(c(0,1,1,1,1,1),nrow=2) x <- c(0,1,0) arrow(x,M,"up")
Function bca
is used to define subsets of a finite set of possible values and to assign their corresponding mass value.
The set is called the frame of discernment. Each subset
of
with a positive mass value is called a focal element or a proposition. The associated mass value is a number of the
(0,1]
interval, called "basic chance assignment" (the basic probability assignment of Shafer's book). All other subsets that have not received a positive mass value are assumed to have a mass value of zero.
bca( tt = NULL, m, qq = NULL, method = NULL, include_all = FALSE, cnames = NULL, con = NULL, ssnames = NULL, idvar = NULL, infovar = NULL, varnames = NULL, valuenames = NULL, inforel = NULL )
bca( tt = NULL, m, qq = NULL, method = NULL, include_all = FALSE, cnames = NULL, con = NULL, ssnames = NULL, idvar = NULL, infovar = NULL, varnames = NULL, valuenames = NULL, inforel = NULL )
tt |
Mandatory. A (0,1)-matrix or a boolean matrix. The number of columns must match the number of elements (values) of the frame of discernment |
m |
A numeric vector of length equal to the number of rows of the matrix |
qq |
Commonality functions from the frame of discernment to |
method |
= NULL: Use Fast Zeta Transform ("fzt") or Efficient Zeta Transform ("ezt") |
include_all |
= FALSE Put TRUE to include all elements with 0 mass in the bca. |
cnames |
A character vector containing the names of the elements of the frame of discernment |
con |
The measure of conflict can be provided. 0 by default. |
ssnames |
A list of subsets names which will be obtained from the column names of the tt matrix. |
idvar |
The number given to the variable. A number is necessary to manage relations between variables and make computations on a graph. 0 if omitted. |
infovar |
A two-column matrix containing variable identification numbers and the number of elements of the variable. Generated if omitted. |
varnames |
The name of the variable. Generated if omitted. |
valuenames |
A list of the names of the variables with the name of the elements of their frame of discernment. |
inforel |
Not used here. Defined within function |
There is two ways of defining the bca: a (0,1) matrix or a list of subsets labels.
y An object of class bcaspec
called a bca for "basic chance assignment":
tt The table of focal elements. Rownames of the matrix of focal elements are generated from the column names of the elements of the frame. See nameRows
for details.
qq Commonality functions from the frame of discernment to
spec A two column matrix. First column contains numbers given to the subsets, 1 to nrow(tt)
. Second column contains the mass values of the subsets.
con The measure of conflict.
infovar The number of the variable and the size of the frame of discernment.
varnames The name of the variable.
valuenames A list of length 1 consisting of the name of the variable with the names of the elements of the frame of discernment (the column names of the tt
matrix).
ssnames A list of subsets names done from the column names of the tt matrix.
inforel Set at 0. used in function bcaRel
.
Claude Boivin
Shafer, G., (1976). A Mathematical Theory of Evidence. Princeton University Press, Princeton, New Jersey, p. 38: Basic probability assignment.
Guan, J. W. and Bell, D. A., (1991). Evidence Theory and its Applications. Elsevier Science Publishing company inc., New York, N.Y., p. 29: Mass functions and belief functions
tt<- t(matrix(c(1,0,1,1),ncol = 2)) m<- c(.9,.1) cnames <- c("yes","no") bca(tt, m) bca(tt, m, cnames) tt1<- t(matrix(c(1,0,1,1),ncol = 2)) colnames(tt1) <- c("yes", "no") m <- c(.9, .1) bca(tt=tt1, m, idvar = 1) x <- bca(tt=matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), include_all = TRUE, cnames = c("a", "b", "c"), idvar = 1) y <- bca(tt=matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6,0.4), cnames = c("a", "b", "c"),varnames = "y", idvar = 1) vacuous <- bca(matrix(c(1,1,1), nrow = 1), m = 1, cnames = c("a","b","c"), ssnames = c("a","b","c"))
tt<- t(matrix(c(1,0,1,1),ncol = 2)) m<- c(.9,.1) cnames <- c("yes","no") bca(tt, m) bca(tt, m, cnames) tt1<- t(matrix(c(1,0,1,1),ncol = 2)) colnames(tt1) <- c("yes", "no") m <- c(.9, .1) bca(tt=tt1, m, idvar = 1) x <- bca(tt=matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), include_all = TRUE, cnames = c("a", "b", "c"), idvar = 1) y <- bca(tt=matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6,0.4), cnames = c("a", "b", "c"),varnames = "y", idvar = 1) vacuous <- bca(matrix(c(1,1,1), nrow = 1), m = 1, cnames = c("a","b","c"), ssnames = c("a","b","c"))
Computer norm between two basic chance assignment objects
bcaNorm(x, y, p = 1)
bcaNorm(x, y, p = 1)
x |
A bca to evaluate norm. |
y |
A bca to evaluate norm. |
p |
exponent parameter of the norm |
a number of norm evaluation
Peiyuan Zhu
y1 <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) y2 <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) y1y2<-dsrwon(y1,y2) bcaNorm(y1y2,y1)
y1 <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) y2 <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) y1y2<-dsrwon(y1,y2) bcaNorm(y1y2,y1)
tt
matrix and mass values of a basic chance assignment (bca)This utility function does a simple printing of a bca
bcaPrint(x)
bcaPrint(x)
x |
A list of class bcaspec. |
A table of subsets with their associated mass. Subsets are identified by row names.
Claude Boivin
z <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), idvar = 1) bcaPrint(z)
z <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), idvar = 1) bcaPrint(z)
Print summary statistics of large mass functions
bcaPrintLarge( x, info_list = "all", num_top_mass = 10, cut_width_size = 10, cut_width_m = 1e-05 )
bcaPrintLarge( x, info_list = "all", num_top_mass = 10, cut_width_size = 10, cut_width_m = 1e-05 )
x |
A basic chance assignment (see |
info_list |
="all" statistics to be printed in a vector of characters
|
num_top_mass |
= 10 number of top masses to be printed |
cut_width_size |
width of a cut among subset sizes |
cut_width_m |
width of a cut among masses |
table of basic and more comprehensive statistics of subsets
table of basic and more comprehensive statistics of masses
table of basic and more comprehensive statistics of masses vs subsets
Peiyuan Zhu
if (requireNamespace("tidyverse", quietly = TRUE) ) { ## library(tidyverse) x <- bca(tt = matrix(c(1,1,0,1,1,1), nrow = 2, byrow = TRUE), m = c(0.8, 0.2), cnames = c(1,2,3)) bcaPrintLarge(x) }
if (requireNamespace("tidyverse", quietly = TRUE) ) { ## library(tidyverse) x <- bca(tt = matrix(c(1,1,0,1,1,1), nrow = 2, byrow = TRUE), m = c(0.8, 0.2), cnames = c(1,2,3)) bcaPrintLarge(x) }
This function is used to represent a relation between two or more variables in their product space P
. The relation can be described by more than one subset of P
. Each subset can also include more than one element. Complete disjunctive coding is used to represent one element in the input matrix of the function.
bcaRel( tt, spec, infovar, varnames, valuenames, relnb = NULL, infovarnames, infovaluenames )
bcaRel( tt, spec, infovar, varnames, valuenames, relnb = NULL, infovarnames, infovaluenames )
tt |
The description matrix of the subsets establishing the relation. This matrix is obtained by putting the variables side by side, as in a truth table representation. For each variable, there are as many columns as possible values. Each row of the matrix is an element of a subset. Each element is described by a sequence of 0 (absence of value of a variable) or 1 (presence of value). This forms a complete disjunctive coding. CAUTION: Variables put side by side must be ordered by their *idvar* from left to right. |
spec |
A two column matrix. First column: numbers assigned to the sub-assemblies. Second column: the mass values of the sub-assemblies. If the subset has more than one element, the number of the subset and its associated mass value are repeated to match the number of elements in the subset. |
infovar |
A two column matrix containing variable identification numbers and the number of elements of each variable. The identification numbers must be ordered in increasing number. |
varnames |
The names of the variables. |
valuenames |
A list of the names of the variables with the name of the elements of their frame of discernment. |
relnb |
A number given to the relation. Set at 0 if omitted. |
infovarnames |
Deprecated. Old name for |
infovaluenames |
Deprecated. Old name for |
An object of class bcaspec
called a bca for "basic chance assignment". This is a list containing the following components:
con The measure of conflict.
tt The resulting table of subsets. Rownames of the matrix of subsets are generated from the column names of the elements of the product frame. See nameRows
for details.
spec The resulting two-column matrix of specification numbers with associated mass values.
infovar The two-column matrix of variables number and size given in the input data.
valuenames A list of the names of the variables with the name of the elements of their frame of discernment.
inforel A two-column matrix containing the relation number and the depth (number of variables) of the relation.
Claude Boivin
# A logical implication rule # A typical relation between two variables is the # logical implication a -> b. Let us suppose # that a stands for Rain: {yes, no} and b stands for # Roadworks: {yes, no}. From experience, # I am 75 % sure that there will be RoadWorks if there is no rain. # 1. The tt table of the logical implication ttrwf <- matrix(c(0,1,1,0,1,0,1,0,1,0,0,1,1,1,1,1), nrow = 4, byrow = TRUE, dimnames = list(NULL, c("rWdy", "rWdn", "Ry", "Rn")) ) # 2. The mass distribution specrw <- matrix(c(1,1,1,2,0.75,0.75,0.75,0.25), ncol = 2, dimnames = list(NULL, c("specnb", "mass"))) # 3. Variables numbers and sizes inforw <- matrix(c(4,5,2,2), ncol = 2, dimnames = list(NULL, c("varnb", "size")) ) bcaRel(tt = ttrwf, spec = specrw, infovar = inforw, varnames = c("RdWorks", "Rain"), relnb = 6)
# A logical implication rule # A typical relation between two variables is the # logical implication a -> b. Let us suppose # that a stands for Rain: {yes, no} and b stands for # Roadworks: {yes, no}. From experience, # I am 75 % sure that there will be RoadWorks if there is no rain. # 1. The tt table of the logical implication ttrwf <- matrix(c(0,1,1,0,1,0,1,0,1,0,0,1,1,1,1,1), nrow = 4, byrow = TRUE, dimnames = list(NULL, c("rWdy", "rWdn", "Ry", "Rn")) ) # 2. The mass distribution specrw <- matrix(c(1,1,1,2,0.75,0.75,0.75,0.25), ncol = 2, dimnames = list(NULL, c("specnb", "mass"))) # 3. Variables numbers and sizes inforw <- matrix(c(4,5,2,2), ncol = 2, dimnames = list(NULL, c("varnb", "size")) ) bcaRel(tt = ttrwf, spec = specrw, infovar = inforw, varnames = c("RdWorks", "Rain"), relnb = 6)
When working with large frames of discernment, the bca resulting of repeated application of Dempster's Rule of Combination can become big. One way to handle this situation could be to group subsets whose mass is less than a small treshold value. The function bcaTrunc
serves this purpose to reduce a large bca to its main elements.
bcaTrunc(x, seuil, use_ssnames = FALSE)
bcaTrunc(x, seuil, use_ssnames = FALSE)
x |
A bca to truncate. |
seuil |
A treshold value |
use_ssnames |
Put TRUE to use ssnames parameteer instead of description matrix. Default = FALSE. |
tr_x The bca object truncated.
Claude Boivin
x <- bca(tt = matrix(c(0,1,0,0, 0,0,1,1, 1,1,0,0, 1,0,1,0, 0,1,1,0, 1,1,1,1),ncol=4, byrow = TRUE), m = c(0.2, 0.5, 0.06, 0.04, 0.03, 0.17), cnames = c("a", "b", "c", "d")) bcaPrint(x) tr_x <- bcaTrunc(x, seuil = 0.1) bcaPrint(tr_x)
x <- bca(tt = matrix(c(0,1,0,0, 0,0,1,1, 1,1,0,0, 1,0,1,0, 0,1,1,0, 1,1,1,1),ncol=4, byrow = TRUE), m = c(0.2, 0.5, 0.06, 0.04, 0.03, 0.17), cnames = c("a", "b", "c", "d")) bcaPrint(x) tr_x <- bcaTrunc(x, seuil = 0.1) bcaPrint(tr_x)
Degrees of Belief Bel
and Plausibility Pl
of the focal elements of a bca are computed. The ratio of the plausibility of a focal element against the plausibility of its contrary is also computed. Subsets with zero mass can be excluded from the calculations.
belplau(x, remove = FALSE, h = NULL, method = NULL)
belplau(x, remove = FALSE, h = NULL, method = NULL)
x |
A basic chance assignment mass function (see |
remove |
= TRUE: Exclude subsets with zero mass. |
h |
= NULL: Hypothesis to be tested. Description matrix in the same format than |
method |
= NULL: Use Fast Zeta Transform ("fzt") or Efficient Zeta Transform ("ezt") or Efficient Zeta Transform on a meet-closed subset ("ezt-m") |
The degree of belief Bel
is defined by:
for every subset B of A.
The degree of plausibility pl
is defined by:
for every subset B
of the frame of discernment.
The plausibility ratio of a focal element A
versus its contrary not A
is defined by: .
A matrix of M
rows by 3 columns is returned, where M
is the number of focal elements:
Column 1: the degree of Belief bel
;
Column 2: the degree of Disbellief (belief in favor of the contrary hypothesis) disbel
;
Column 3: the degree of Epistemic uncertainty unc
;
Column 4: the degree of Plausibility plau
;
Column 5: the Plausibility ratio rplau
.
Claude Boivin, Peiyuan Zhu
Shafer, G., (1976). A Mathematical Theory of Evidence. Princeton University Press, Princeton, New Jersey, p. 39-43.
Williams, P., (1990). An interpretation of Shenoy and Shafer's axioms for local computation. International Journal of Approximate Reasoning 4, pp. 225-232.
x <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) belplau(x) y <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "y", idvar = 1) xy <- nzdsr(dsrwon(x,y)) belplau(xy) print("compare all elementary events") xy1 <- addTobca(x = xy, tt = matrix(c(0,1,0,0,0,1), nrow = 2, byrow = TRUE)) belplau(xy1) belplau(xy1, remove = TRUE) belplau(xy1, h = matrix(c(1,0,0,0,1,1), nrow = 2, byrow = TRUE))
x <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) belplau(x) y <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "y", idvar = 1) xy <- nzdsr(dsrwon(x,y)) belplau(xy) print("compare all elementary events") xy1 <- addTobca(x = xy, tt = matrix(c(0,1,0,0,0,1), nrow = 2, byrow = TRUE)) belplau(xy1) belplau(xy1, remove = TRUE) belplau(xy1, h = matrix(c(1,0,0,0,1,1), nrow = 2, byrow = TRUE))
Calculate error A, B, and total error A+B by comparing two vectors as defined below. One vector represents the truth and the other represents a numerical quantity of importance.
Error A: out of all the comparisons between two elements, what proportion of errors are due to indicating an irrelevant element as more important than a relevant element
Error B: out of all the comparisons between two elements, what proportion of errors are due to indicating a relevant element as less important than an irrelevant element
Total error A+B: the sum of quantity A and quantity B
belplauEval( belplau_mat, true_order, var = "rplau", err = "A", is_belplau = TRUE )
belplauEval( belplau_mat, true_order, var = "rplau", err = "A", is_belplau = TRUE )
belplau_mat |
belplau matrix e.g. belplau(bca) or a numerical vector quantifying order of importance of the elements of the frame. |
true_order |
a binary vector representing the truth. 1 means relevant and 0 means not relevant. |
var |
= "rplau" column name of the belplau matrix to be used as ordering. |
err |
= "A" kind of error to be evaluated. Can also take value "B" or "A+B". |
is_belplau |
= TRUE whether bel_plau is indeed a belplau matrix or just a numerical vector quantifying order of importance of elements. |
A number in of error A, B, or total error A+B.
Peiyuan Zhu
x <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) belplau(x) y <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "y", idvar = 1) xy <- nzdsr(dsrwon(x,y)) z<-belplau(xy,h=ttmatrixPartition(xy$infovar[2],xy$infovar[2])) belplauEval(z,c(0,1,0))
x <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) belplau(x) y <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "y", idvar = 1) xy <- nzdsr(dsrwon(x,y)) z<-belplau(xy,h=ttmatrixPartition(xy$infovar[2],xy$infovar[2])) belplauEval(z,c(0,1,0))
Calculate belief, disbelief, unknown, plausibility, plausibility ratio
belplauH(MACC, W2, h)
belplauH(MACC, W2, h)
MACC |
Vector of masses e.g. x$spec[,2] |
W2 |
Description matrix e.g. x$tt |
h |
H hypotheses to be tested, same format as x$tt |
A matrix of M
rows by 5 columns is returned, where M
is the number of hypothesis tested:
Column 1: the degree of Belief bel
;
Column 2: the degree of Disbellief (belief in favor of the contrary hypothesis) disbel
;
Column 3: the degree of Epistemic uncertainty unc
;
Column 4: the degree of Plausibility plau
;
Column 5: the Plausibility ratio rplau
.
Peiyuan Zhu
x <- bca(tt = matrix(c(1,1,0,1,1,1), nrow = 2, byrow = TRUE), m = c(0.8, 0.2), cnames = c(1,2,3)) belplauH(MACC = x$spec[,2], W2 = x$tt, h = x$tt) hyp <- matrix(c(0,1,0, 0,1,1), nrow = 2, byrow = TRUE) rownames(hyp) <- nameRows(hyp) belplauH(MACC = x$spec[,2], W2 = x$tt, h = hyp)
x <- bca(tt = matrix(c(1,1,0,1,1,1), nrow = 2, byrow = TRUE), m = c(0.8, 0.2), cnames = c(1,2,3)) belplauH(MACC = x$spec[,2], W2 = x$tt, h = x$tt) hyp <- matrix(c(0,1,0, 0,1,1), nrow = 2, byrow = TRUE) rownames(hyp) <- nameRows(hyp) belplauH(MACC = x$spec[,2], W2 = x$tt, h = hyp)
Calculate belief, disbelief, unknown, plausibility, plausibility ratio with logsumexp
belplauHLogsumexp(MACC, W2, h)
belplauHLogsumexp(MACC, W2, h)
MACC |
Vector of masses e.g. x$spec[,2] |
W2 |
Description matrix e.g. x$tt |
h |
Hypotheses to be tested, same format as x$tt |
A matrix of M
rows by 5 columns is returned, where M
is the number of hypothesis tested:
Column 1: the degree of Belief bel
;
Column 2: the degree of Disbellief (belief in favor of the contrary hypothesis) disbel
;
Column 3: the degree of Epistemic uncertainty unc
;
Column 4: the degree of Plausibility plau
;
Column 5: the Plausibility ratio rplau
.
Peiyuan Zhu
x <- bca(tt = matrix(c(1,1,0,1,1,1), nrow = 2, byrow = TRUE), m = c(0.8, 0.2), cnames = c(1,2,3)) belplauH(MACC = x$spec[,2], W2 = x$tt, h = x$tt) hyp <- matrix(c(0,1,0, 0,1,1), nrow = 2, byrow = TRUE) rownames(hyp) <- nameRows(hyp) belplauH(MACC = x$spec[,2], W2 = x$tt, h = hyp)
x <- bca(tt = matrix(c(1,1,0,1,1,1), nrow = 2, byrow = TRUE), m = c(0.8, 0.2), cnames = c(1,2,3)) belplauH(MACC = x$spec[,2], W2 = x$tt, h = x$tt) hyp <- matrix(c(0,1,0, 0,1,1), nrow = 2, byrow = TRUE) rownames(hyp) <- nameRows(hyp) belplauH(MACC = x$spec[,2], W2 = x$tt, h = hyp)
Degrees of Belief Bel
and Plausibility Pl
of the focal elements of a bca are computed. The ratio of the plausibility of a focal element against the plausibility of its contrary is also computed. Subsets with zero mass can be excluded from the calculations.
belplauLogsumexp(x, remove = FALSE, h = NULL, fzt = FALSE)
belplauLogsumexp(x, remove = FALSE, h = NULL, fzt = FALSE)
x |
A basic chance assignment mass function (see |
remove |
= TRUE: Exclude subsets with zero mass. |
h |
= NULL: Hypothesis to be tested. Description matrix in the same format than |
fzt |
= FALSE: Whether to use Fast Zeta Transform |
The degree of belief Bel
is defined by:
for every subset B of A.
The degree of plausibility pl
is defined by:
for every subset B
of the frame of discernment.
The plausibility ratio of a focal element A
versus its contrary not A
is defined by: .
A matrix of M
rows by 3 columns is returned, where M
is the number of focal elements:
Column 1: the degree of Belief bel
;
Column 2: the degree of Disbellief (belief in favor of the contrary hypothesis) disbel
;
Column 3: the degree of Epistemic uncertainty unc
;
Column 4: the degree of Plausibility plau
;
Column 5: the Plausibility ratio rplau
.
Claude Boivin, Peiyuan Zhu
Shafer, G., (1976). A Mathematical Theory of Evidence. Princeton University Press, Princeton, New Jersey, p. 39-43.
Williams, P., (1990). An interpretation of Shenoy and Shafer's axioms for local computation. International Journal of Approximate Reasoning 4, pp. 225-232.
x <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) belplau(x) y <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "y", idvar = 1) xy <- nzdsr(dsrwon(x,y)) belplau(xy) print("compare all elementary events") xy1 <- addTobca(x = xy, tt = matrix(c(0,1,0,0,0,1), nrow = 2, byrow = TRUE)) belplau(xy1) belplau(xy1, remove = TRUE) belplau(xy1, h = matrix(c(1,0,0,0,1,1), nrow = 2, byrow = TRUE))
x <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) belplau(x) y <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "y", idvar = 1) xy <- nzdsr(dsrwon(x,y)) belplau(xy) print("compare all elementary events") xy1 <- addTobca(x = xy, tt = matrix(c(0,1,0,0,0,1), nrow = 2, byrow = TRUE)) belplau(xy1) belplau(xy1, remove = TRUE) belplau(xy1, h = matrix(c(1,0,0,0,1,1), nrow = 2, byrow = TRUE))
Plot belplau matrix
belplauPlot( belplau_mat, xlab, color, y = "rplau", x = "index", levels = NULL, legend_title = "", main_title = "", is_log_scale = TRUE, is_negative = FALSE, is_factor = FALSE )
belplauPlot( belplau_mat, xlab, color, y = "rplau", x = "index", levels = NULL, legend_title = "", main_title = "", is_log_scale = TRUE, is_negative = FALSE, is_factor = FALSE )
belplau_mat |
Belplau matrix e.g. belplau(bpa) or a numerical vector quantifying order of importance of the elements of the frame |
xlab |
X-axis labels e.g. c("1:34","35:68","69:101") |
color |
Color of xlab e.g. c(0,1,0) |
y |
= "rplau": column name of belplau matrix. Ignore if it's not belplau matrix. |
x |
= "index": x-axis name |
levels |
= NULL: levels of color in order |
legend_title |
= "": title of legend |
main_title |
= "": main title |
is_log_scale |
= TRUE Whether to use log-scale |
is_negative |
= TRUE Whether to multiple by -1 |
is_factor |
= FALSE Whether to plot all x labels |
a plot of a column of the belplau matrix or a numerical vector quantifying order of importance of the elements of the frame
Peiyuan Zhu
bpa <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) bel_plau <- belplau(bpa) belplauPlot(bel_plau, c("a","b","c"), c(1,3,2))
bpa <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) bel_plau <- belplau(bpa) belplauPlot(bel_plau, c("a","b","c"), c(1,3,2))
Find inf, sup of a lattice
bound(x, method = NULL)
bound(x, method = NULL)
x |
Binary matrix encoding the lattice from which the supremum or infimum is found |
method |
Return supremum or infimum |
b Binary vector of sup or inf
Peiyuan Zhu
M <- matrix(c(0,1,1,1,1,1),nrow=2) x <- t(as.matrix(c(0,1,0))) bound(M,"inf")
M <- matrix(c(0,1,1,1,1,1),nrow=2) x <- t(as.matrix(c(0,1,0))) bound(M,"inf")
swr
: Result of the evaluation of the Hypergraph at node Arrival (A)This dataset is the tt
bca resulting from the combination of the relations of the hypergraph and marginalization at node Arrival (A).
captain_result
captain_result
A list of 8 elements, of class bcaspec.
Claude Boivin, Stat.ASSQ
Almond, R.G. [1988] Fusion and Propagation in Graphical Belief Models. Computing Science and Statistics: Proceedings of the 20th Symposium on the Interface. Wegman, Edward J., Gantz, Donald T. and Miller, John J. (ed.). American Statistical Association, Alexandria, Virginia. pp 365–370.
qq is the commonality function as a set function from the subsets of the frame to . To evaluate it, input a set encoded in binary vector, so the commonality number at that set can be returned.
commonality(tt, m, method = NULL)
commonality(tt, m, method = NULL)
tt |
Bolean description matrix |
m |
Mass assignment vector of probabilities |
method |
= NULL: Use Fast Zeta Transform ("fzt") or Efficient Zeta Transform ("ezt") or Efficient Zeta Transform on a join-closed subset ("ezt-j") |
f Commonality function
Peiyuan Zhu
x <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) qq <- commonality(x$tt,x$spec[,2]) qq(c(1,0,0))
x <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) qq <- commonality(x$tt,x$spec[,2]) qq(c(1,0,0))
The aplDecode
function of the project APL in R (https://rpubs.com/deleeuw/158476) has been adapted to follow the standard implementation of the APL decode
function.
decode(base, ind)
decode(base, ind)
base |
A scalar or a numeric vector which describes the number system in which the data is coded. |
ind |
The value to decode represented by a numeric vector in the |
If the base value is a number system, e.g. base 2, we need only to enter it as a scalar, which is then processed to match the length of the expression to decode. If length(ind)
is less than length(base)
, zeroes are added to the left of the vector ind
to match the length of the two vectors. And vice-versa.
A scalar representing the conversion of the coded number ind
to its decimal representation.
Claude Boivin
Jan de Leeuw and Masanao Yajima (March 07, 2016) APL in R (Version 009), Source code. https://rpubs.com/deleeuw/158476
L. Gilman and A. J. Rose.(1974): APL an Interactive Approach, Second Edition, John Wiley, New York.
APL 68000 Level II language manual. MicroAPL Ltd. 1990.
decode(c(2,2,2,2), c(1,0,1,1)) # Find the base 10 value of the base 2 number 1011. decode(2, c(1,0,1,1)) # left argument is extended to vector c(2,2,2,2) decode(c(365,24,60), c(2,1,57)) # transform 2 days 1 h 57 min in minutes decode(c(365,24,60), c(1,57)) # right vector extended decode(c(24,60), c(2,1,57)) # left vector extended decode(1.5, c(1,2,3)) # polynomial 1*x^2 +2*x +3 evaluated at x=1.5
decode(c(2,2,2,2), c(1,0,1,1)) # Find the base 10 value of the base 2 number 1011. decode(2, c(1,0,1,1)) # left argument is extended to vector c(2,2,2,2) decode(c(365,24,60), c(2,1,57)) # transform 2 days 1 h 57 min in minutes decode(c(365,24,60), c(1,57)) # right vector extended decode(c(24,60), c(2,1,57)) # left vector extended decode(1.5, c(1,2,3)) # polynomial 1*x^2 +2*x +3 evaluated at x=1.5
dlfm
: Relation between variables Departure delay (D), Loading delay (L), Forecast of the weather (F), Maintenance delay (M)This dataset is the tt
matrix establishing the relation between the four variables. Each event (loading = true, forecast = foul, Maintenance = true) adds one day of Departure Delay. The elements (d,l, f, m) of (D x L x F x M) satisfying the relation form a subset with a mass value of 1. To construct the tt
matrix, we put the variables D,L,F,M side by side, as in a truth table representation. Each 4-tuple of the subset is described by a row of the matrix as a vector of zeros and ones.
dlfm
dlfm
An integer matrix with 10 rows and 12 columns.
value = 0, not used
Identification numbers of the four variables. Column 3 to 6: variable 2; columns 7,8: variable 4; columns 9, 10: variable 5: columns 11,12: variable 6.
identification number of the specification
the value of the specification, a number between 0 and 1
1 if d3 is part of the specification, 0 otherwise
1 if d2 is part of the specification, 0 otherwise
1 if d1 is part of the specification, 0 otherwise
1 if d0 is part of the specification, 0 otherwise
1 if true is part of the specification, 0 otherwise
1 if false is part of the specification, 0 otherwise
1 if foul is part of the specification, 0 otherwise
1 if fair is part of the specification, 0 otherwise
Claude Boivin, Stat.ASSQ
Almond, R.G. [1988] Fusion and Propagation in Graphical Belief Models. Computing Science and Statistics: Proceedings of the 20th Symposium on the Interface. Wegman, Edward J., Gantz, Donald T. and Miller, John J. (ed.). American Statistical Association, Alexandria, Virginia. pp 365–370.
Construct subsets names from column names of a tt matrix
DoSSnames(tt)
DoSSnames(tt)
tt |
A description matrix with column names |
subsets_names A list of names.
Claude Boivin
y1 <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) DoSSnames(y1$tt)
y1 <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) DoSSnames(y1$tt)
The generalized inner product of two matrices combines two operators in the same manner as the classical inner product defined for the multiplication of two matrices. The number of rows of the second matrix must be equal the number of columns of the first matrix.
dotprod(x, y, g, f)
dotprod(x, y, g, f)
x |
A matrix of M rows by K columns. |
y |
A matrix of K rows by N columns. |
g |
Any operator: +, -, *, /, &, |, ==, <=, paste etc. |
f |
Any operator: +, -, *, /, &, |, ==, <=, paste etc. |
The result of the generalized inner product is returned.
Claude Boivin
print("Standard matrix product") x <- y <- matrix(c(1:6), nrow = 2, byrow = TRUE) dotprod(x, t(y), g = "+", f = "*") ## same as x %*% t(y) print("Find some data x2 in the rows of a larger matrix y2") x2 <- matrix(c(1,0,0,1,1,1), nrow = 2, byrow = TRUE) y2 <- matrix(c(1,0,0,0,1,0,1,1,0,0,1,1,1,1,1), nrow = 5, byrow = TRUE) (1:nrow(y2)) * dotprod(x2, t(y2), g = "&", f = "==") print("Find some names in a long list") team_names <- matrix(c("Patrick", "Dole", "Amanda", "Dole", "Robert", "Calvin", "Alvina", "Klein", "Robert", "Gariepy", "Nellie", "Arcand"), ncol = 2, byrow = TRUE) colnames(team_names) <- c("First_name", "Last_name") print("Where in the list are the person with first name Robert and where are the Doles?") BobandDoles <- matrix(c("Robert", "", "", "Dole"), ncol = 2, byrow = TRUE) dotprod(team_names, t(BobandDoles),g="|",f="==") * (1:nrow(team_names))
print("Standard matrix product") x <- y <- matrix(c(1:6), nrow = 2, byrow = TRUE) dotprod(x, t(y), g = "+", f = "*") ## same as x %*% t(y) print("Find some data x2 in the rows of a larger matrix y2") x2 <- matrix(c(1,0,0,1,1,1), nrow = 2, byrow = TRUE) y2 <- matrix(c(1,0,0,0,1,0,1,1,0,0,1,1,1,1,1), nrow = 5, byrow = TRUE) (1:nrow(y2)) * dotprod(x2, t(y2), g = "&", f = "==") print("Find some names in a long list") team_names <- matrix(c("Patrick", "Dole", "Amanda", "Dole", "Robert", "Calvin", "Alvina", "Klein", "Robert", "Gariepy", "Nellie", "Arcand"), ncol = 2, byrow = TRUE) colnames(team_names) <- c("First_name", "Last_name") print("Where in the list are the person with first name Robert and where are the Doles?") BobandDoles <- matrix(c("Robert", "", "", "Dole"), ncol = 2, byrow = TRUE) dotprod(team_names, t(BobandDoles),g="|",f="==") * (1:nrow(team_names))
Recursive function.
doubles(x)
doubles(x)
x |
A matrix of numeric, character or logical type. |
The submitted matrix with duplicated rows removed from.
Claude Boivin
td0 <- matrix(c(rep(c(1,0,1),times=3),0,0,1,1,1,1, 1,1,1),ncol = 3,byrow = TRUE) (doubles(td0)) td1 <- matrix(c(rep(c(1,0,1),times=3),0,0,1,1,1,1),ncol = 3,byrow = TRUE) (doubles(td1)) td2 <- matrix(c(1:3, 1:3,4:6,1:3),nrow = 4,byrow = TRUE) (doubles(td2)) td3 <- matrix(c("d","e","f", rep(c("a","b","cc"),times = 3),"g","h","i"),nrow = 5,byrow = TRUE) (doubles(td3)) td4 <- matrix(as.logical(td1),nrow = 5,byrow = TRUE) (doubles(td4))
td0 <- matrix(c(rep(c(1,0,1),times=3),0,0,1,1,1,1, 1,1,1),ncol = 3,byrow = TRUE) (doubles(td0)) td1 <- matrix(c(rep(c(1,0,1),times=3),0,0,1,1,1,1),ncol = 3,byrow = TRUE) (doubles(td1)) td2 <- matrix(c(1:3, 1:3,4:6,1:3),nrow = 4,byrow = TRUE) (doubles(td2)) td3 <- matrix(c("d","e","f", rep(c("a","b","cc"),times = 3),"g","h","i"),nrow = 5,byrow = TRUE) (doubles(td3)) td4 <- matrix(as.logical(td1),nrow = 5,byrow = TRUE) (doubles(td4))
The unnormalized Dempster's rule is used to combine two mass functions mx
and my
defined on the same frame of discernment and described by their respective basic chance assignments x
and y
. Dempster's rule of combination is applied. The normalization is not done, leaving the choice to the user to normalize the results or not (for the normalization operation, see function nzdsr
).
dsrwon( x, y, mcores = "no", use_ssnames = FALSE, use_qq = FALSE, method = NULL, varnames = NULL, relnb = NULL, skpt_tt = FALSE, infovarnames )
dsrwon( x, y, mcores = "no", use_ssnames = FALSE, use_qq = FALSE, method = NULL, varnames = NULL, relnb = NULL, skpt_tt = FALSE, infovarnames )
x |
A basic chance assignment (see |
y |
A basic chance assignment (see |
mcores |
Make use of multiple cores ("yes") or not ("no"). Default = "no". |
use_ssnames |
= TRUE to use ssnames instead of tt matrix to do the intersections. Default = FALSE |
use_qq |
= TRUE to use qq instead of tt matrix to do the intersections. Default = FALSE |
method |
= NULL |
varnames |
A character string to name the resulting variable. named "z" if omitted. |
relnb |
Identification number of the relation. Can be omitted. |
skpt_tt |
Skip reconstruction of tt matrix. Default = FALSE. |
infovarnames |
Deprecated. Old name for |
The calculations make use of multiple cores available.
The two bca's x
and y
must be defined on the same frame of discernment for the combination to take place. The relation number of the x input is given to the output result.
A basic chance assignment with these two components added:
I12 Intersection table of subsets.
Sort_order Sort order of subsets.
Claude Boivin, Peiyuan Zhu
Shafer, G., (1976). A Mathematical Theory of Evidence. Princeton University Press, Princeton, New Jersey, pp. 57-61: Dempster's rule of combination.
y1 <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) y2 <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) dsrwon(y1,y2) # Sparse matrices y1s <- y1 y2s <- y2 y1s$tt <- methods::as(y1$tt, "RsparseMatrix") y2s$tt <- methods::as(y2$tt, "RsparseMatrix") y1y2s <- dsrwon(y1s, y2s, use_ssnames = TRUE) # using commonalities bma <- bca(tt=matrix(c(1,1,0,1,rep(1,4)), ncol = 4, byrow = TRUE), m = c(0.1, 0.9), cnames = c("a", "b", "c", "d")) bma2 <- dsrwon(bma, bma, use_qq = TRUE) vacuous <- bca(matrix(c(1,1,1), nrow = 1), m = 1, cnames = c("a","b","c")) dsrwon(vacuous, vacuous)
y1 <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) y2 <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) dsrwon(y1,y2) # Sparse matrices y1s <- y1 y2s <- y2 y1s$tt <- methods::as(y1$tt, "RsparseMatrix") y2s$tt <- methods::as(y2$tt, "RsparseMatrix") y1y2s <- dsrwon(y1s, y2s, use_ssnames = TRUE) # using commonalities bma <- bca(tt=matrix(c(1,1,0,1,rep(1,4)), ncol = 4, byrow = TRUE), m = c(0.1, 0.9), cnames = c("a", "b", "c", "d")) bma2 <- dsrwon(bma, bma, use_qq = TRUE) vacuous <- bca(matrix(c(1,1,1), nrow = 1), m = 1, cnames = c("a","b","c")) dsrwon(vacuous, vacuous)
The unnormalized Dempster's rule is used to combine two mass functions mx
and my
defined on the same frame of discernment and described by their respective basic chance assignments x
and y
. Dempster's rule of combination is applied. The normalization is not done, leaving the choice to the user to normalize the results or not (for the normalization operation, see function nzdsr
).
dsrwonLogsumexp( x, y, mcores = "no", use_ssnames = FALSE, use_qq = FALSE, varnames = NULL, relnb = NULL, skpt_tt = FALSE, infovarnames )
dsrwonLogsumexp( x, y, mcores = "no", use_ssnames = FALSE, use_qq = FALSE, varnames = NULL, relnb = NULL, skpt_tt = FALSE, infovarnames )
x |
A basic chance assignment (see |
y |
A basic chance assignment (see |
mcores |
Make use of multiple cores ("yes") or not ("no"). Default = "no". |
use_ssnames |
= TRUE to use ssnames instead of tt matrix to do the intersections. Default = FALSE |
use_qq |
= TRUE to use qq instead of tt matrix to do the intersections. Default = FALSE |
varnames |
A character string to name the resulting variable. named "z" if omitted. |
relnb |
Identification number of the relation. Can be omitted. |
skpt_tt |
Skip reconstruction of tt matrix. Default = FALSE. |
infovarnames |
Deprecated. Old name for |
The calculations make use of multiple cores available.
The two bca's x
and y
must be defined on the same frame of discernment for the combination to take place. The relation number of the x input is given to the output result.
A basic chance assignment with these two components added:
I12 Intersection table of subsets.
Sort_order Sort order of subsets.
Claude Boivin, Peiyuan Zhu
Shafer, G., (1976). A Mathematical Theory of Evidence. Princeton University Press, Princeton, New Jersey, pp. 57-61: Dempster's rule of combination.
y1 <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) y2 <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) dsrwonLogsumexp(y1,y2) # Sparse matrices y1s <- y1 y2s <- y2 y1s$tt <- methods::as(y1$tt, "RsparseMatrix") y2s$tt <- methods::as(y2$tt, "RsparseMatrix") y1y2s <- dsrwonLogsumexp(y1s, y2s, use_ssnames = TRUE) vacuous <- bca(matrix(c(1,1,1), nrow = 1), m = 1, cnames = c("a","b","c")) dsrwonLogsumexp(vacuous, vacuous)
y1 <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) y2 <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) dsrwonLogsumexp(y1,y2) # Sparse matrices y1s <- y1 y2s <- y2 y1s$tt <- methods::as(y1$tt, "RsparseMatrix") y2s$tt <- methods::as(y2$tt, "RsparseMatrix") y1y2s <- dsrwonLogsumexp(y1s, y2s, use_ssnames = TRUE) vacuous <- bca(matrix(c(1,1,1), nrow = 1), m = 1, cnames = c("a","b","c")) dsrwonLogsumexp(vacuous, vacuous)
This function works on a relation defined on a product of two variables or more. Having fixed a variable to eliminate from the relation, the reduced product space is determined and the corresponding reduced bca is computed.This operation is also called "marginalization".
elim(rel, xnb)
elim(rel, xnb)
rel |
The relation to reduce, an object of class bcaspec. |
xnb |
Identification number of the variable to eliminate. |
r The reduced relation
Claude Boivin
# We construct a relation between two variables to show marginalization. wr_tt <- matrix(c(1,rep(0,3),rep(c(1,0),3),0,1,1,1,0,0, 1,0,rep(1,5),0,1,1,0,rep(1,5)), ncol = 4, byrow = TRUE) colnames(wr_tt) <- c("Wy Ry", "Wy Rn", "Wn Ry", "Wn Rn") rownames(wr_tt) <- nameRows(wr_tt) wr_spec = matrix(c(1:8, 0.017344, 0.046656, 0.004336, 0.199456,0.011664,0.536544,0.049864, 0.134136), ncol = 2, dimnames = list(NULL, c("specnb", "mass"))) wr_infovar = matrix(c(4,5,2,2), ncol = 2, dimnames = list(NULL, c("varnb", "size")) ) wr_rel <- list(tt = wr_tt, con = 0.16, spec=wr_spec, infovar = wr_infovar, varnames = c("Roadworks","Rain"), valuenames = list( RdWorks = c("Wy", "Wn"), Rain=c("Ry", "Rn") )) class(wr_rel) <- "bcaspec" bcaPrint(elim(wr_rel, xnb = 5)) bcaPrint(elim(wr_rel, xnb = 4))
# We construct a relation between two variables to show marginalization. wr_tt <- matrix(c(1,rep(0,3),rep(c(1,0),3),0,1,1,1,0,0, 1,0,rep(1,5),0,1,1,0,rep(1,5)), ncol = 4, byrow = TRUE) colnames(wr_tt) <- c("Wy Ry", "Wy Rn", "Wn Ry", "Wn Rn") rownames(wr_tt) <- nameRows(wr_tt) wr_spec = matrix(c(1:8, 0.017344, 0.046656, 0.004336, 0.199456,0.011664,0.536544,0.049864, 0.134136), ncol = 2, dimnames = list(NULL, c("specnb", "mass"))) wr_infovar = matrix(c(4,5,2,2), ncol = 2, dimnames = list(NULL, c("varnb", "size")) ) wr_rel <- list(tt = wr_tt, con = 0.16, spec=wr_spec, infovar = wr_infovar, varnames = c("Roadworks","Rain"), valuenames = list( RdWorks = c("Wy", "Wn"), Rain=c("Ry", "Rn") )) class(wr_rel) <- "bcaspec" bcaPrint(elim(wr_rel, xnb = 5)) bcaPrint(elim(wr_rel, xnb = 4))
The aplEncode
function of the project APL in R (https://rpubs.com/deleeuw/158476) has been adapted to follow the standard implementation of the APL encode
function.
encode(base, ind)
encode(base, ind)
base |
A numeric vector which describes the number system in which we want to recode the data. |
ind |
The value to convert represented by a number or a numeric vector. |
A vector or a matrix of the data converted.
Claude Boivin
Jan de Leeuw and Masanao Yajima (March 07, 2016) APL in R (Version 009), Source code. https://rpubs.com/deleeuw/158476
L. Gilman and A. J. Rose.(1974): APL an Interactive Approach, Second Edition, John Wiley, New York.
APL 68000 Level II language manual. MicroAPL Ltd. 1990.
encode(c(2,2,2,2), 11) # find the base 2 representation of number 11 encode(c(365,24,60), 2997) # convert 2997 minutes to days-hrs-min.
encode(c(2,2,2,2), 11) # find the base 2 representation of number 11 encode(c(365,24,60), 2997) # convert 2997 minutes to days-hrs-min.
This function works on a basic chance assignment (bca) x
defined on a single variable. Iy= t Allows the addition of new values to the frame of discernment.
extFrame(x, use_ssnames = FALSE, lab = NULL)
extFrame(x, use_ssnames = FALSE, lab = NULL)
x |
An object of bca class, i.e. a basic chance assignment defined on one variable |
use_ssnames |
Default= FALSE. Put TRUE if use of subset names is wanted. |
lab |
A character vector containing the names of the elements to add to the frame of discernment. |
zxtnd The bca with its frame extended
Claude Boivin
s1_e1 <- bca(tt = matrix(c(1,0,1,1),nrow = 2, byrow = TRUE), m = c(0.6,0.4), cnames = c("S1","S2"), varnames = "v1", idvar = 1) s13_names <- extFrame(s1_e1, lab = "S3", use_ssnames =TRUE) s13 <- extFrame(s1_e1, lab = "S3")
s1_e1 <- bca(tt = matrix(c(1,0,1,1),nrow = 2, byrow = TRUE), m = c(0.6,0.4), cnames = c("S1","S2"), varnames = "v1", idvar = 1) s13_names <- extFrame(s1_e1, lab = "S3", use_ssnames =TRUE) s13 <- extFrame(s1_e1, lab = "S3")
This function works on a basic chance assignment (bca) x
defined on a single variable or more. A relation of reference is given, and an extension of the space of x
is made to the larger product space of the relation of reference. The basic chance assignment to extend and the relation of reference must have at least one common variable for the extension to occur.
extmin(rel1, relRef)
extmin(rel1, relRef)
rel1 |
An object of class bcaspec, i.e. a basic chance assignment defined on one variable or a relation. |
relRef |
The relation of reference. It can be an existing relation, or it can be constructed as a vacuous function. |
The relRef
parameter is used to extract all the information on the variables, namely their identification numbers and the number of elements of each variable, variables names and columns names of the tt
matrix. The relation of reference relRef
may be a relation already existing or simply the the vacuous relation defined on the product set of variables of interest.
the resulting extended bca.
Claude Boivin
G. Shafer and P. P. Shenoy. Local Computations in Hypertrees. School of Business, University of Kansas, Lawrence, KS, 1991. See p. 78, vacuous extension of a belief function.
# Making a vacuous reference relation and extending a bca to its space. init_tt = matrix(rep(1,10),nrow = 1, dimnames = list(NULL, c("3", "2", "1", "0", "true", "false", "foul", "fair", "true", "false")) ) init_spec <- matrix(c(1,1), ncol = 2, dimnames = list(NULL, c("specnb", "mass"))) init_info <- matrix(c(3,4,7,8,4,2,2,2), ncol = 2, dimnames = list(NULL, c("varnb", "size")) ) relRef <- bcaRel(tt = init_tt, spec = init_spec, infovar = init_info, varnames = c("Sail", "Loading", "Weather", "Repairs"), relnb = 0) # a bcaspec defined on one variable l_rel <- bca(tt = matrix(c(1,0,1,0,1,1), ncol = 2), m = c(0.3,0.5,0.2), cnames = c("true", "false"), infovar = matrix(c(4,2), ncol = 2, dimnames = list(NULL, c("varnb", "size"))), varnames = c("Loading"), inforel = matrix(c(7,1), ncol = 2, dimnames = list(NULL, c("relnb", "depth")))) z <- extmin(l_rel, relRef) prmatrix(t(z$tt), collab = rep("", nrow(z$tt)))
# Making a vacuous reference relation and extending a bca to its space. init_tt = matrix(rep(1,10),nrow = 1, dimnames = list(NULL, c("3", "2", "1", "0", "true", "false", "foul", "fair", "true", "false")) ) init_spec <- matrix(c(1,1), ncol = 2, dimnames = list(NULL, c("specnb", "mass"))) init_info <- matrix(c(3,4,7,8,4,2,2,2), ncol = 2, dimnames = list(NULL, c("varnb", "size")) ) relRef <- bcaRel(tt = init_tt, spec = init_spec, infovar = init_info, varnames = c("Sail", "Loading", "Weather", "Repairs"), relnb = 0) # a bcaspec defined on one variable l_rel <- bca(tt = matrix(c(1,0,1,0,1,1), ncol = 2), m = c(0.3,0.5,0.2), cnames = c("true", "false"), infovar = matrix(c(4,2), ncol = 2, dimnames = list(NULL, c("varnb", "size"))), varnames = c("Loading"), inforel = matrix(c(7,1), ncol = 2, dimnames = list(NULL, c("relnb", "depth")))) z <- extmin(l_rel, relRef) prmatrix(t(z$tt), collab = rep("", nrow(z$tt)))
fw
: Relation between variables Forecast of the weather (F) and Weather at sea (W)This dataset is the tt
matrix establishing the relation between the two variables. An accurate forecast is described by this subset of two event: (Forecast = foul, Weather = foul) and (Forecast = fair, Weather = fair). We assign a mass value of 0.8 to this subset. The remaining mass of 0.2 is allotted to the frame. To construct the tt
matrix, we put the variables F and W side by side, as in a truth table representation. Each pair of the subset is described by a row of the matrix as a vector of zeros and ones.
fw
fw
An integer matrix with 4 rows and 6 columns.
value = 0, not used
Identification numbers of the two variables. Column 3,6: variable 5; columns 5,6: variable 7.
identification number of the specification
the value of the specification, a number between 0 and 1
1 if foul is part of the specification, 0 otherwise
1 if fair is part of the specification, 0 otherwise
Claude Boivin
Almond, R.G. [1988] Fusion and Propagation in Graphical Belief Models. Computing Science and Statistics: Proceedings of the 20th Symposium on the Interface. Wegman, Edward J., Gantz, Donald T. and Miller, John J. (ed.). American Statistical Association, Alexandria, Virginia. pp 365–370.
Function inters
returns a table of the intersection between two (0,1) or boolean matrices or two vectors. The two matrices must have the same number of columns. The two vectors must be of the same length. This function generalizes the intersection of two subsets represented by boolean vectors to the intersection of two matrices of subsets.
inters(x, y)
inters(x, y)
x |
A (0,1)-matrix or a boolean matrix of M rows by K columns, or a vector of length K. |
y |
A (0,1)-matrix or a boolean matrix of N rows by K columns or a vector of length K. |
The result is a (0,1)-table of dimensions (M x K) x N). In the case of vectors, the result is a (0,1)-table of dimensions (1 x K) x 1)
Claude Boivin
mx <- matrix(c(0,1,0,0,1,1,1,1,1),nrow = 3, byrow = TRUE, dimnames = list(NULL, c("a", "b", "c"))) rownames(mx) <- nameRows(mx) my<-matrix(c(0,0,1,1,1,1),nrow = 2, byrow = TRUE, dimnames = list(NULL, c("a", "b", "c"))) rownames(my) <- nameRows(my) inters(mx,my) b1 <- matrix(c(FALSE, TRUE, TRUE), nrow=1) b2 <- matrix(c(TRUE, TRUE, FALSE), nrow=1) colnames(b1) <- colnames(b2) <- c("c1","c2","c3") inters(b1,b2) x3<-matrix(c(1,1,0,1), ncol = 2, dimnames = list(NULL, c("a","b"))) y3<-matrix(c(0,1,1,1), ncol = 2, dimnames = list(NULL, c("a","b"))) inters(x3,y3) x4 <-matrix(c(1,0,1,1,1,1,1,1),nrow = 2, byrow = TRUE, dimnames = list(NULL, c("a", "b", "c","d"))) y4 <-matrix(c(1,0,0,1,1,1,1,1),nrow = 2, byrow = TRUE, dimnames = list(NULL, c("a", "b", "c","d"))) inters(x4,y4) # Sparse matrices stt1 <- Matrix::sparseMatrix(i= c(1,1,2,2,3,3,3), j= c(2,3,1,2,1,2,3), x = 1, dims = c(3,3)) y1 <- bca(tt = stt1, m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) stt2 <- Matrix::sparseMatrix(i= c(1,2,2,2), j= c(1,1,2,3), x = 1, dims = c(2,3)) y2 <- bca(tt = stt2, m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) sr <-inters(y1$tt, y2$tt) sr class(sr)
mx <- matrix(c(0,1,0,0,1,1,1,1,1),nrow = 3, byrow = TRUE, dimnames = list(NULL, c("a", "b", "c"))) rownames(mx) <- nameRows(mx) my<-matrix(c(0,0,1,1,1,1),nrow = 2, byrow = TRUE, dimnames = list(NULL, c("a", "b", "c"))) rownames(my) <- nameRows(my) inters(mx,my) b1 <- matrix(c(FALSE, TRUE, TRUE), nrow=1) b2 <- matrix(c(TRUE, TRUE, FALSE), nrow=1) colnames(b1) <- colnames(b2) <- c("c1","c2","c3") inters(b1,b2) x3<-matrix(c(1,1,0,1), ncol = 2, dimnames = list(NULL, c("a","b"))) y3<-matrix(c(0,1,1,1), ncol = 2, dimnames = list(NULL, c("a","b"))) inters(x3,y3) x4 <-matrix(c(1,0,1,1,1,1,1,1),nrow = 2, byrow = TRUE, dimnames = list(NULL, c("a", "b", "c","d"))) y4 <-matrix(c(1,0,0,1,1,1,1,1),nrow = 2, byrow = TRUE, dimnames = list(NULL, c("a", "b", "c","d"))) inters(x4,y4) # Sparse matrices stt1 <- Matrix::sparseMatrix(i= c(1,1,2,2,3,3,3), j= c(2,3,1,2,1,2,3), x = 1, dims = c(3,3)) y1 <- bca(tt = stt1, m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) stt2 <- Matrix::sparseMatrix(i= c(1,2,2,2), j= c(1,1,2,3), x = 1, dims = c(2,3)) y2 <- bca(tt = stt2, m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) sr <-inters(y1$tt, y2$tt) sr class(sr)
Intersect two vectors of ssnames
intersBySSName(zx, yz)
intersBySSName(zx, yz)
zx |
a vector of ssnames from one bca |
yz |
a vector of ssnames from another bca |
ssnames in the intersection of the two bcas
Peiyuan Zhu
y1 <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) y2 <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) intersBySSName(y1$ssnames[[1]], y2$ssnames[[2]])
y1 <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) y2 <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) intersBySSName(y1$ssnames[[1]], y2$ssnames[[2]])
Adding small probabilities
logsum(l1, l2)
logsum(l1, l2)
l1 |
log probabilities |
l2 |
log probabilities |
sum of probabilities exp(l1)+exp(l2)
Peiyuan Zhu
# sum of two 1e-5 exp(logsum(log(1e-5),log(1e-5)))
# sum of two 1e-5 exp(logsum(log(1e-5),log(1e-5)))
The array representation or product space representation is converted to the matrix representation of the corresponding relation.
marrayToMatrix(mtt)
marrayToMatrix(mtt)
mtt |
The matrix |
The matrix representation of the data.
Claude Boivin
mtt <- array(c(1,0,0,0,1,1,0,0,1,0,0,1,1,0,1,0,1,1,0,1,1,1,1,0,1,0,1,1,1,1,1,1), c(2,2,8), dimnames = list( RdWorks=c("Wy", "Wn") , Rain = c("Ry", "Rn"), ev=1:8) ) print(z <- marrayToMatrix(mtt))
mtt <- array(c(1,0,0,0,1,1,0,0,1,0,0,1,1,0,1,0,1,1,0,1,1,1,1,0,1,0,1,1,1,1,1,1), c(2,2,8), dimnames = list( RdWorks=c("Wy", "Wn") , Rain = c("Ry", "Rn"), ev=1:8) ) print(z <- marrayToMatrix(mtt))
The matrix representation of a relation is converted to the array representation or product space representation.
matrixToMarray(tt, valuenames)
matrixToMarray(tt, valuenames)
tt |
A (0,1)-matrix or a boolean matrix establishing the relation between two or more variables. The matrix is constructed by placing the variables side by side, as in a truth table representation. |
valuenames |
A list of the names of the variables with the name of each value of their frame of discernment. |
mtt The array (product space) representation of the tt
matrix.
Claude Boivin
# Define wr_tt, a matrix describing the relation between two variables wr_tt <- matrix(c(1,rep(0,3),rep(c(1,0),3),0,1,1,1,0,0, 1,0,rep(1,5),0,1,1,0,rep(1,5)), ncol=4, byrow = TRUE) colnames(wr_tt) <- c("Wy Ry", "Wy Rn", "Wn Ry", "Wn Rn") rownames(wr_tt) <- nameRows(wr_tt) vars = list( RdWorks = c("Wy", "Wn") , Rain = c("Ry", "Rn")) print(zmToa <- matrixToMarray(tt = wr_tt, valuenames = vars ) )
# Define wr_tt, a matrix describing the relation between two variables wr_tt <- matrix(c(1,rep(0,3),rep(c(1,0),3),0,1,1,1,0,0, 1,0,rep(1,5),0,1,1,0,rep(1,5)), ncol=4, byrow = TRUE) colnames(wr_tt) <- c("Wy Ry", "Wy Rn", "Wn Ry", "Wn Rn") rownames(wr_tt) <- nameRows(wr_tt) vars = list( RdWorks = c("Wy", "Wn") , Rain = c("Ry", "Rn")) print(zmToa <- matrixToMarray(tt = wr_tt, valuenames = vars ) )
Construct m vector of a bca from marginal probabilities
mFromMarginal( marg_probs, a = 1e-05, simple = FALSE, min_prob = 0, max_prob = 2 )
mFromMarginal( marg_probs, a = 1e-05, simple = FALSE, min_prob = 0, max_prob = 2 )
marg_probs |
vector of marginal probabilities |
a |
=1e-5 probability that the sample is reliable |
simple |
=TRUE whether to use simple support function |
min_prob |
=0 lower bound on marginal probabilities |
max_prob |
=2 upper bound on marginal probabilities |
vector of probability masses obtained from uniformly sampling the cut
Peiyuan Zhu
x <- c(2,2,1.5,1.2,1,0,0) mFromMarginal(x, simple=FALSE)
x <- c(2,2,1.5,1.2,1,0,0) mFromMarginal(x, simple=FALSE)
Construct a mass vector from qq function and ttmatrix of focal elements recursively.
mFromQQ(qq, n, cnames, method = NULL)
mFromQQ(qq, n, cnames, method = NULL)
qq |
Commonality function |
n |
Frame dimension |
method |
= NULL: Use Fast Mobius Transform ("fmt") or Efficient Mobius Transform ("emt") or Efficient Mobius Transform on a meet-closed subset ("emt-m") |
cnames: |
A character vector containing the names of the elements of the frame of discernment |
m A corresponding mass vector
Peiyuan Zhu
tt<- t(matrix(c(1,0,1,1),ncol = 2)) m<- c(.9,.1) cnames <- c("yes","no") x<- bca(tt, m, cnames=cnames) mFromQQ(x$qq, 2, method = "fmt", cnames = cnames)
tt<- t(matrix(c(1,0,1,1),ncol = 2)) m<- c(.9,.1) cnames <- c("yes","no") x<- bca(tt, m, cnames=cnames) mFromQQ(x$qq, 2, method = "fmt", cnames = cnames)
mrf
: Relation between variables No Maintenance (M = false) and Repairs at sea (R)This dataset is the tt
matrix establishing a set of two relations between the two variables. First, Repairs = true if Maintenance = false in (M x R). We are 20% sure that there will be Repairs if no maintenance. Second, Repairs = false if Maintenance = false in (M x R). We are 20% sure that there will be no repairs if no maintenance.
mrf
mrf
A (0,1) matrix with 4 rows and 6 columns.
value = 0, not used
Identification numbers of the two variables. Column 3,4: variable 6; columns 5,6: variable 8
identification number of the specification
the value of the specification, a number between 0 and 1
1 if true is part of the specification, 0 otherwise
1 if false is part of the specification, 0 otherwise
These two relations are implication rules. The remaining mass of 0.6 is allotted to the frame. To construct the tt
matrix, we put the variables M and R side by side, as in a truth table representation. Each pair of the subset is described by a row of the matrix as a vector of zeros and ones.
Claude Boivin, Stat.ASSQ
Almond, R.G. [1988] Fusion and Propagation in Graphical Belief Models. Computing Science and Statistics: Proceedings of the 20th Symposium on the Interface. Wegman, Edward J., Gantz, Donald T. and Miller, John J. (ed.). American Statistical Association, Alexandria, Virginia. pp 365–370.
mrt
: Relation between variables Maintenance done (M = true) and Repairs at sea (R)This dataset is the tt
matrix establishing a set of two relations between the two variables. First, Repairs = true if Maintenance = true in (M x R). We are 10% sure that there will be Repairs if maintenance is done. Second, Repairs = false if Maintenance = true in (M x R). We are 70% sure that there will be no repairs if maintenance is done.
mrt
mrt
A (0,1) matrix with 4 rows and 6 columns.
value = 0, not used
Identification numbers of the two variables. Column 3,4: variable 6; columns 5,6: variable 8
identification number of the specification
the value of the specification, a number between 0 and 1
1 if true is part of the specification, 0 otherwise
1 if false is part of the specification, 0 otherwise
These two relations are implication rules. The remaining mass of 0.2 is allotted to the frame. To construct the tt
matrix, we put the variables M and R side by side, as in a truth table representation. Each pair of the subset is described by a row of the matrix as a vector of zeros and ones.
Claude Boivin, Stat.ASSQ
Almond, R.G. [1988] Fusion and Propagation in Graphical Belief Models. Computing Science and Statistics: Proceedings of the 20th Symposium on the Interface. Wegman, Edward J., Gantz, Donald T. and Miller, John J. (ed.). American Statistical Association, Alexandria, Virginia. pp 365–370.
tt
matrixThis utility function makes use of the valuenames and size parameters of a set of variables to assign values names to the columns of a tt
matrix.
nameCols(valuenames, size)
nameCols(valuenames, size)
valuenames |
A list of the names of the variables with the name of the elements of their frame of discernment. |
size |
A vector of the size of the variables. |
A character vector of length equal to the sum of the sizes of the variables.
Claude Boivin
infoval <- list(A = c("a1", "a2"), B = c("b1", "b2", "b3")) sizes <- c(2,3) print(nameCols(valuenames = infoval, size = sizes) )
infoval <- list(A = c("a1", "a2"), B = c("b1", "b2", "b3")) sizes <- c(2,3) print(nameCols(valuenames = infoval, size = sizes) )
tt
matrix of a product spaceThis utility function makes use of the valuenames and size parameters of a set of variables to assign values names to the columns of the tt
matrix of their product space.
nameCols_prod(valuenames, size)
nameCols_prod(valuenames, size)
valuenames |
A list of the names of the variables with the name of the elements of their frame of discernment. |
size |
A vector of the size of the variables. |
A character vector of length equal to the product of the sizes of the variables.
Claude Boivin
infoval <- list(A = c("a1", "a2"), B = c("b1", "b2", "b3")) sizes <- c(2,3) print(nameCols_prod(valuenames = infoval, size = sizes) )
infoval <- list(A = c("a1", "a2"), B = c("b1", "b2", "b3")) sizes <- c(2,3) print(nameCols_prod(valuenames = infoval, size = sizes) )
This function determines the name of a row from all the columns of the tt
that show 1 for that row.
nameRows(tt, f)
nameRows(tt, f)
tt |
A (0,1)-matrix or a boolean matrix. |
f |
Deprecated. Old name for |
The row containing only 1s is called "frame", to avoid too long a label. The empty set is identified by its code "u00f8". The "+" sign is used to represent the logical "or" operator. The space " " is used to represent the logical "and" operator. Note that in the case of a product space defined on many variables, row labels can become very long.
A character vector of labels obtained for the rows of the tt
matrix. The length of the result is nrow(tt)
.
Claude Boivin
tt <- matrix(c(0,0,0,1,0,0,0,0,1,1,0,1,1,1,1),ncol = 3, byrow = TRUE) colnames(tt) <- c("A","B","C") rownames(tt) <-nameRows(tt) tt
tt <- matrix(c(0,0,0,1,0,0,0,0,1,1,0,1,1,1,1),ncol = 3, byrow = TRUE) colnames(tt) <- c("A","B","C") rownames(tt) <-nameRows(tt) tt
It may occur that the result of the combination of two basic chance assignments with Dempster's Rule of combination contains a non-zero mass allocated to the empty set. The function nzdsr
normalizes the result of function dsrwon
by dividing the mass value of the non-empty subsets by 1 minus the mass of the empty set.
nzdsr(x, sparse = "no", comm = "no")
nzdsr(x, sparse = "no", comm = "no")
x |
A basic chance assignment, i.e. a object of class bcaspec. |
sparse |
Put "yes" to use sparse matrix. Default = "no". |
comm |
Put "yes" to use commonality function. Default = "no". |
z The normalized basic chance assignment.
Claude Boivin, Peiyuan Zhu
Shafer, G., (1976). A Mathematical Theory of Evidence. Princeton University Press, Princeton, New Jersey, pp. 57-61: Dempster's rule of combination.
x1 <- bca(tt= matrix(c(1,0,1,1),nrow = 2, byrow = TRUE), m = c(0.9,0.1), cnames = c("yes", "no"), varnames = "x", idvar = 1) x2 <- bca(tt = matrix(c(0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.5,0.5), cnames = c("yes", "no"), varnames = "x", idvar = 1) print("combination of x1 and x2") x1x2 <- dsrwon(x1,x2, varname = "x") nzdsr(x1x2) # Test with sparse matrices x1s=x1 x2s=x2 x1s$tt <- methods::as(x1$tt, "RsparseMatrix") x2s$tt <- methods::as(x2$tt, "RsparseMatrix") x1x2s <- dsrwon(x1s, x2s, use_ssnames = TRUE) nzdsr(x1x2s) print("normalization of a bca definition.") y2 <- bca(tt = matrix(c(0,0,0,1,0,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5,0.3), cnames = c("a", "b", "c"), idvar = 1) cat("y2") cat("\ ") y2 nzdsr(y2)
x1 <- bca(tt= matrix(c(1,0,1,1),nrow = 2, byrow = TRUE), m = c(0.9,0.1), cnames = c("yes", "no"), varnames = "x", idvar = 1) x2 <- bca(tt = matrix(c(0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.5,0.5), cnames = c("yes", "no"), varnames = "x", idvar = 1) print("combination of x1 and x2") x1x2 <- dsrwon(x1,x2, varname = "x") nzdsr(x1x2) # Test with sparse matrices x1s=x1 x2s=x2 x1s$tt <- methods::as(x1$tt, "RsparseMatrix") x2s$tt <- methods::as(x2$tt, "RsparseMatrix") x1x2s <- dsrwon(x1s, x2s, use_ssnames = TRUE) nzdsr(x1x2s) print("normalization of a bca definition.") y2 <- bca(tt = matrix(c(0,0,0,1,0,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5,0.3), cnames = c("a", "b", "c"), idvar = 1) cat("y2") cat("\ ") y2 nzdsr(y2)
It may occur that the result of the combination of two basic chance assignments with Dempster's Rule of combination contains a non-zero mass allocated to the empty set. The function nzdsr
normalizes the result of function dsrwon
by dividing the mass value of the non-empty subsets by 1 minus the mass of the empty set.
nzdsrLogsumexp(x, sparse = "no", comm = "no")
nzdsrLogsumexp(x, sparse = "no", comm = "no")
x |
A basic chance assignment, i.e. a object of class bcaspec. |
sparse |
Put "yes" to use sparse matrix. Default = "no". |
comm |
Put "yes" to use commonality function. Default = "no". |
z The normalized basic chance assignment.
Claude Boivin, Peiyuan Zhu
Shafer, G., (1976). A Mathematical Theory of Evidence. Princeton University Press, Princeton, New Jersey, pp. 57-61: Dempster's rule of combination.
x1 <- bca(tt= matrix(c(1,0,1,1),nrow = 2, byrow = TRUE), m = c(0.9,0.1), cnames = c("yes", "no"), varnames = "x", idvar = 1) x2 <- bca(tt = matrix(c(0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.5,0.5), cnames = c("yes", "no"), varnames = "x", idvar = 1) print("combination of x1 and x2") x1x2 <- dsrwon(x1,x2, varname = "x") nzdsr(x1x2) # Test with sparse matrices x1s=x1 x2s=x2 x1s$tt <- methods::as(x1$tt, "RsparseMatrix") x2s$tt <- methods::as(x2$tt, "RsparseMatrix") x1x2s <- dsrwon(x1s, x2s, use_ssnames = TRUE) nzdsr(x1x2s) print("normalization of a bca definition.") y2 <- bca(tt = matrix(c(0,0,0,1,0,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5,0.3), cnames = c("a", "b", "c"), idvar = 1) cat("y2") cat("\ ") y2 nzdsr(y2)
x1 <- bca(tt= matrix(c(1,0,1,1),nrow = 2, byrow = TRUE), m = c(0.9,0.1), cnames = c("yes", "no"), varnames = "x", idvar = 1) x2 <- bca(tt = matrix(c(0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.5,0.5), cnames = c("yes", "no"), varnames = "x", idvar = 1) print("combination of x1 and x2") x1x2 <- dsrwon(x1,x2, varname = "x") nzdsr(x1x2) # Test with sparse matrices x1s=x1 x2s=x2 x1s$tt <- methods::as(x1$tt, "RsparseMatrix") x2s$tt <- methods::as(x2$tt, "RsparseMatrix") x1x2s <- dsrwon(x1s, x2s, use_ssnames = TRUE) nzdsr(x1x2s) print("normalization of a bca definition.") y2 <- bca(tt = matrix(c(0,0,0,1,0,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5,0.3), cnames = c("a", "b", "c"), idvar = 1) cat("y2") cat("\ ") y2 nzdsr(y2)
An implementation of the peeling algorithm based on its description in terms of hypergraphs by R. Almond [1989].
peeling(vars_def, hgm, hg_rel_names, elim_order, verbose = FALSE)
peeling(vars_def, hgm, hg_rel_names, elim_order, verbose = FALSE)
vars_def |
A list of variables and their possible values. Concatenate the valuenames parameter of all the variables of the hypergraph to obtain this list. |
hgm |
The incidence matrix of the hypergraph (bipartite graph), which is the description of the relations between the variables. The variables are the nodes of the hypergraph, and the relations are the edges. Each column describes a relation between the variables by a (0,1) vector. A "1" indicates that a variable belongs to the relation and a "0" not. This matrix must have row and column names. These names are used to show the graph eventually. They need not be the same as variables and relations names of the set of bca's to be analyzed. Use short names to obtain a clear graph. |
hg_rel_names |
The names of the relations, which are objects of class "bcaspec". |
elim_order |
The order of elimination of the variables. A vector of length |
verbose |
= TRUE: print steps on the console. Default = FALSE. |
The peeling algorithm works on an undirected graph. Nodes of the graph (variables) are removed one by one until only the variable of interest remains. An order of elimination (peeling) of the variables must be chosen by the user. No algorithm is provided for that matter. At each step, a procedure of extension is applied to the bca's to merge, and marginalization is applied to eliminate a variable. The marginalization has the effect to integrate in the remaining nodes the information of the eliminated variable.
A bca class object.
Claude Boivin
Almond, R. G. (1989) Fusion and Propagation of Graphical Belief Models: An Implementation and an Example. Ph. D. Thesis, the Department of Statistics, Harvard University. 288 pages (for the description of the peeling algorithm, see pages 52-53).
# Zadeh's Example # 1. Defining variables and relations # (for details, see vignette: Zadeh_Example) e1 <- bca(tt = matrix(c(1,0,0,1,1,1), ncol = 2, byrow = TRUE), m = c(0.99, 0.01, 0), cnames = c("M", "T"), varnames = "D1", idvar = 1) e2 <- bca(tt = matrix(c(1,0,0,1,1,1), ncol = 2, byrow = TRUE), m = c(0.99, 0.01, 0), cnames = c("C", "T"), varnames = "D2", idvar = 2) p_diag <- bca(tt = matrix(c(1,1,1), ncol = 3, byrow = TRUE), m = 1, cnames = c("M", "T", "C"), varnames = "D", idvar = 3) # Defining the relation between the variables # tt matrix tt_r1 <- matrix(c(1,0,1,0,1,0,0,1,0,1,0,0,0,1, 1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,1,0,0,1,0, 0,1,1,0,0,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1), ncol = 7,byrow = TRUE) colnames(tt_r1) = c("M", "T", "C", "T", "M", "T", "C") # The mass function spec_r1 <- matrix(c(rep(1,7),2, rep(1,7), 0), ncol = 2, dimnames = list(NULL, c("specnb", "mass"))) # Variables numbers and dimension of their frame info_r1 <- matrix(c(1:3, 2,2,3), ncol = 2, dimnames = list(NULL, c("varnb", "size")) ) # The relation between e1, e2 and a patient p r1 <- bcaRel(tt = tt_r1, spec = spec_r1, infovar = info_r1, varnames = c("D1", "D2", "D"), relnb = 1) # 2. Setting the incidence matrix of the grapph rel1 <- 1*1:3 %in% r1$infovar[,1] ev1 <- 1*1:3 %in% e1$infovar[,1] ev2 <- 1*1:3 %in% e2$infovar[,1] meddiag_hgm <- matrix(c(ev1,ev2, rel1), ncol = 3, dimnames = list(c("D1", "D2", "D"), c("e1","e2", "r1"))) # 3. Setting the names of the variables and their frame of discernment meddiag_vars1 <- c(e1$valuenames, e2$valuenames, p_diag$valuenames) # 4. Names of bca specifications (evidence and relations) meddiag_rel_names <- c("e1", "e2", "r1") # 5. Order of elimination of variables elim_order <- c(1,2,3) tabresul(peeling(vars_def = meddiag_vars1, hgm = meddiag_hgm, hg_rel_names = meddiag_rel_names, elim_order = c(1, 2, 3)) )
# Zadeh's Example # 1. Defining variables and relations # (for details, see vignette: Zadeh_Example) e1 <- bca(tt = matrix(c(1,0,0,1,1,1), ncol = 2, byrow = TRUE), m = c(0.99, 0.01, 0), cnames = c("M", "T"), varnames = "D1", idvar = 1) e2 <- bca(tt = matrix(c(1,0,0,1,1,1), ncol = 2, byrow = TRUE), m = c(0.99, 0.01, 0), cnames = c("C", "T"), varnames = "D2", idvar = 2) p_diag <- bca(tt = matrix(c(1,1,1), ncol = 3, byrow = TRUE), m = 1, cnames = c("M", "T", "C"), varnames = "D", idvar = 3) # Defining the relation between the variables # tt matrix tt_r1 <- matrix(c(1,0,1,0,1,0,0,1,0,1,0,0,0,1, 1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,1,0,0,1,0, 0,1,1,0,0,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1), ncol = 7,byrow = TRUE) colnames(tt_r1) = c("M", "T", "C", "T", "M", "T", "C") # The mass function spec_r1 <- matrix(c(rep(1,7),2, rep(1,7), 0), ncol = 2, dimnames = list(NULL, c("specnb", "mass"))) # Variables numbers and dimension of their frame info_r1 <- matrix(c(1:3, 2,2,3), ncol = 2, dimnames = list(NULL, c("varnb", "size")) ) # The relation between e1, e2 and a patient p r1 <- bcaRel(tt = tt_r1, spec = spec_r1, infovar = info_r1, varnames = c("D1", "D2", "D"), relnb = 1) # 2. Setting the incidence matrix of the grapph rel1 <- 1*1:3 %in% r1$infovar[,1] ev1 <- 1*1:3 %in% e1$infovar[,1] ev2 <- 1*1:3 %in% e2$infovar[,1] meddiag_hgm <- matrix(c(ev1,ev2, rel1), ncol = 3, dimnames = list(c("D1", "D2", "D"), c("e1","e2", "r1"))) # 3. Setting the names of the variables and their frame of discernment meddiag_vars1 <- c(e1$valuenames, e2$valuenames, p_diag$valuenames) # 4. Names of bca specifications (evidence and relations) meddiag_rel_names <- c("e1", "e2", "r1") # 5. Order of elimination of variables elim_order <- c(1,2,3) tabresul(peeling(vars_def = meddiag_vars1, hgm = meddiag_hgm, hg_rel_names = meddiag_rel_names, elim_order = c(1, 2, 3)) )
Given a mass function defined on some subsets of a frame , the application of the plausibility transformation to the singletons of
yields the probability distribution associated with this mass function.
plautrans(x)
plautrans(x)
x |
A bca mass function. |
We compute the plausibility measure of all the singletons of the frame of discernment. The probability distribution of the singletons is obtained from their plausibility measures.
The matrix of singletons with their plausibility transformation added in the last column.
Claude Boivin
Cobb, B. R. and Shenoy, P.P. (2006). On the plausibility transformation method for translating belief function models to probability models. Journal of Approximate Reasoning, 41(3), April 2006, 314–330.
x <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) plautrans(x)
x <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) plautrans(x)
This utility function takes the input matrix of a relation between two or more variables and yields its product space representation.
productSpace(tt, specnb, infovar)
productSpace(tt, specnb, infovar)
tt |
A (0,1) or boolean matrix, where the variables are set side by side, as in a truth table. Each variable has a number of columns equal to the number of possible values. |
specnb |
A vector of integers ranging from 1 to |
infovar |
A two-column matrix containing identification numbers of the variables and the number of elements of each variable (size of the frame). |
The matrix of the product space representation of the relation.
Claude Boivin
ttfw <- matrix(c(1,0,1,0,0,1,0,1,1,1,1,1),nrow = 3, byrow = TRUE, dimnames = list(NULL, c("foul", "fair", "foul", "fair")) ) specfw <- c(1,1,2) infovarfw <- matrix(c(5,7,2,2), ncol = 2, dimnames = list(NULL, c("varnb", "size")) ) rownames(ttfw) <- nameRows(ttfw) ttfw productSpace(tt = ttfw, specnb = specfw, infovar = infovarfw)
ttfw <- matrix(c(1,0,1,0,0,1,0,1,1,1,1,1),nrow = 3, byrow = TRUE, dimnames = list(NULL, c("foul", "fair", "foul", "fair")) ) specfw <- c(1,1,2) infovarfw <- matrix(c(5,7,2,2), ncol = 2, dimnames = list(NULL, c("varnb", "size")) ) rownames(ttfw) <- nameRows(ttfw) ttfw productSpace(tt = ttfw, specnb = specfw, infovar = infovarfw)
This utility function is used to obtain a summary of a vector of data for many operators. The function is taken from the project APL in R (https://rpubs.com/deleeuw/158476).
reduction(x, f)
reduction(x, f)
x |
A vector of numbers or a character string. |
f |
The operator. Must be compatible with the type of input vector (numeric or character) |
The result of applying the chosen operator to all the elements of the vector is an object of length 1.
Claude Boivin
Jan de Leeuw and Masanao Yajima (March 07, 2016) APL in R (Version 009), Source code. https://rpubs.com/deleeuw/158476
G. Helzer. (1989): An Encyclopedia of APL, second edition, I-APL LTD, St. Albans, G.B.
L. Gilman and A. J. Rose.(1974): APL an Interactive Approach, Second Edition, John Wiley, New-York.
reduction(c(1,2,3,4), f = "-") reduction(c(1,0,1,1,0), f = "|") reduction(c("a", "b", "c"), f = "paste")
reduction(c(1,2,3,4), f = "-") reduction(c(1,0,1,1,0), f = "|") reduction(c("a", "b", "c"), f = "paste")
shape
returns the dimension of given array or returns the length of a given vector. The function is taken from the project APL in R (https://rpubs.com/deleeuw/158476).
shape(a)
shape(a)
a |
An array or a vector. |
The dimension of the array a
or the length of the vector a
.
Claude Boivin
Jan de Leeuw and Masanao Yajima (March 07, 2016) APL in R (Version 009), Source code. https://rpubs.com/deleeuw/158476
G. Helzer. (1989): An Encyclopedia of APL, second edition, I-APL LTD, St. Albans, G.B.
L. Gilman and A. J. Rose.(1974): APL an Interactive Approach, Second Edition, John Wiley, New-York.
shape(array(c(1:6), c(2,3))) shape(c("a", "b"))
shape(array(c(1:6), c(2,3))) shape(c("a", "b"))
swr
: Relation between variables Sailing delay (S), Weather at sea (W), and Repairs at sea (R)This dataset is the tt
matrix establishing a relation between S, W and R, where S = 0:3, W = (foul, fair) and R = (true, false). The goal of this relation is to account for other causes of sailing delay. All the elements (s,w,r) of (S x W x R) where W or R is true add one day of sailing delay. We put a mass value of 0.9 to this subset. The remaining mass of 0.1 is allotted to the frame.
swr
swr
An integer matrix with 6 rows and 10 columns.
value = 0, not used
Identification numbers of the three variables. Column 3 to 6: variable 3; columns 7,8: variable 7, columns 9,10: variable 8
identification number of the specification
the value of the specification, a number between 0 and 1
1 if 3 is part of the specification, 0 otherwise
1 if 2 is part of the specification, 0 otherwise
1 if 1 is part of the specification, 0 otherwise
1 if 0 is part of the specification, 0 otherwise
1 if foul is part of the specification, 0 otherwise
1 if fair is part of the specification, 0 otherwise
1 if true is part of the specification, 0 otherwise
1 if false is part of the specification, 0 otherwise
To construct the tt
matrix, we put the variables S, W, R side by side, as in a truth table representation. Each triplet of the subset is described by a row of the matrix as a vector of zeros and ones.
Claude Boivin, Stat.ASSQ
Almond, R.G. [1988] Fusion and Propagation in Graphical Belief Models. Computing Science and Statistics: Proceedings of the 20th Symposium on the Interface. Wegman, Edward J., Gantz, Donald T. and Miller, John J. (ed.). American Statistical Association, Alexandria, Virginia. pp 365–370.
This utility function is a more detailed version of the belplau
function. Different tables of measures of belief, plausibility and of the plausibility ratio can be obtained, namely by removing subsets with zero mass if present, or by asking for singletons only. Unlike function belplau
, function tabresul
does not reconstruct the row names from the column names. You can assign short rownames of your choice to the tt matrix of your resulting bca before calling function tabresul
.
tabresul(x, singletonsOnly = FALSE, removeZeroes = FALSE)
tabresul(x, singletonsOnly = FALSE, removeZeroes = FALSE)
x |
A basic chance assignment (bca) |
singletonsOnly |
= TRUE reduces the table of results to elementary events (singletons). |
removeZeroes |
= TRUE removes subsets with 0 mass. |
A list of two elements:
mbp The table of focal elements with the addition of their associated mass, degree of belief, plausibility and the plausibility ratio.
con The measure of conflict between subsets.
Claude Boivin
x <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) y <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "y", idvar = 1) xy <- dsrwon(x,y) xyNorm <- nzdsr(xy) tabresul(xyNorm) ## print("Show all elementary events") xy1 <- addTobca(nzdsr(dsrwon(x,y)), matrix(c(0,1,0,0,0,1), nrow = 2, byrow = TRUE)) tabresul(xy1) ## print("Remove focal elements with 0 mass") tabresul(xy1, removeZeroes = TRUE) print("Retain singletons only") tabresul(xy1, singletonsOnly = TRUE)
x <- bca(tt = matrix(c(0,1,1,1,1,0,1,1,1),nrow = 3, byrow = TRUE), m = c(0.2,0.5, 0.3), cnames = c("a", "b", "c"), varnames = "x", idvar = 1) y <- bca(tt = matrix(c(1,0,0,1,1,1),nrow = 2, byrow = TRUE), m = c(0.6, 0.4), cnames = c("a", "b", "c"), varnames = "y", idvar = 1) xy <- dsrwon(x,y) xyNorm <- nzdsr(xy) tabresul(xyNorm) ## print("Show all elementary events") xy1 <- addTobca(nzdsr(dsrwon(x,y)), matrix(c(0,1,0,0,0,1), nrow = 2, byrow = TRUE)) tabresul(xy1) ## print("Remove focal elements with 0 mass") tabresul(xy1, removeZeroes = TRUE) print("Retain singletons only") tabresul(xy1, singletonsOnly = TRUE)
Construct a description matrix from a list of subsets names.
ttmatrix(x, sparse = "no")
ttmatrix(x, sparse = "no")
x |
A list of names |
sparse |
= c("yes","no") whether to use sparse matrix. Default = "no". |
ttmat A corresponding logical description matrix
Claude Boivin
subsets_names <- list(c("b", "c"), "b", c("a", "b", "c")) ttmatrix(subsets_names) znames <- list("empty", "a", c("b", "c"), c("a", "b"), c("a", "b", "c") ) print(ttmatrix(znames) ) print(ttmatrix(znames, sparse = "yes") )
subsets_names <- list(c("b", "c"), "b", c("a", "b", "c")) ttmatrix(subsets_names) znames <- list("empty", "a", c("b", "c"), c("a", "b"), c("a", "b", "c") ) print(ttmatrix(znames) ) print(ttmatrix(znames, sparse = "yes") )
Construct tt matrix of a bca from marginal probabilities
ttmatrixFromMarginal( marg_probs, from_above = FALSE, simple = FALSE, min_prob = 0, max_prob = 2 )
ttmatrixFromMarginal( marg_probs, from_above = FALSE, simple = FALSE, min_prob = 0, max_prob = 2 )
marg_probs |
marginal probabilities |
from_above |
=TRUE whether to cut marginal probabilities from above |
simple |
=TRUE whether to use simple support function |
min_prob |
=0 lower bound on marginal probabilities |
max_prob |
=2 upper bound on marginal probabilities |
matrix of possible subsets obtained from the cuts
Peiyuan Zhu
x <- c(2,2,1.5,1.2,1,0,0) ttmatrixFromMarginal(x, FALSE)
x <- c(2,2,1.5,1.2,1,0,0) ttmatrixFromMarginal(x, FALSE)
Construct a description matrix from a qq vector
ttmatrixFromQQ(qq, n, cnames)
ttmatrixFromQQ(qq, n, cnames)
qq |
Commonality function |
n |
Dimension of the frame |
cnames |
A character vector containing the names of the elements of the frame of discernment |
tt A corresponding logical description matrix
Peiyuan Zhu
tt<- t(matrix(c(1,0,1,1),ncol = 2)) m<- c(.9,.1) cnames <- c("yes","no") x<- bca(tt, m, cnames=cnames) ttmatrixFromQQ(x$qq,as.integer(x$infovar[1,2]))
tt<- t(matrix(c(1,0,1,1),ncol = 2)) m<- c(.9,.1) cnames <- c("yes","no") x<- bca(tt, m, cnames=cnames) ttmatrixFromQQ(x$qq,as.integer(x$infovar[1,2]))
Create partition matrix
ttmatrixPartition(n, m)
ttmatrixPartition(n, m)
n |
partition size |
m |
size of the set to be partitioned |
h binary partition matrix of size n by m
Peiyuan Zhu
# test singleton hypotheses x <- bca(tt = matrix(c(1,1,0,1,1,1), nrow = 2, byrow = TRUE), m = c(0.8, 0.2), cnames = c(1,2,3)) pa <- ttmatrixPartition(x$infovar[2], x$infovar[2]) belplau(x, h=pa)
# test singleton hypotheses x <- bca(tt = matrix(c(1,1,0,1,1,1), nrow = 2, byrow = TRUE), m = c(0.8, 0.2), cnames = c(1,2,3)) pa <- ttmatrixPartition(x$infovar[2], x$infovar[2]) belplau(x, h=pa)