Package fuzzy :: Package norm :: Module SchweizerUnion2
[hide private]
[frames] | no frames]

Source Code for Module fuzzy.norm.SchweizerUnion2

 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  __revision__ = "$Id: SchweizerUnion2.py,v 1.9 2010-01-21 20:55:51 rliebscher Exp $" 
20   
21  from fuzzy.norm.ParametricNorm import ParametricNorm 
22  from fuzzy.utils import inf_p 
23   
24 -class SchweizerUnion2(ParametricNorm):
25 26 _range = [ (0.,inf_p) ] 27
28 - def __init__(self, param=1.):
30
31 - def __call__(self, *args):
32 x, y = self.checkArgs2(args) 33 p = self.p 34 if 1.-x == 0. or 1.-y == 0.: 35 return 1. 36 def f(x,p): 37 return 1./pow(1.-x,p)
38 return 1.0-1.0/pow(f(x,p)+f(y,p)-1.0,1.0/p)
39