86 - Assignment-3 DS Lab
86 - Assignment-3 DS Lab
Aim:
Implementat Fuzzy set operations and Membership Functions.
Theory:
Fuzzy sets are a mathematical concept that extend classical set theory by
allowing elements to have degrees of membership between 0 and 1, rather
than simply belonging or not belonging to the set. This allows for a more
nuanced representation of data, particularly when dealing with imprecise or
vague information.
A fuzzy set is defined as a pair (U, m), where U is a set (often required to be
non-empty) and m is a membership function. The membership function maps
each element in U to a real number in the interval [0, 1], representing the
degree of membership of the element in the fuzzy set. Elements with a
membership value of 1 are fully included in the set, while elements with a
Fuzzy sets allow for the representation of uncertainty and vagueness in data,
and several operations can be performed on them. Here are the primary
operations associated with fuzzy sets:
The union of two fuzzy sets A and B is a fuzzy set Y that contains all elements
from both sets. The degree of membership for each element in the union is
defined as:
This means that the membership degree in the union is the highest degree
of membership from either set.
Example:
Let A = {(a, 0.2), (b, 0.5)} and B = {(a, 0.7), (c, 0.4)} . The union Y would be:
The intersection of two fuzzy sets A and B is a fuzzy set Y that consists of
elements that are common to both sets. The degree of membership for each
element in the intersection is defined as:
This means that the membership degree in the intersection is the lowest
degree of membership from either set.
Example:
Using the same sets A and B :
Example:
For a fuzzy set A = {(a, 0.2), (b, 0.5)} :
4. Other Operations
a. Scalar Multiplication
This operation scales the membership values of a fuzzy set by a constant α
. If α is in the range [0, 1], the membership values are simply multiplied by α
. If α > 1 , values are capped at 1.
b. Fuzzy Relations
Fuzzy sets can also be used to define fuzzy relations, which extend the
concept of binary relations by allowing degrees of relation between elements.
● Use Case: Useful in situations where a clear peak and linear decrease
are desired, such as in linguistic terms like "medium."
def fuzzy_complement(A):
return 1 - A
# Example usage
x = np.linspace(0, 10, 100)
# Perform operations
union_set = fuzzy_union(triangular_set, trapezoidal_set)
intersection_set = fuzzy_intersection(triangular_set, gaussian_set)
complement_set = fuzzy_complement(triangular_set)
plt.subplot(2, 2, 1)
plt.plot(x, triangular_set, label='Triangular')
plt.title('Triangular Membership Function')
plt.grid(True)
plt.subplot(2, 2, 2)
plt.plot(x, trapezoidal_set, label='Trapezoidal')
plt.title('Trapezoidal Membership Function')
plt.grid(True)
plt.subplot(2, 2, 3)
plt.plot(x, gaussian_set, label='Gaussian')
plt.title('Gaussian Membership Function')
plt.grid(True)
plt.subplot(2, 2, 4)
plt.grid(True)
plt.tight_layout()
plt.show()
# Display results of operations
plt.figure(figsize=(12, 8))
plt.subplot(2, 2, 1)
plt.title('Union Operation')
plt.grid(True)
plt.subplot(2, 2, 2)
plt.title('Intersection Operation')
plt.grid(True)
plt.subplot(2, 2, 3)
plt.title('Complement Operation')
plt.grid(True)
Conclusion:
In conclusion, fuzzy sets provide a robust framework for dealing with
uncertainty and partial truths, extending traditional set theory to better handle
real-world complexities. By allowing elements to have varying degrees of
membership, fuzzy sets offer a more nuanced approach to modeling and
reasoning compared to binary sets. The operations on fuzzy sets—such as
union, intersection, and complement—enable effective manipulation and
combination of fuzzy information, making them invaluable in fields like control
systems, decision-making, and pattern recognition.