Miniproject
For The
Mathematica Workshop

Carol Castellon

Descriptive Statistics

Brief Description
     This project is an illustration of the built-in functions of the Descriptive Statistics package.  This package is automatically loaded when most other statistical packages are used.
     This project also provides an explaination of the measures used in descriptive statistics.

Descriptive Statistics

Initialization:

<<Statistics`DescriptiveStatistics`
<<Graphics`Graphics`
<<Statistics`DataManipulation`
Off[General::Spell1]
Off[General::Spell]

1.  Averages

Given a set of ranked data, the median is the number which splits the data into equal halves.
Example:  Given the set of data: 3,2,7,6,3,10,8
First rank the data, then locate the median.

data1 := {3,2,7,6,3,10,8}
srtdata1 = Sort[data1]
Median[data1]

There were 7 peices of data in the set.  If there are an even number of pieces of data, the median may not necessarily be a member of the data set.
For example:		3,2,7,6,9,8

data2 := {3,2,7,6,9,8}
Sort[data2]
N[Median[data2]]

You can see that the median, 6™í⁄ , is not a member of the data set, yet it divides the set into two equal halves.

The arithmetic mean is the only average which uses all the values of a data set.  It is called the "balance point" of a distribution because the sum of the deviations to the left of the mean equals the sum of the deviations to the right of the mean.
To find the mean, all the data values are added, and then divided by the number of pieces of data (sample size).
In symbols:  —x = à¡˜ x∆  ÷÷ n
Example:  Given the data set:  2,3,6,7,8,10
The mean is

N[Mean[data1]]

There are other kinds of means.
The Geometric mean and Harmonic mean, respectively, are

N[GeometricMean[data1]]
N[HarmonicMean[data1]]

The mode is the peice of data with the highest frequency in the set of data.
Example:  Given the set of data: 3,2,7,6,3,10,8
The mode is

Mode[data1]

Other measures of central tendancy include the midhinge (also called the midquartile) and the midrange.
Example:  Given the set of data: 3,2,7,6,3,10,8
The midhinge and midrange, respectively, are

midhinge = (N[Quantile[data1,.25]] + 
            N[Quantile[data1,.75]])/2 
midrange = N[(First[srtdata1] + Last[srtdata1])/2]

Note:  A general command, LocationReport[data] , gives the mean, harmonic mean and median with one input.

2.	  Dispersion

There are several measures which describe how the data is dispersed.

The simplest is the range, the distance between the highest and lowest data value; i.e. Range = H - L
Example:  Given the set of data: 3,2,7,6,3,10,8
The range is:

data1 := {3,2,7,6,3,10,8}
SampleRange[data1]

Interquartile range can also be found; i.e., IQ Range = Q£  - Q¡  
The interquartile range is:

N[InterquartileRange[data1]]

The two measures of variation most widely used are variance and standared deviation.  (The package uses unbiased variance)
The Variance =  s€ = µíµ⁄ à∆ (x∆  - —x  )€ where m = n-1  is:

N[Variance[data1]]

The Standard Deviation = s = √ s€

N[StandardDeviation[data1]]

Although there are other measures of dispersion, only the simplest were presented here.
Note:  A general command, DispersionReport[data], gives the variance, standard deviation, sample range, mean deviation, median deviation, and quartile deviation with one input.

3.	  Position

Statisticians are often interested in location of selected pieces of data.
The most common measures of postion are Percentiles, Quartiles, and Deciles.

Quartiles divide the ranked data set into 4 parts.  Therefore, there are only 3 quartiles.
Example:  Given the set of data: 3,2,7,6,3,10,8,5
The Quartiles for the ranked data are

data1 := {3,2,7,6,3,10,8,5}
srtdata1 = Sort[data1]
N[Quartiles[data1]]

Percentiles divide the ranked data set into 100 parts.  Therefore, there are only 99 percentiles.  When a set of data has only 8 pieces, it is obvious that to divide it into 100 parts, a single data value must "share" the name of many percentiles.  For example, the data value 3 in the data set, is the 13th through the 37th percentiles.
To find the value of a percentile, multiply:    % É n
Then, If this answer is not whole, round up; if this anwer is whole, add ™í™⁄ .  Use this result as a locator of the desired percentile.
For example, in the given set of data, the 35th percentile is:

N[Quantile[data1,.35]]

The 80th percentile is:

N[Quantile[data1,.80]]

Deciles divide the ranked data set into 10 parts.  Therefore, there are only 9 deciles.  Deciles are found via percentiles.
The 4th Decile is

N[Quantile[data1,.40]]

Another measure which describes the location of a particular piece of data is the z-score, or standard score.  The z-score tells where the data is located relative to the mean, in terms of the number of standard deviations away from the mean.  A z-score of 1.5 would say that the data is located 1.5 standard deviations to the right of the mean.  
The formula to find a z-score is:   z∆  =  (x∆  - —x  ) ÷ s
Example:  Given the set of data: 3,2,7,6,3,10,8,5
The z-score for the data value 6 is

z = N[(6 - Mean[data1])/StandardDeviation[data1]]

This says that the piece of data, 6, is located 0.18 standard deviations to the right of the mean.

4.		Graphs and Charts

To produce bar graphs and circle graphs, you need to use the Graphics package.

Using an arbitrary set of data which simulates a set of Quiz scores,

data = {5,7,8,9,8,8,10,6,7,10,4,8,10,9,9,7,9,8}
fdata := Frequencies[data]

The bar graph of the data set looks like this.

BarChart[fdata,PlotLabel->"Frequency of Quiz Scores"];

The pie graph of the data set can be customized to seperate out any subset of scores.

DisplayTogetherArray[PieChart[fdata],
	PieChart[fdata,PieExploded->{{1,.3},{2,.3}}]];