def generate_mf_group(self, G, x): mf_group = {} for (k, v) in G.iteritems(): shp = v['shp'] mf = v['mf'] if mf == 'trap': mf_group[k] = trapmf(x, shp) if mf == 'tri': mf_group[k] = trimf(x, shp) if mf == 'gbell': mf_group[k] = gbellmf(x, shp[0], shp[1], shp[2]) if mf == 'gauss': mf_group[k] = gaussmf(x, shp[0], shp[1]) if mf == 'gauss2': mf_group[k] = gauss2mf(x, shp[0], shp[1]) if mf == 'sig': mf_group[k] = sigmf(x, shp[0], shp[1]) if mf == 'psig': mf_group[k] = psigmf(x, shp[0], shp[1], shp[2], shp[3]) if mf == 'zmf': mf_group[k] = zmf(x, shp[0], shp[1], shp[2], shp[3]) if mf == 'smf': mf_group[k] = smf(x, shp[0], shp[1], shp[2], shp[3]) if mf == 'pimf': mf_group[k] = pimf(x, shp[0], shp[1], shp[2], shp[3]) if mf == 'piecemf': mf_group[k] = piecemf(x, shp[0], shp[1], shp[2], shp[3]) return mf_group
def test_gbellmf(): x = np.arange(-4, 5.1, 0.1) a, b, c = (2.4, 0.9, 1.33) expected = 1 / (1 + np.abs(np.r_[x - c] / a)**[2 * b]) test = gbellmf(x, a, b, c) assert_allclose(test, expected)
def test_gbellmf(): x = np.arange(-4, 5.1, 0.1) a, b, c = (2.4, 0.9, 1.33) expected = 1 / (1 + np.abs(np.r_[x - c] / a) ** [2 * b]) test = gbellmf(x, a, b, c) assert_allclose(test, expected)
def field(A0,Td,w,t): #potenziale vettore assumendo return A0 *(((np.cos((t-Td/2)*pi/Td))**2)* np.sin(w*(t-Td/2)) * fuzzy.gaussmf(t-Td/2,0,Td/4) * fuzzy.gbellmf(t-Td/2,Td/4,7,0)) #inviluppo cos^2
def fl_bellmf(x, center, width, slope): '''Like gbellmf, but fuzzylite supplies parameters in a different order''' return skmemb.gbellmf(x, width, slope, center)