- Partition function on FuzzySet

This commit is contained in:
Petrônio Cândido 2017-08-17 15:40:35 -03:00
parent 7a7ff4f3e3
commit b672cdf08a

View File

@ -19,6 +19,8 @@ class FuzzySet:
self.mf = mf self.mf = mf
self.parameters = parameters self.parameters = parameters
self.centroid = centroid self.centroid = centroid
":param Z: Partition function in respect to the membership function"
self.Z = None
if self.mf == Membership.trimf: if self.mf == Membership.trimf:
self.lower = min(parameters) self.lower = min(parameters)
self.upper = max(parameters) self.upper = max(parameters)
@ -34,6 +36,14 @@ class FuzzySet:
""" """
return self.mf(x, self.parameters) return self.mf(x, self.parameters)
def partition_function(self,uod=None, nbins=100):
if self.Z is None and uod is not None:
self.Z = 0.0
for k in np.linspace(uod[0], uod[1], nbins):
self.Z += self.membership(k)
else:
return self.Z
def __str__(self): def __str__(self):
return self.name + ": " + str(self.mf.__name__) + "(" + str(self.parameters) + ")" return self.name + ": " + str(self.mf.__name__) + "(" + str(self.parameters) + ")"