gset(support, memberships, charfun, elements, universe, bound)
as.gset(x)
is.gset(x)
gset_support(x)
gset_core(x, na.rm = FALSE)
gset_peak(x, na.rm = FALSE)
gset_height(x, na.rm = FALSE)
gset_universe(x)
gset_bound(x)gset_memberships(x, filter = NULL)
gset_transform_memberships(x, FUN, ...)
gset_concentrate(x)
gset_dilate(x)
gset_normalize(x, height = 1)
gset_defuzzify(x,
method = c("meanofmax", "smallestofmax",
"largestofmax", "centroid"))
gset_is_empty(x, na.rm = FALSE)
gset_is_subset(x, y, na.rm = FALSE)
gset_is_proper_subset(x, y, na.rm = FALSE)
gset_is_equal(x, y, na.rm = FALSE)
gset_contains_element(x, e)
gset_is_set(x, na.rm = FALSE)
gset_is_multiset(x, na.rm = FALSE)
gset_is_fuzzy_set(x, na.rm = FALSE)
gset_is_set_or_multiset(x, na.rm = FALSE)
gset_is_set_or_fuzzy_set(x, na.rm = FALSE)
gset_is_fuzzy_multiset(x)
gset_is_crisp(x, na.rm = FALSE)
gset_has_missings(x)
gset_cardinality(x, type = c("absolute", "relative"), na.rm = FALSE)
gset_union(...)
gset_sum(...)
gset_difference(...)
gset_product(...)
gset_mean(x, y, type = c("arithmetic", "geometric", "harmonic"))
gset_intersection(...)
gset_symdiff(...)
gset_complement(x, y)
gset_power(x)
gset_cartesian(...)
gset_combn(x, m)
e(x, memberships = 1L)
is_element(e)
## S3 method for class 'gset':
cut(x, level = 1, type = c("alpha", "nu"), strict = FALSE, ...)
## S3 method for class 'gset':
mean(x, \dots, na.rm = FALSE)
## S3 method for class 'gset':
median(x, na.rm = FALSE)
## S3 method for class 'gset':
length(x)
e()
, as.gset()
and is.gset()
:
an Robject. A (g)set object otherwise. gset_memberships()
also accepts tuple objects.element
.e
objects which are
object/memberships-pairs.NULL
,
defaults to the value of sets_options("bound")
.
If the latter is also NULL
, the maximum multiplicity
will be used in comgset_cardinality()
:
cardinality type (either "absolute"
or
"relative"
). For gset_mean()
: mean type
("arithmetic"
, "geometric"
, or "harmonic"
).
FNULL
,
defaults to the value of sets_options("universe")
.
If the latter is also NULL
, the support
will be used in computations."centroid"
computes the arithmetic
mean of the set elements, using the membership values as
weights. "smallestofmax"
/ "meanofmax"
/
"largestofmax"
returns the minimum/mean/maximum of all
NA
values should be
removed. A generalized set (or gset) is set of pairs $(e, f)$, where
$e$ is some set element and $f$ is the characteristic (or
membership) function. For (gset_is_foo()
predicates
are vectorized. In addition
to the methods defined, one can use the following operators:
|
for the union, &
for the
intersection, +
for the sum, -
for
the difference, %D%
for the symmetric difference,
*
and ^n
for the
($n$-fold) cartesian product, 2^
for the power set,
%e%
for the element-of predicate,
<
and <=< code=""> for
the (proper) subset predicate,
>
and >=
for
the (proper) superset predicate, and ==
and !=
for
(in)equality.
The Summary
methods do also work if
defined for the set elements.
The mean
and median
methods try to convert the object to a numeric vector before calling
the default methods. set_combn
returns the gset of all
subsets of specified length. =<>
gset_support
, gset_core
, and gset_peak
return the set of elements with memberships greater than zero, equal
to one, and equal to the maximum membership, respectively.
gset_memberships
returns the membership
vector(s) of a given (tuple of) gset(s), optionally
restricted to the elements specified by filter
.
gset_height
returns only
the largest membership degree.
gset_cardinality
computes either the absolute or the
relative cardinality, i.e. the memberships sum, or the absolute
cardinality divided by the number of elements, respectively.
The length
method for gsets gives the (absolute) cardinality.
gset_transform_memberships
applies function FOO
to
the membership vector of the supplied gset and returns the transformed
gset. The transformed memberships are guaranteed to be in the unit
interval.
gset_concentrate
and gset_dilate
are convenience
functions, using the square and the square root,
respectively. gset_normalize
divides the memberships by their
maximum and scales with height
.
gset_product
(gset_mean
) of some gsets
compute the gset with the corresponding memberships multiplied (averaged).
The cut
method provides both $\alpha$- and $\nu$-cuts.
$\alpha$-cuts level
---the result, thus, is a crisp
(multi)set. $\nu$-cuts select those elements with a
multiplicity exceeding level
(only sensible for (fuzzy) multisets).
Because set elements are unordered, it is not allowed to use
positional indexing. However, it is possible to
do indexing using element labels or
simply the elements themselves (useful, e.g., for subassignment).
In addition, it is possible to iterate over
all elements using for
and lapply
/sapply
.
gset_contains_element
is vectorized in e
, that is, if e
is an atomic vector or list, the is-element operation is performed
element-wise, and a logical vector returned. Note that, however,
objects of class tuple
are taken as atomic objects to
correctly handle sets of tuples.
set
for gset_outer
, and
tuple
for tuples (## multisets
(A <- gset(letters[1:5], memberships = c(3, 2, 1, 1, 1)))
(B <- gset(c("a", "c", "e", "f"), memberships = c(2, 2, 1, 2)))
rep(B, 2)
gset_memberships(tuple(A, B), c("a","c"))
gset_union(A, B)
gset_intersection(A, B)
gset_complement(A, B)
gset_is_multiset(A)
gset_sum(A, B)
gset_difference(A, B)
## fuzzy sets
(A <- gset(letters[1:5], memberships = c(1, 0.3, 0.8, 0.6, 0.2)))
(B <- gset(c("a", "c", "e", "f"), memberships = c(0.7, 1, 0.4, 0.9)))
cut(B, 0.5)
A * B
A <- gset(3L, memberships = 0.5, universe = 1:5)
!A
## fuzzy multisets
(A <- gset(c("a", "b", "d"),
memberships = list(c(0.3, 1, 0.5), c(0.9, 0.1),
gset(c(0.4, 0.7), c(1, 2)))))
(B <- gset(c("a", "c", "d", "e"),
memberships = list(c(0.6, 0.7), c(1, 0.3), c(0.4, 0.5), 0.9)))
gset_union(A, B)
gset_intersection(A, B)
gset_complement(A, B)
## other operations
mean(gset(1:3, c(0.1,0.5,0.9)))
median(gset(1:3, c(0.1,0.5,0.9)))
Run the code above in your browser using DataLab