@@ -138,23 +138,27 @@ def membership(self, x: float) -> float:
138
138
msg = f"Invalid value { x } for fuzzy set { self } "
139
139
raise ValueError (msg )
140
140
141
- def union (self , other ) -> FuzzySet :
142
- """
143
- Calculate the union of this fuzzy set with another fuzzy set.
144
- Args:
145
- other (FuzzySet): Another fuzzy set to union with.
146
- Returns:
147
- FuzzySet: A new fuzzy set representing the union.
148
-
149
- >>> FuzzySet("a", 0.1, 0.2, 0.3).union(FuzzySet("b", 0.4, 0.5, 0.6))
150
- FuzzySet(name='a U b', left_boundary=0.1, peak=0.6, right_boundary=0.35)
151
- """
152
- return FuzzySet (
153
- f"{ self .name } U { other .name } " ,
154
- min (self .left_boundary , other .left_boundary ),
155
- max (self .right_boundary , other .right_boundary ),
156
- (self .peak + other .peak ) / 2 ,
157
- )
141
+ def union (self , other : FuzzySet ) -> FuzzySet :
142
+ """
143
+ Calculate the union of this fuzzy set with another fuzzy set.
144
+ The union of two fuzzy sets is determined by taking the maximum
145
+ membership value at each point.
146
+
147
+ Args:
148
+ other (FuzzySet): Another fuzzy set to union with.
149
+
150
+ Returns:
151
+ FuzzySet: A new fuzzy set representing the union.
152
+
153
+ >>> FuzzySet("a", 0.1, 0.2, 0.3).union(FuzzySet("b", 0.4, 0.5, 0.6))
154
+ FuzzySet(name='a U b', left_boundary=0.1, peak=0.5, right_boundary=0.6)
155
+ """
156
+ return FuzzySet (
157
+ f"{ self .name } U { other .name } " ,
158
+ min (self .left_boundary , other .left_boundary ),
159
+ max (self .peak , other .peak ),
160
+ max (self .right_boundary , other .right_boundary )
161
+ )
158
162
159
163
def plot (self ):
160
164
"""
0 commit comments