From b672cdf08a75370e22fdc268ebd659f199ef4d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=C3=B4nio=20C=C3=A2ndido?= Date: Thu, 17 Aug 2017 15:40:35 -0300 Subject: [PATCH] - Partition function on FuzzySet --- pyFTS/common/FuzzySet.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pyFTS/common/FuzzySet.py b/pyFTS/common/FuzzySet.py index cc2d934..31f947e 100644 --- a/pyFTS/common/FuzzySet.py +++ b/pyFTS/common/FuzzySet.py @@ -19,6 +19,8 @@ class FuzzySet: self.mf = mf self.parameters = parameters self.centroid = centroid + ":param Z: Partition function in respect to the membership function" + self.Z = None if self.mf == Membership.trimf: self.lower = min(parameters) self.upper = max(parameters) @@ -34,6 +36,14 @@ class FuzzySet: """ 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): return self.name + ": " + str(self.mf.__name__) + "(" + str(self.parameters) + ")"