C# Class Accord.Fuzzy.FuzzySet

The class represents a fuzzy set.

The fuzzy sets are the base for all fuzzy applications. In a classical set, the membership of a given value to the set can always be defined as true (1) or false (0). In fuzzy sets, this membership can be a value in the range [0..1], representing the imprecision existent in many real world applications.

Let us consider, for example, fuzzy sets representing some temperature. In a given application, there is the need to represent a cool and warm temperature. Like in real life, the precise point when the temperature changes from cool to warm is not easy to find, and does not makes sense. If we consider the cool around 20 degrees and warm around 30 degrees, it is not simple to find a break point. If we take the mean, we can consider values greater than or equal 25 to be warm. But we can still consider 25 a bit cool. And a bit warm at the same time. This is where fuzzy sets can help.

Fuzzy sets are often used to compose Linguistic Variables, used in Fuzzy Inference Systems.

Sample usage:

// creating 2 fuzzy sets to represent Cool and Warm TrapezoidalFunction function1 = new TrapezoidalFunction( 13, 18, 23, 28 ); FuzzySet fsCool = new FuzzySet( "Cool", function1 ); TrapezoidalFunction function2 = new TrapezoidalFunction( 23, 28, 33, 38 ); FuzzySet fsWarm = new FuzzySet( "Warm", function2 ); // show membership to the Cool set for some values Console.WriteLine( "COOL" ); for ( int i = 13; i <= 28; i++ ) Console.WriteLine( fsCool.GetMembership( i ) ); // show membership to the Warm set for some values Console.WriteLine( "WARM" ); for ( int i = 23; i <= 38; i++ ) Console.WriteLine( fsWarm.GetMembership( i ) );
Exibir arquivo Open project: accord-net/framework Class Usage Examples

Public Methods

Method Description
FuzzySet ( string name, IMembershipFunction function ) : System

Initializes a new instance of the FuzzySet class.

GetMembership ( float x ) : float

Calculate membership of a given value to the fuzzy set.

Method Details

FuzzySet() public method

Initializes a new instance of the FuzzySet class.
public FuzzySet ( string name, IMembershipFunction function ) : System
name string Name of the fuzzy set.
function IMembershipFunction Membership function that will define the shape of the fuzzy set.
return System

GetMembership() public method

Calculate membership of a given value to the fuzzy set.
public GetMembership ( float x ) : float
x float Value which membership needs to be calculated.
return float