# ctx: Context for linguistic expressions In beerda/lfl: Linguistic Fuzzy Logic

## Description

A context describes a range of allowed values for a data column.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113``` ```ctx3( low = 0, center = low + (high - low) * relCenter, high = 1, relCenter = 0.5 ) ctx3bilat( negMax = -1, negCenter = origin + (negMax - origin) * relCenter, origin = 0, center = origin + (max - origin) * relCenter, max = 1, relCenter = 0.5 ) ctx5( low = 0, lowerCenter = mean(c(low, center)), center = low + (high - low) * relCenter, upperCenter = mean(c(center, high)), high = 1, relCenter = 0.5 ) ctx5bilat( negMax = -1, negUpperCenter = mean(c(negCenter, negMax)), negCenter = origin + (negMax - origin) * relCenter, negLowerCenter = mean(c(origin, negCenter)), origin = 0, lowerCenter = mean(c(origin, center)), center = origin + (max - origin) * relCenter, upperCenter = mean(c(center, max)), max = 1, relCenter = 0.5 ) as.ctx3(x) ## S3 method for class 'ctx3' as.ctx3(x) ## S3 method for class 'ctx3bilat' as.ctx3(x) ## S3 method for class 'ctx5' as.ctx3(x) ## S3 method for class 'ctx5bilat' as.ctx3(x) ## Default S3 method: as.ctx3(x) as.ctx3bilat(x) ## S3 method for class 'ctx3bilat' as.ctx3bilat(x) ## S3 method for class 'ctx3' as.ctx3bilat(x) ## S3 method for class 'ctx5' as.ctx3bilat(x) ## S3 method for class 'ctx5bilat' as.ctx3bilat(x) ## Default S3 method: as.ctx3bilat(x) as.ctx5(x) ## S3 method for class 'ctx5' as.ctx5(x) ## S3 method for class 'ctx3' as.ctx5(x) ## S3 method for class 'ctx3bilat' as.ctx5(x) ## S3 method for class 'ctx5bilat' as.ctx5(x) ## Default S3 method: as.ctx5(x) as.ctx5bilat(x) ## S3 method for class 'ctx5bilat' as.ctx5bilat(x) ## S3 method for class 'ctx3' as.ctx5bilat(x) ## S3 method for class 'ctx3bilat' as.ctx5bilat(x) ## S3 method for class 'ctx5' as.ctx5bilat(x) ## Default S3 method: as.ctx5bilat(x) is.ctx3(x) is.ctx3bilat(x) is.ctx5(x) is.ctx5bilat(x) ```

## Arguments

 `low` Lowest value of an unilateral context. `center` A positive middle value of a bilateral context, or simply a middle value of an unilateral context. `high` Highest value of an unilateral context. `relCenter` A relative quantity used to compute the `negCenter` and/or `center`, if they are not specified explicitly. The sensible value is 0.5 for context symmetric around center, or 0.42 as proposed by Novak. `negMax` Lowest negative value of a bilateral context. `negCenter` A negative middle value. `origin` Origin, i.e. the initial point of the bilateral context. It is typically a value of zero. `max` Highest value of a bilateral context. `lowerCenter` A typical positive value between origin and center. `upperCenter` A typical positive value between center and maximum. `negUpperCenter` A typical negative value between `negMax` and `negCenter`. `negLowerCenter` A typical negative value between `negCenter` and `negOrigin`. `x` A value to be examined or converted. For `as.ctx*`, it can be an instance of any `ctx*` class or a numeric vector of size equal to the number of points required for the given context type.

## Details

A context describes a range of allowed values for a data column. For that, only the borders of the interval, i.e. minimum and maximum, are usually needed, but we use contexts to hold more additional information that is crucial for the construction of linguistic expressions.

Currently, four different contexts are supported that determine the types of possible linguistic expressions, as constructed with `lingexpr()`. Unilateral or bilateral context is allowed in the variants of trichotomy or pentachotomy. Trichotomy distinguishes three points in the interval: the lowest value, highest value, and center. Pentachotomy adds lower center and upper center to them. As opposite to unilateral, the bilateral context handles explicitly the negative values. That is, bilateral context expects some middle point, the origin (usually 0), around which the positive and negative values are placed.

Concretely, the type of the context determines the allowed atomic expressions as follows:

• `ctx3`: trichotomy (low, center, high) enables atomic expressions: small, medium, big;

• `ctx5`: pentachotomy (low, lowerCenter, center, upperCenter, high) enables atomic expressions: small, lower medium, medium, upper medium, big;

• `ctx3bilat`: bilateral trichotomy (negMax, negCenter, origin, center, max) enables atomic expressions: negative big, negative medium, negative small, zero, small, medium, big;

• `ctx5bilat`: bilateral pentachotomy (negMax, negCenter, origin, center, max) enables atomic expressions: negative big, negative medium, negative small, zero, small, medium, big.

The `as.ctx*` functions return instance of the appropriate class. The functions perform the conversion so that missing points of the new context are computed from the old context that is being transformed. In the subsequent table, rows represent compatible values of different context types:

 ctx3 ctx5 ctx3bilat ctx5bilat negMax negMax negUpperCenter negCenter negCenter negLowerCenter low low origin origin lowerCenter lowerCenter center center center center upperCenter upperCenter high high max max

The `as.ctx*` conversion is performed by replacing values by rows, as indicated in the table above. When converting from a context with less points to a context with more points (e.g. from unilateral to bilateral, or from trichotomy to pentachotomy), missing points are computed as follows:

• `center` is computed as a mean of `origin` (or `low`) and `max` (or `high`).

• `lowerCenter` is computed as a mean of `origin` (or `low`) and `center`.

• `upperCenter` is computed as a mean of `mas` (or `high`) and `center`.

• negative points (such as `negMax`, `negCenter` etc.) are computed symmetrically around `origin` to the corresponding positive points.

The code `as.ctx*` functions allow the parameter to be also a numeric vector of size equal to the number of points required for the given context type, i.e. 3 (`ctx3`), 5 (`ctx3bilat`, `ctx5`), or 9 (`ctx5bilat`).

## Value

`ctx*` and `as.ctx*` return an instance of the appropriate class. `is.ctx*` returns `TRUE` or `FALSE`.

Michal Burda

## See Also

`minmax()`, `lingexpr()`, `horizon()`, `hedge()`, `fcut()`, `lcut()`

## Examples

 ```1 2``` ``` ctx3(low=0, high=10) as.ctx3bilat(ctx3(low=0, high=10)) ```

beerda/lfl documentation built on Oct. 17, 2020, 8:57 p.m.