# Problem solving on scatter matrix

**Prerequisite : **Scatter Plot Matrix

We calculate S_{w }( within class scatter matrix )_{ }and S_{B} ( between class scatter matrix ) for the available data points.

S_{W }: To minimize variability within a class, inner class scatter.

S_{B }: To increase between class variability, between class scatter.

X1 = (y1, y2) ={ (2,2), (1,2), (1,2), (1,2), (2,2) } X2 = (y1,y2) ={ (9, 10), (6,8), (9,5), (8,7), (10,8) }

**Within class scatter matrix :**

S_{i}is the class specific covariance matrix. m_{i}is the mean of indivisual class

**Mean computation :**

We calculate the mean for each of the points present in the class. Here mean is the total sum of observations divided by the number of observations, we require this mean fot calculating the covariance of the matrix.

**Covariance matrix computation :**

We subtract the mean value from each of the observation and then we calculate the average after performing the matrix multiplication with the transpose of the matrix.

**Class specific covariance for the first class :**

Averaging values from 1,2,3,4 and 5.

We calculate the sum of all the values for each element in the matrix for S1 and divide by the number of the observation which in the present computation is 5.

Therefore S_{1 }is :

**Class specific covariance for the second class :**

Averaging values from 1,2,3,4 and 5

we calculate the sum of all the values for each element in the matrix for S2 and divide by the number of the observation which in the present computation is 5.

Therefore S2 is :

**Within class scatter matrix S _{w }:**

S_{W }= S_{1}+ S_{2}

**Between class scatter matrix S _{B }:**

**Total scatter matrix :**

S_{T = SB + SW}

Therefore we have calculated between class scatter matrix and within class scatter matrix for the available data points.

We make use of these computations in feature extraction , where the main goal is to increase the distance between the class in the projection of points and decrease the distance between the points within the class in the projection. Here we aim at generating data projection at the required dimension.