Variable: FuzzyShape
@kortexya/reasoninglayer / FuzzyShape
Variable: FuzzyShape
Section titled “Variable: FuzzyShape”
constFuzzyShape: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}.
Type Declaration
Section titled “Type Declaration”bell()
Section titled “bell()”
readonlybell(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.
Parameters
Section titled “Parameters”center
Section titled “center”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.
Returns
Section titled “Returns”A BellShape.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”FuzzyShape.bell(100, 15, 3)// {"kind": "Bell", "center": 100, "width": 15, "slope": 3}cauchy()
Section titled “cauchy()”
readonlycauchy(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.
Parameters
Section titled “Parameters”center
Section titled “center”number
Center of the Cauchy curve (membership = 1).
number
Half-width at half-maximum, controlling the spread.
Returns
Section titled “Returns”A CauchyShape.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”FuzzyShape.cauchy(0, 1)// {"kind": "Cauchy", "center": 0, "gamma": 1}cosine()
Section titled “cosine()”
readonlycosine(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.
Parameters
Section titled “Parameters”center
Section titled “center”number
Center of the cosine curve (membership = 1).
number
Full width of the support region.
Returns
Section titled “Returns”A CosineShape.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”FuzzyShape.cosine(50, 10)// {"kind": "Cosine", "center": 50, "width": 10}cyclicGaussian()
Section titled “cyclicGaussian()”
readonlycyclicGaussian(mean,stdDev,period):CyclicGaussianShape
Create a cyclic Gaussian fuzzy membership function with periodic wrapping.
Parameters
Section titled “Parameters”number
Center of the Gaussian curve.
stdDev
Section titled “stdDev”number
Standard deviation controlling width.
period
Section titled “period”number
Period of the cyclic wrapping (e.g., 360 for degrees).
Returns
Section titled “Returns”A CyclicGaussianShape.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”FuzzyShape.cyclicGaussian(180, 30, 360)gaussian()
Section titled “gaussian()”
readonlygaussian(mean,stdDev):GaussianShape
Create a Gaussian fuzzy membership function.
Parameters
Section titled “Parameters”number
Center of the Gaussian curve (membership = 1).
stdDev
Section titled “stdDev”number
Standard deviation controlling width.
Returns
Section titled “Returns”A GaussianShape.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”FuzzyShape.gaussian(100, 15)gaussianProduct()
Section titled “gaussianProduct()”
readonlygaussianProduct(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.
Parameters
Section titled “Parameters”number
Left Gaussian center.
stdDev1
Section titled “stdDev1”number
Left Gaussian standard deviation.
number
Right Gaussian center.
stdDev2
Section titled “stdDev2”number
Right Gaussian standard deviation.
Returns
Section titled “Returns”A GaussianProductShape.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”FuzzyShape.gaussianProduct(36.5, 0.3, 37.5, 0.2)// {"kind": "GaussianProduct", "mean1": 36.5, "stdDev1": 0.3, "mean2": 37.5, "stdDev2": 0.2}piecewiseLinear()
Section titled “piecewiseLinear()”
readonlypiecewiseLinear(points):PiecewiseLinearShape
Create a piecewise linear fuzzy membership function.
Membership is linearly interpolated between the provided (x, mu) data points.
Parameters
Section titled “Parameters”points
Section titled “points”[number, number][]
Array of [x, mu] tuples defining the membership function.
Returns
Section titled “Returns”A PiecewiseLinearShape.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”FuzzyShape.piecewiseLinear([[0, 0], [0.5, 1], [1, 0]])// {"kind": "PiecewiseLinear", "points": [[0, 0], [0.5, 1], [1, 0]]}piShape()
Section titled “piShape()”
readonlypiShape(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.
Parameters
Section titled “Parameters”number
Left foot (SShape start).
number
Left shoulder (SShape end).
number
Right shoulder (ZShape start).
number
Right foot (ZShape end).
Returns
Section titled “Returns”A PiShapeShape.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”FuzzyShape.piShape(10, 20, 60, 80)// {"kind": "PiShape", "a": 10, "b": 20, "c": 60, "d": 80}sigmoid()
Section titled “sigmoid()”
readonlysigmoid(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.
Parameters
Section titled “Parameters”midpoint
Section titled “midpoint”number
The x-value where membership = 0.5 (inflection point).
steepness
Section titled “steepness”number
Controls transition sharpness. Positive = left-to-right rise.
Returns
Section titled “Returns”A SigmoidShape.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”// DNA match confidence: sharp transition around 95%FuzzyShape.sigmoid(0.95, 20)// {"kind": "Sigmoid", "midpoint": 0.95, "steepness": 20}sigmoidDifference()
Section titled “sigmoidDifference()”
readonlysigmoidDifference(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).
Parameters
Section titled “Parameters”midpoint1
Section titled “midpoint1”number
Left transition inflection point.
steepness1
Section titled “steepness1”number
Left transition sharpness (positive = rising).
midpoint2
Section titled “midpoint2”number
Right transition inflection point.
steepness2
Section titled “steepness2”number
Right transition sharpness (positive = falling).
Returns
Section titled “Returns”A SigmoidDifferenceShape.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”// Smooth region between pH 6.5 and 7.5FuzzyShape.sigmoidDifference(6.5, 10, 7.5, 10)// {"kind": "SigmoidDifference", "midpoint1": 6.5, "steepness1": 10, "midpoint2": 7.5, "steepness2": 10}sigmoidProduct()
Section titled “sigmoidProduct()”
readonlysigmoidProduct(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).
Parameters
Section titled “Parameters”midpoint1
Section titled “midpoint1”number
First sigmoid inflection point.
steepness1
Section titled “steepness1”number
First sigmoid sharpness.
midpoint2
Section titled “midpoint2”number
Second sigmoid inflection point.
steepness2
Section titled “steepness2”number
Second sigmoid sharpness.
Returns
Section titled “Returns”A SigmoidProductShape.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”FuzzyShape.sigmoidProduct(6.5, 10, 7.5, -10)// {"kind": "SigmoidProduct", "midpoint1": 6.5, "steepness1": 10, "midpoint2": 7.5, "steepness2": -10}spike()
Section titled “spike()”
readonlyspike(center,width):SpikeShape
Create a spike (Laplacian/double-exponential) fuzzy membership function.
μ(x) = exp(-|x - center| / width). Sharp cusp at center with exponential tails.
Parameters
Section titled “Parameters”center
Section titled “center”number
Peak of the spike (membership = 1).
number
Controls the rate of exponential decay.
Returns
Section titled “Returns”A SpikeShape.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”FuzzyShape.spike(100, 5)// {"kind": "Spike", "center": 100, "width": 5}sShape()
Section titled “sShape()”
readonlysShape(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).
Parameters
Section titled “Parameters”number
Foot: x-value where membership starts rising from 0.
number
Shoulder: x-value where membership reaches 1.
Returns
Section titled “Returns”An SShapeShape.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”FuzzyShape.sShape(20, 80)// {"kind": "SShape", "a": 20, "b": 80}trapezoidal()
Section titled “trapezoidal()”
readonlytrapezoidal(a,b,c,d):TrapezoidalShape
Create a trapezoidal fuzzy membership function.
Parameters
Section titled “Parameters”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).
Returns
Section titled “Returns”A TrapezoidalShape.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”FuzzyShape.trapezoidal(18, 20, 24, 26)triangular()
Section titled “triangular()”
readonlytriangular(a,b,c):TriangularShape
Create a triangular fuzzy membership function.
Parameters
Section titled “Parameters”number
Left foot (membership = 0).
number
Peak (membership = 1).
number
Right foot (membership = 0).
Returns
Section titled “Returns”A TriangularShape: {"kind": "Triangular", "a": 20, "b": 22, "c": 24}.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”FuzzyShape.triangular(20, 22, 24)zShape()
Section titled “zShape()”
readonlyzShape(a,b):ZShapeShape
Create a Z-shaped (zmf) fuzzy membership function.
Mirror of sShape. Smooth monotonic spline from 1 to 0 using piecewise quadratic.
Parameters
Section titled “Parameters”number
Shoulder: x-value where membership starts falling from 1.
number
Foot: x-value where membership reaches 0.
Returns
Section titled “Returns”A ZShapeShape.
Remarks
Section titled “Remarks”Serialization format: Tagged by "kind" (FuzzyShapeDto).
Example
Section titled “Example”FuzzyShape.zShape(20, 80)// {"kind": "ZShape", "a": 20, "b": 80}Remarks
Section titled “Remarks”Discriminator field is "kind", NOT "type".
This differs from most other tagged unions in the API which use "type".
Example
Section titled “Example”import { FuzzyShape, Value } from '@kortexya/reasoninglayer';
const shape = FuzzyShape.triangular(20, 22, 24);const fuzzyAge = Value.fuzzyNumber(shape);