mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-05-18 23:21:28 +00:00
Merge branch 'master' of https://github.com/Shreya123714/Python
This commit is contained in:
commit
cb77a2a22d
@ -10,7 +10,7 @@ import numpy as np
|
|||||||
|
|
||||||
class FuzzySet:
|
class FuzzySet:
|
||||||
"""
|
"""
|
||||||
A class for representing and
|
A class for representing and
|
||||||
manipulating triangular fuzzy sets.
|
manipulating triangular fuzzy sets.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
@ -20,27 +20,29 @@ class FuzzySet:
|
|||||||
c (float): The right boundary of the fuzzy set.
|
c (float): The right boundary of the fuzzy set.
|
||||||
|
|
||||||
Methods:
|
Methods:
|
||||||
membership(x): Calculate the membership value
|
membership(x): Calculate the membership value
|
||||||
of an input 'x' in the fuzzy set.
|
of an input 'x' in the fuzzy set.
|
||||||
union(other): Calculate the union of this fuzzy set
|
union(other): Calculate the union of this fuzzy set
|
||||||
with another fuzzy set.
|
with another fuzzy set.
|
||||||
intersection(other): Calculate the intersection of this fuzzy set
|
intersection(other): Calculate the intersection of this fuzzy set
|
||||||
with another fuzzy set.
|
with another fuzzy set.
|
||||||
complement(): Calculate the complement (negation)
|
complement(): Calculate the complement (negation)
|
||||||
of this fuzzy set.
|
of this fuzzy set.
|
||||||
plot(): Plot the membership function of the fuzzy set.
|
plot(): Plot the membership function of the fuzzy set.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name: str, left_boundary: float, peak: float, right_boundary: float) -> None:
|
def __init__(self, name: str, left_boundary: float, peak: float, right_boundary: float) -> None:
|
||||||
"""
|
"""
|
||||||
Initializes a triangular fuzzy set with the given parameters.
|
Initializes a triangular fuzzy set
|
||||||
|
with the given parameters.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
name (str): The name or label of the fuzzy set.
|
name (str): The name or label of the fuzzy set.
|
||||||
left_boundary (float): The left boundary of the fuzzy set.
|
a (float): The left boundary of the fuzzy set.
|
||||||
peak (float): The peak (central) value of the fuzzy set.
|
b (float): The peak (central) value of
|
||||||
right_boundary (float): The right boundary of the fuzzy set.
|
the fuzzy set.
|
||||||
"""
|
c (float): The right boundary of the fuzzy set.
|
||||||
|
"""
|
||||||
self.name = name # Fuzzy set name
|
self.name = name # Fuzzy set name
|
||||||
self.left_boundary = left_boundary # Left boundary
|
self.left_boundary = left_boundary # Left boundary
|
||||||
self.peak = peak # Peak value
|
self.peak = peak # Peak value
|
||||||
@ -49,15 +51,15 @@ class FuzzySet:
|
|||||||
|
|
||||||
def membership(self, x):
|
def membership(self, x):
|
||||||
"""
|
"""
|
||||||
Calculate the membership value of
|
Calculate the membership value of
|
||||||
an input 'x' in the fuzzy set.
|
an input 'x' in the fuzzy set.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
x (float): The input value for
|
x (float): The input value for
|
||||||
which the membership is calculated.
|
which the membership is calculated.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
float: The membership value of 'x' in
|
float: The membership value of 'x' in
|
||||||
the fuzzy set.
|
the fuzzy set.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -70,7 +72,7 @@ class FuzzySet:
|
|||||||
|
|
||||||
def union(self, other):
|
def union(self, other):
|
||||||
"""
|
"""
|
||||||
Calculate the union of this fuzzy set
|
Calculate the union of this fuzzy set
|
||||||
with another fuzzy set.
|
with another fuzzy set.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -78,7 +80,7 @@ class FuzzySet:
|
|||||||
to union with.
|
to union with.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
FuzzySet: A new fuzzy
|
FuzzySet: A new fuzzy
|
||||||
set representing the union.
|
set representing the union.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -92,7 +94,7 @@ class FuzzySet:
|
|||||||
|
|
||||||
def intersection(self, other):
|
def intersection(self, other):
|
||||||
"""
|
"""
|
||||||
Calculate the intersection of this
|
Calculate the intersection of this
|
||||||
fuzzy set with another fuzzy set.
|
fuzzy set with another fuzzy set.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user