Homework 5 Problem 1 Write the formula for the COA defuzzification strategy when we have a finite universe of discourse X = {x1, x2, x3,…xn} where x1<…<xn. π(π₯)ππ π‘βπ ππππππ ππ’πππ‘πππ πππππππ ππ¦ π ππΆππ΄ = ∑ππ=1 π(π₯π )π₯π ππ₯ ∑ππ=1 π(π₯π ) ππ₯ Problem 2 Use COA, BOA and MOM defuzzification strategies to find the representative values for the overall implied fuzzy set A defined by µA(x)=trapezoid(x, 10, 30, 50, 90) 1 0.5 0 ππΆππ΄ 0 10 20 30 40 50 60 70 80 90 30 π₯ − 10 50 90 90 − π₯ ∫10 (30 − 10) π₯ ππ₯ + ∫30 (1)π₯ ππ₯ + ∫50 (90 − 50) π₯ ππ₯ = = = ππ 30 π₯ − 10 50 90 90 − π₯ ∫π ππ΄ (π₯) ππ₯ (1) ( ) ππ₯ + ππ₯ + ( ) ππ₯ ∫10 30 − 10 ∫30 ∫50 90 − 50 ∫π ππ΄ (π₯)π₯ ππ₯ ππ΅ππ΄ ππ΅ππ΄ => ∫ max(π₯) ππ΄ (π₯)ππ₯ = ∫ min(π₯) 30 ∫ 10 ππ΄ (π₯)ππ₯ ππ΅ππ΄ ππ΅ππ΄ 50 90 π₯ − 10 90 − π₯ (1)ππ₯ = ∫ (1) ππ₯ + ∫ ( ( ) ππ₯ + ∫ ) ππ₯ 30 − 10 90 − 50 30 ππ΅ππ΄ 50 10 + ππ΅ππ΄ − 30 = 50 − ππ΅ππ΄ + 20 50 + 20 + 30 − 10 ππ΅ππ΄ = = ππ 2 ππππ = ∫π′ (1)π₯ ππ₯ ∫π′ (1) ππ₯ 50 = ∫30 (1)π₯ ππ₯ 50 ∫30 (1) ππ₯ = 800 = ππ 20 100 Problem 3 % % % % % % Simplified Product Fuzzy Inference Engine with Fuzzy Singleton Inputs -4 Rule, 2 Input -Product Inference Engine -Gaussian and Sigmoidal membership functions -MFs are normal (there is a max that equals 1) -Center Average Deffuzificaition % X and Y universes X_universe = -5:.1:5; Y_universe = -5:.1:5; % Initialize output space z_out = zeros(length(X_universe), length(Y_universe)); % Generic equations for the problem sigmoid=@(x,a,c) (1/(1+exp(-a*(x-c)))); gaussian=@(x,s,c) exp(-1/2*((x-c)/s)^2); % Input Membership functions ux_small=@(x) sigmoid(x, -3, 0); ux_large=@(x) sigmoid(x, 3, 0); uy_small=@(y) sigmoid(y, -0.9, 0); uy_large=@(y) sigmoid(y, 0.9, 0); % Rule output Centers c_negLarge=-3.5; c_negSmall=-1.7; c_posSmall=1.7; c_posLarge=3.5; % Intermediate Arrays to hold values during calculations w=zeros(1,4); % Rule Weights rc=zeros(1,4); % Rule Contribution % Calculate the Rule surface by traversing through X and Y for xIndex=1:length(X_universe), for yIndex=1:length(Y_universe), x=X_universe(xIndex); y=Y_universe(yIndex); % Rule 1 if x is small and y is small them z is negative large w(1) = ux_small(x) * uy_small(y); rc(1) = w(1)* c_negLarge; % Rule 2 if x is small and y is large them z is negative small w(2) = ux_small(x) * uy_large(y); rc(2) = w(2)* c_negSmall; % Rule 3 if x is large and y is small them z is positive small w(3) = ux_large(x) * uy_small(y); rc(3) = w(3)* c_posSmall; % Rule 4 if x is large and y is large them z is positive large w(4) = ux_large(x) * uy_large(y); rc(4) = w(4)* c_posLarge; % Deffuzify z_out(yIndex, xIndex) = sum(rc) / sum(w); end end figure(1); mesh(X_universe, Y_universe, z_out); axis([-5 5 -5 5 -4 4]); box off; title({'Product Inference Engine with Center Average Deffuzification', '4 Rules, 2 Inputs'}); xlabel('X'); ylabel('Y'); zlabel('Fuzzy System Rule Surface');