I have 2 types of fuzzy function => triangle and trapazoid .. the triangle function take value and 3 points ( a,b,c's of triangle) and the trapazoid take value and 4 points ( a,b,c,d's of trapazoid )
i use the line equation to calculate the fuzzy value but the problem here is that function work if the points of set is like that [0,10,20,30] or [10,20,30,40] but when the set is [0,0,10,20] i got error cause of dividing on zero so it is possible to solve this problem using this equations This is triangle equation
def triangular(x, a, b, c):
return max(min((x - a) / (b - a), (c - x) / (c - b)), 0)
def trap(x, a, b, c, d):
return max(min((x - a) / (b - a), 1, (d - x) / (d - c)), 0)