# Explanation of Air Quality Data Using Takagi-Sugeno Fuzzy Inference System
## 3 Fuzzy Sets and Fuzzy Logic
Mathematically, we write it as follows:  
\[\mu_{H}:\mathbb{X}\rightarrow[0,1],\ \ \mu_{H}(x)= \begin{cases}\frac{x-20}{10},&x\in[ 20,30],\\ 1,&x\in[30,35],\\ \frac{40-x}{5},&x\in[35,40],\\ 0,&x\in[0,20]\&40,50].\end{cases}  \tag{2}\]  
Figure 2: Example of trapezoidal membership function. This type of membership function is called the trapezoidal membership function. Note that we can uniquely determine such functions by using four parameters \([a\ b\ c\ d]\). For the function displayed in Figure 2, these parameters are \([20\ 30\ 35\ 40]\), i.e., the first coordinates of points \(A\), \(B\), \(C\) and \(D\). Notation using four coordinates is also used in MATLAB software. As we can see, we chose these values as integers. Since the values of these parameters significantly affect the result, even a small change in the parameter values can lead to a significant improvement in the overall result. Various optimisation methods are used to find more accurate values. They are often incorporated into software for working with fuzzy sets. There is a large number of different types of membership functions. When we want to capture expert knowledge, we usually use the mentioned trapezoidal membership function (for examples of such uses, see [23; 24]). When we have a sufficient number of data, we can obtain the membership functions by approximating the considered values with the chosen function. In our work, we chose the so-called Gaussian membership function to approximate the data. The Gaussian function has a general prescription:  
\[f(x)=a\mathrm{e}^{-\frac{(x-b)^{2}}{2\epsilon^{2}}} \tag{3}\]  
where \(\mathrm{e}\) is Euler's constant, \(a\) is the height of the curve's peak, \(b\) is the position of the centre of the peak and \(c\) is the standard deviation. Figure 3 displays the membership function of the fuzzy set _high temperature in summer_ using the Gaussian membership function. Note that this function has just two parameters \([u\ v]\). In MATLAB software, parameter \(u\) represents the standard deviation of the curve, and parameter \(v\) represents the position of the centre of the curve peak. When using the fuzzy set approach, the height of this curve is always equal to one. Figure 3 displays the Gaussian membership function with \(u=9\) and \(v=32.5\), i.e.,  
\[\mu_{H}(x)=\mathrm{e}^{-\frac{(x-32.5)^{2}}{2(9\epsilon^{2}}}. \tag{4}\]  
Similarly to the trapezoidal membership functions, when using these functions in real applications, it is necessary to optimise the function parameters. When analysing data by using fuzzy sets, each input variable needs to be described with several membership functions. For example, the input variable _Air temperature_ can obtain the values _low air temperature_, _middle air temperature_ and _high air temperature_. This allows us to create a set of human-friendly rules which consists of the statements like _If the temperature is high and the wind speed is low, then there is a lot of particular matter in the air_. Several fuzzy inference systems have been developed to work with such rules. The most used of these are the Mamdani fuzzy inference system (see [25]) and the Takagi-Sugeno fuzzy inference system (see [6]). For the Mamdani FIS, it is typical that the variables are determined by using fuzzy sets in both the assumptions and conclusions of the rule. Figure 3: Example of Gaussian membership function. To determine the output of the system, a process of defuzzification is needed, in which the fuzzy set is transformed into a specific number. This transformation is commonly computationally demanding and time-consuming. Since, in our work, we consider a sizable Smart City system, which needs to be able to analyse data in close-to-real time, we are not able to use the Mamdani FIS. The input variables of the Takagi-Sugeno FIS are defined by using fuzzy sets as in the case of the Mamdani FIS. However, the output variables of this system are determined by using simple functions (linear or constant functions).