Skip to content

Variable: FuzzyShape

@kortexya/reasoninglayer


@kortexya/reasoninglayer / FuzzyShape

const FuzzyShape: object

Defined in: src/builders/value.ts:587

Builder namespace for fuzzy membership function shapes.

Produces JSON using the "kind" discriminator (NOT "type"): {"kind": "Triangular", "a": 20, "b": 22, "c": 24}.

readonly bell(center, width, slope): BellShape

Create a generalized bell fuzzy membership function.

Tunable flat-top bell: μ(x) = 1 / (1 + |((x - center) / width)|^(2*slope)). Unlike Gaussian, the slope controls how sharply the curve drops off.

number

Center of the bell (membership = 1).

number

Half-width of the bell at the crossover point.

number

Controls steepness of the sides. Higher = sharper edges.

BellShape

A BellShape.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

FuzzyShape.bell(100, 15, 3)
// {"kind": "Bell", "center": 100, "width": 15, "slope": 3}

readonly cauchy(center, gamma): CauchyShape

Create a Cauchy (Lorentzian) fuzzy membership function.

μ(x) = 1 / (1 + ((x - center) / gamma)^2). Heavy-tailed bell whose tails never reach zero.

number

Center of the Cauchy curve (membership = 1).

number

Half-width at half-maximum, controlling the spread.

CauchyShape

A CauchyShape.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

FuzzyShape.cauchy(0, 1)
// {"kind": "Cauchy", "center": 0, "gamma": 1}

readonly cosine(center, width): CosineShape

Create a cosine fuzzy membership function with compact support.

μ(x) = 0.5 * (1 + cos(2π/width * (x - center))) for |x - center| <= width/2, μ(x) = 0 otherwise.

number

Center of the cosine curve (membership = 1).

number

Full width of the support region.

CosineShape

A CosineShape.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

FuzzyShape.cosine(50, 10)
// {"kind": "Cosine", "center": 50, "width": 10}

readonly cyclicGaussian(mean, stdDev, period): CyclicGaussianShape

Create a cyclic Gaussian fuzzy membership function with periodic wrapping.

number

Center of the Gaussian curve.

number

Standard deviation controlling width.

number

Period of the cyclic wrapping (e.g., 360 for degrees).

CyclicGaussianShape

A CyclicGaussianShape.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

FuzzyShape.cyclicGaussian(180, 30, 360)

readonly gaussian(mean, stdDev): GaussianShape

Create a Gaussian fuzzy membership function.

number

Center of the Gaussian curve (membership = 1).

number

Standard deviation controlling width.

GaussianShape

A GaussianShape.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

FuzzyShape.gaussian(100, 15)

readonly gaussianProduct(mean1, stdDev1, mean2, stdDev2): GaussianProductShape

Create a Gaussian product (gauss2mf) fuzzy membership function.

Asymmetric flat-top bell: left Gaussian up to mean1, flat 1.0 in [mean1, mean2], right Gaussian after mean2.

number

Left Gaussian center.

number

Left Gaussian standard deviation.

number

Right Gaussian center.

number

Right Gaussian standard deviation.

GaussianProductShape

A GaussianProductShape.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

FuzzyShape.gaussianProduct(36.5, 0.3, 37.5, 0.2)
// {"kind": "GaussianProduct", "mean1": 36.5, "stdDev1": 0.3, "mean2": 37.5, "stdDev2": 0.2}

readonly piecewiseLinear(points): PiecewiseLinearShape

Create a piecewise linear fuzzy membership function.

Membership is linearly interpolated between the provided (x, mu) data points.

[number, number][]

Array of [x, mu] tuples defining the membership function.

PiecewiseLinearShape

A PiecewiseLinearShape.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

FuzzyShape.piecewiseLinear([[0, 0], [0.5, 1], [1, 0]])
// {"kind": "PiecewiseLinear", "points": [[0, 0], [0.5, 1], [1, 0]]}

readonly piShape(a, b, c, d): PiShapeShape

Create a Pi-shaped (pimf) fuzzy membership function.

Smooth flat-top bump: μ(x) = SShape(x, a, b) * ZShape(x, c, d). Like a smooth trapezoidal.

number

Left foot (SShape start).

number

Left shoulder (SShape end).

number

Right shoulder (ZShape start).

number

Right foot (ZShape end).

PiShapeShape

A PiShapeShape.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

FuzzyShape.piShape(10, 20, 60, 80)
// {"kind": "PiShape", "a": 10, "b": 20, "c": 60, "d": 80}

readonly sigmoid(midpoint, steepness): SigmoidShape

Create a sigmoid (logistic) fuzzy membership function.

Monotonic S-curve transition: μ(x) = 1 / (1 + exp(-steepness * (x - midpoint))). Positive steepness = increasing, negative = decreasing.

number

The x-value where membership = 0.5 (inflection point).

number

Controls transition sharpness. Positive = left-to-right rise.

SigmoidShape

A SigmoidShape.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

// DNA match confidence: sharp transition around 95%
FuzzyShape.sigmoid(0.95, 20)
// {"kind": "Sigmoid", "midpoint": 0.95, "steepness": 20}

readonly sigmoidDifference(midpoint1, steepness1, midpoint2, steepness2): SigmoidDifferenceShape

Create a sigmoid difference fuzzy membership function.

Difference of two sigmoids: creates a smooth bounded region (like a smooth trapezoidal). μ(x) = sigmoid(x, midpoint1, steepness1) - sigmoid(x, midpoint2, steepness2).

number

Left transition inflection point.

number

Left transition sharpness (positive = rising).

number

Right transition inflection point.

number

Right transition sharpness (positive = falling).

SigmoidDifferenceShape

A SigmoidDifferenceShape.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

// Smooth region between pH 6.5 and 7.5
FuzzyShape.sigmoidDifference(6.5, 10, 7.5, 10)
// {"kind": "SigmoidDifference", "midpoint1": 6.5, "steepness1": 10, "midpoint2": 7.5, "steepness2": 10}

readonly sigmoidProduct(midpoint1, steepness1, midpoint2, steepness2): SigmoidProductShape

Create a sigmoid product fuzzy membership function.

Product of two sigmoids: μ(x) = sigmoid(x, midpoint1, steepness1) * sigmoid(x, midpoint2, steepness2). Always non-negative (unlike sigmoidDifference).

number

First sigmoid inflection point.

number

First sigmoid sharpness.

number

Second sigmoid inflection point.

number

Second sigmoid sharpness.

SigmoidProductShape

A SigmoidProductShape.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

FuzzyShape.sigmoidProduct(6.5, 10, 7.5, -10)
// {"kind": "SigmoidProduct", "midpoint1": 6.5, "steepness1": 10, "midpoint2": 7.5, "steepness2": -10}

readonly spike(center, width): SpikeShape

Create a spike (Laplacian/double-exponential) fuzzy membership function.

μ(x) = exp(-|x - center| / width). Sharp cusp at center with exponential tails.

number

Peak of the spike (membership = 1).

number

Controls the rate of exponential decay.

SpikeShape

A SpikeShape.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

FuzzyShape.spike(100, 5)
// {"kind": "Spike", "center": 100, "width": 5}

readonly sShape(a, b): SShapeShape

Create an S-shaped (smf) fuzzy membership function.

Smooth monotonic spline from 0 to 1 using piecewise quadratic. Reaches exact 0 and 1 (unlike sigmoid).

number

Foot: x-value where membership starts rising from 0.

number

Shoulder: x-value where membership reaches 1.

SShapeShape

An SShapeShape.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

FuzzyShape.sShape(20, 80)
// {"kind": "SShape", "a": 20, "b": 80}

readonly trapezoidal(a, b, c, d): TrapezoidalShape

Create a trapezoidal fuzzy membership function.

number

Left foot (membership starts rising from 0).

number

Left shoulder (membership reaches 1).

number

Right shoulder (membership starts falling from 1).

number

Right foot (membership returns to 0).

TrapezoidalShape

A TrapezoidalShape.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

FuzzyShape.trapezoidal(18, 20, 24, 26)

readonly triangular(a, b, c): TriangularShape

Create a triangular fuzzy membership function.

number

Left foot (membership = 0).

number

Peak (membership = 1).

number

Right foot (membership = 0).

TriangularShape

A TriangularShape: {"kind": "Triangular", "a": 20, "b": 22, "c": 24}.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

FuzzyShape.triangular(20, 22, 24)

readonly zShape(a, b): ZShapeShape

Create a Z-shaped (zmf) fuzzy membership function.

Mirror of sShape. Smooth monotonic spline from 1 to 0 using piecewise quadratic.

number

Shoulder: x-value where membership starts falling from 1.

number

Foot: x-value where membership reaches 0.

ZShapeShape

A ZShapeShape.

Serialization format: Tagged by "kind" (FuzzyShapeDto).

FuzzyShape.zShape(20, 80)
// {"kind": "ZShape", "a": 20, "b": 80}

Discriminator field is "kind", NOT "type". This differs from most other tagged unions in the API which use "type".

import { FuzzyShape, Value } from '@kortexya/reasoninglayer';
const shape = FuzzyShape.triangular(20, 22, 24);
const fuzzyAge = Value.fuzzyNumber(shape);