Mean, median, and mode

We begin our explorative analysis by calculating the maximum, mean, and minimum of the newly imported table. MATLAB calculates these statistics independently for each column in the table. For this purpose, we use three useful functions: max(), mean(),and min().

To find the maximum value of oxide content (from the third column to the eighth, representing oxide content of Na, Mg, Al, Si, K, and Ca), using curly braces, {}, simply type the following command:

>> Max = max(GlassIdentificationDataSet{:,3:8})
Max =
17.3800 4.4900 3.5000 75.4100 6.2100 16.1900

This way, we get the maximum values in each of the specified columns. To calculate the mean of the same columns, we will write the command shown here:

>> Mean = mean(GlassIdentificationDataSet{:,3:8})
Mean =
13.4079 2.6845 1.4449 72.6509 0.4971 8.9570

To find the minimum value in each column, we use the following command:

>> Min = min(GlassIdentificationDataSet{:,3:8})
Min =
10.7300 0 0.2900 69.8100 0 5.4300

It may be useful to identify the records in which minimum and maximum are found; to get this information, just specify a second output parameter to return the row index. For example:

>> [Max,IndRowMax] = max(GlassIdentificationDataSet{:,3:8})
Max =
17.3800 4.4900 3.5000 75.4100 6.2100 16.1900
IndRowMax =
185 1 164 185 172 108

>> [Min,IndRowMin] = min(GlassIdentificationDataSet{:,3:8})
Min =
10.7300 0 0.2900 69.8100 0 5.4300
IndRowMin =
107 106 22 107 64 186

Additionally, using MATLAB's built-in functions, we can calculate median and mode. Recall that the median represents the intermediate value between the extremes of a set of data. MATLAB calculates the median for each column with the median() function:

>> Median = median(GlassIdentificationDataSet{:,3:8})
Median =
13.3000 3.4800 1.3600 72.7900 0.5550 8.6000

The mode is the value that appears most often in a set of data. MATLAB calculates the mode for each column with the mode() function:

>> Mode = mode(GlassIdentificationDataSet{:,3:8})
Mode =
13.0000 0 1.5400 72.8600 0 8.0300

When there are multiple values occurring equally frequently, mode returns the smallest of those values.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset