Skip to content

Commit 4cdeb39

Browse files
authored
Update gaussian_fuzzyset.py
1 parent b4a3e41 commit 4cdeb39

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

fuzzy_logic/gaussian_fuzzyset.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ class GaussianFuzzySet:
2727
is_complement: Indicates whether this is the complement
2828
of the original fuzzy set.
2929
Methods:
30-
membership(x): Calculate the membership value of an input 'x' in the fuzzy set.
31-
complement(): Create a new GaussianFuzzySet instance representing the complement.
30+
membership(member): Calculate the membership value of
31+
an input 'member'in the fuzzy set.
32+
complement(): Create a new GaussianFuzzySet instance representing
33+
the complement.
3234
plot(): Plot the membership function of the fuzzy set.
3335
3436
>>> fuzzy_set = GaussianFuzzySet("Medium Temperature", mean=25, std_dev=5)
@@ -45,9 +47,9 @@ class GaussianFuzzySet:
4547
std_dev: float
4648
is_complement: bool = False # This flag indicates if it's the complement set
4749

48-
def membership(self, x: float) -> float:
50+
def membership(self, member: float) -> float:
4951
"""
50-
Calculate the membership value of an input 'x' in the Gaussian fuzzy set.
52+
Calculate the membership value of an input 'member' in the Gaussian fuzzy set.
5153
If it's a complement set, returns 1 - the Gaussian membership.
5254
5355
>>> GaussianFuzzySet("Medium", 0, 1).membership(0)
@@ -56,7 +58,7 @@ def membership(self, x: float) -> float:
5658
0.6065306597126334
5759
"""
5860

59-
membership_value = np.exp(-0.5 * ((x - self.mean) / self.std_dev) ** 2)
61+
membership_value = np.exp(-0.5 * ((member - self.mean) / self.std_dev) ** 2)
6062
# Directly return for non-complement or return 1 - membership for complement
6163
return membership_value if not self.is_complement else 1 - membership_value
6264

@@ -74,7 +76,7 @@ def complement(self) -> GaussianFuzzySet:
7476
is_complement=not self.is_complement,
7577
)
7678

77-
def plot(self):
79+
def plot(self) -> None:
7880
"""
7981
Plot the membership function of the Gaussian fuzzy set.
8082
"""

0 commit comments

Comments
 (0)