2016-12-22 20:15:07 +04:00
|
|
|
import numpy as np
|
|
|
|
import math
|
|
|
|
from pyFTS import *
|
|
|
|
|
|
|
|
|
|
|
|
def trimf(x, parameters):
|
|
|
|
xx = round(x, 3)
|
2017-04-01 03:34:12 +04:00
|
|
|
if xx < parameters[0]:
|
2016-12-22 20:15:07 +04:00
|
|
|
return 0
|
2017-04-01 03:34:12 +04:00
|
|
|
elif parameters[0] <= xx < parameters[1]:
|
2016-12-22 20:15:07 +04:00
|
|
|
return (x - parameters[0]) / (parameters[1] - parameters[0])
|
2017-04-01 03:34:12 +04:00
|
|
|
elif parameters[1] <= xx <= parameters[2]:
|
2016-12-22 20:15:07 +04:00
|
|
|
return (parameters[2] - xx) / (parameters[2] - parameters[1])
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
def trapmf(x, parameters):
|
2017-04-01 03:34:12 +04:00
|
|
|
if x < parameters[0]:
|
2016-12-22 20:15:07 +04:00
|
|
|
return 0
|
2017-04-01 03:34:12 +04:00
|
|
|
elif parameters[0] <= x < parameters[1]:
|
2016-12-22 20:15:07 +04:00
|
|
|
return (x - parameters[0]) / (parameters[1] - parameters[0])
|
2017-04-01 03:34:12 +04:00
|
|
|
elif parameters[1] <= x <= parameters[2]:
|
2016-12-22 20:15:07 +04:00
|
|
|
return 1
|
2017-04-01 03:34:12 +04:00
|
|
|
elif parameters[2] <= x <= parameters[3]:
|
2016-12-22 20:15:07 +04:00
|
|
|
return (parameters[3] - x) / (parameters[3] - parameters[2])
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
def gaussmf(x, parameters):
|
2016-12-26 21:47:23 +04:00
|
|
|
return math.exp((-(x - parameters[0])**2)/(2 * parameters[1]**2))
|
|
|
|
#return math.exp(-0.5 * ((x - parameters[0]) / parameters[1]) ** 2)
|
2016-12-22 20:15:07 +04:00
|
|
|
|
|
|
|
|
|
|
|
def bellmf(x, parameters):
|
|
|
|
return 1 / (1 + abs((x - parameters[2]) / parameters[0]) ** (2 * parameters[1]))
|
|
|
|
|
|
|
|
|
|
|
|
def sigmf(x, parameters):
|
|
|
|
return 1 / (1 + math.exp(-parameters[0] * (x - parameters[1])))
|