Descriptive Statistics and More Mathematical Built-In Functions

In today’s lesson, we are going to discuss the following topics:

1. Calculating Statistical Values (Descriptive Statistics)

2. Sum and Product Functions

VIDEO COMING SOON!

Descriptive Statistics

Descriptive statistics are statistical values that describe information in a set of data so it is easier to analyze. Here is a table of different MATLAB statistical analysis functions. Let’s go through them one by one:

(a) Finding the mean of a dataset

Use mean( ), with the dataset you want to find the mean of within the brackets

(b) Finding the median of a dataset

Use median( ), with the dataset you want to find the median of within the brackets

(c) Finding the mode of a dataset

Use mode( ), with the dataset you want to find the median of within the brackets

(d) Finding the standard deviation of a dataset

Use std( ), with the dataset you want to find the median of within the brackets

(e) Finding the variance of a dataset

Use var( ), with the dataset you want to find the median of within the brackets

(f) Finding the correlation coefficient

This one isn’t in the list, but the correlation coefficient of a set of data tells how strong of a linear relationship that data has. For example, say we have two datasets A and B. To find the correlation coefficient between them, use the syntax corrcoef(A,B). This is what I have done below:

The correlation coefficient can range from -1 to 1. The closer the correlation coefficient is to 1, the stronger the linear relationship is between the variables. The closer it is to -1, the weaker the linear relationship is between the variables (there is an anticorrelation). If the value is close to or equal to 0, there is no linear relationship between the variables.

Here, the output for the coefficient is 0.9839, indicating a strong linear relationship between the variables.

Built-In Functions – Sum and Product

Some other built-in functions that can come in useful are the sum and product functions. I have done examples with each of them using the vector a = [ 1 2 3 4 5]

(a) Finding the sum of a dataset

Use the function sum( ) with the dataset you want to find the sum of within the brackets. This adds all the numbers in the dataset

(b) Finding the product of the dataset

Use the function prod( ) with the dataset you want to find the product of within the brackets. This multiplies all the numbers in the dataset.