Friday, February 11, 2011

Statistics operators mean and stdev

Hi everyone, it's so much time without posts, but it's a new one for you.

Let's see anything about two functions very useful in statistics: mean() and stdev().

The function mean() returns the mean of a set of data, e. g. vectors, matrices, etc. and the function stdev() returns the standard deviation of a set of data.

Let's try some examples now.

-->x = rand(1, 3)
 x  =

    0.1708866    0.9025495    0.4888218 

 ans  =


 ans  =


These functions are useful mainly in data mining, for example: two sets of data are given x and y (each data point has two dimensions), and it's necessary to identify a region in the data space for each set.

For starting, we create the sets of data:

x = rand(50, 2) + 1; // see this link
y = rand(50, 2, 'normal');

For determining the regions, we use the functions mean() and stdev()

mean_x = mean(x, 'r');
mean_y = mean(y, 'r');

mean_x and mean_y are the centers of the sets of data, where each one has two components: mean_x = [x_xm x_ym] and mean_y = [y_xm y_ym]

std_x = stdev(x);
std_y = stdev(y);

std_x and std_y are the distance from the centers to the boundaries of each region that we were looking for, or we can use a multiple of the standard deviation.

In the example, the regions created were circles with center in the mean and radius n times standard deviation, but we could try more complexes regions, or not?