Package fuzzy :: Package set :: Module ZFunction
[hide private]
[frames] | no frames]

Source Code for Module fuzzy.set.ZFunction

 1  # -*- coding: utf-8 -*- 
 2  # 
 3  # Copyright (C) 2009  Rene Liebscher 
 4  # 
 5  # This program is free software; you can redistribute it and/or modify it under 
 6  # the terms of the GNU Lesser General Public License as published by the Free  
 7  # Software Foundation; either version 3 of the License, or (at your option) any 
 8  # later version. 
 9  # 
10  # This program is distributed in the hope that it will be useful, but WITHOUT  
11  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
12  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 
13  # details. 
14  #  
15  # You should have received a copy of the GNU Lesser General Public License 
16  # along with this program; if not, see <http://www.gnu.org/licenses/>.  
17  # 
18   
19  """Realize a Z-shaped fuzzy set.""" 
20   
21  __revision__ = "$Id: ZFunction.py,v 1.17 2010-03-28 18:44:46 rliebscher Exp $" 
22   
23   
24  from fuzzy.set.SFunction import SFunction 
25   
26 -class ZFunction(SFunction):
27 r"""Realize a Z-shaped fuzzy set:: 28 __ 29 \ 30 |\ 31 | \ 32 | |\ 33 | | \__ 34 | a | 35 | | 36 2*delta 37 38 see also U{http://pyfuzzy.sourceforge.net/demo/set/ZFunction.png} 39 40 @ivar a: center of set. 41 @type a: float 42 @ivar delta: absolute distance between x-values for minimum and maximum. 43 @type delta: float 44 """ 45
46 - def __init__(self, a=0.0, delta=1.0):
47 """Initialize a Z-shaped fuzzy set. 48 49 @param a: center of set 50 @type a: float 51 @param delta: absolute distance between x-values for minimum and maximum 52 @type delta: float 53 """ 54 super(ZFunction, self).__init__(a, delta)
55 56
57 - def __call__(self, x):
58 """Return membership of x in this fuzzy set. 59 This method makes the set work like a function. 60 61 @param x: value for which the membership is to calculate 62 @type x: float 63 @return: membership 64 @rtype: float 65 """ 66 return 1.0 - SFunction.__call__(self, x)
67