Package libai.fuzzy.defuzzifiers
Class CenterOfGravity
- java.lang.Object
-
- libai.fuzzy.defuzzifiers.Defuzzifier
-
- libai.fuzzy.defuzzifiers.CenterOfGravity
-
- Direct Known Subclasses:
CenterOfArea
public class CenterOfGravity extends Defuzzifier
Defuzzifier method that calculates the center of gravity of given function. Formally the center of gravity is Integral(x.f(x)) / Integral(f(x)) for the whole interval. This implementation uses Riemann's sums to calculate the integrals of both functions.
-
-
Field Summary
-
Fields inherited from class libai.fuzzy.defuzzifiers.Defuzzifier
COA, COG, MOM
-
-
Constructor Summary
Constructors Constructor Description CenterOfGravity()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getValue(java.util.List<java.awt.geom.Point2D.Double> function)
Implements the center of gravity by calculating the Riemann's sums of the area using the trapezoidal rule.protected double
riemmanSum(java.util.List<java.awt.geom.Point2D.Double> function)
protected double
riemmanSum(java.util.List<java.awt.geom.Point2D.Double> function, double maxX)
java.lang.String
toString()
-
Methods inherited from class libai.fuzzy.defuzzifiers.Defuzzifier
fromString
-
-
-
-
Method Detail
-
getValue
public double getValue(java.util.List<java.awt.geom.Point2D.Double> function)
Implements the center of gravity by calculating the Riemann's sums of the area using the trapezoidal rule. It assumes the x points are equally spaced across the whole domain of the function.- Specified by:
getValue
in classDefuzzifier
- Parameters:
function
- the list of points [x, f(x)] representing the function to analyze.- Returns:
- the center of gravity of the function.
-
riemmanSum
protected double riemmanSum(java.util.List<java.awt.geom.Point2D.Double> function)
-
riemmanSum
protected double riemmanSum(java.util.List<java.awt.geom.Point2D.Double> function, double maxX)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-