Descriptive Statistics in Matlab
Descriptive Statistics in Matlab
A. Preparing Data
Consider the hypothetical data below:
1. Manual
Input: >>A=[2.27 0.75 1 0.43 3.6; 27 21 36 34 69; 4920 4113 6072 4024 3562]
Output:
A=
2.27 0.75 1 0.43 3.6
27 21 36 34 69
4920 4113 6072 4024 3562
Note: Values appear in horizontal (row) form with “space” as delimiter and “;” as row
identifier. Use “ ‘ “ to create 3 columns (that is, transpose).
Input: >>A=[2.27 0.75 1 0.43 3.6; 27 21 36 34 69; 4920 4113 6072 4024 3562]’
Output:
A=
2.27 27 4920
0.75 21 4113
1 36 6072
0.43 34 4024
3.6 69 3562
2. Importing data file:
Input: >>A=readtable(file_name.xlsx) %make sure that the file is in the current directory
Output:
A=
Acres Age Taxes
2.27 27 4920
0.75 21 4113
1 36 6072
0.43 34 4024
3.6 69 3562
Central Values
>>mean(A) %calculates the mean
>>median(A) %calculates the median
>>mode(A) %finds the mode
>>geomean(A) %calculates the geometric mean
>>harmmean(A) % calculates the harmonic mean
>>trimmean(A,10) % calculates the 10% trimmed mean
Percentiles
>>prctile(A,84) %calculates the 84th percentile of data A. This can also be used to find
other quantiles, like “>>prctile(A,75)” will calculate the third quartile
while “>>prctile(A,40)” will calculate the 4th decile.
Variations/Dispersion
>>std(A) % calculates the standard deviation
>>var(A) % calculates the variance
>>range(A) % calculates the range
>>mad(A) % calculates the mean absolute deviation
>>iqr(A) % calculates the Interquartile Range
Shapes
>>skewness(A)
>>kurtosis(A)