Histogramming
and Statistics

This laboratory will expand your repetoire of analytical skills and introduce the notion of a frequency distribution.

1. Basic Commands.

In this laboratory you will take a set of data and plot the frequency of different results. You will then extract simple statistical information from the histogram. First, enter some data. The command below shows how to enter an array of data in Mathematica.

Make a histogram of the data array.

Histogram[data]

2. Choosing Your Own Bins.

Sometimes you will want to have more control over how the frequency data are binned. Notice how the bins are different sizes in the next command. Compare this plot with the one in Section 1.

Histogram[data,{{-3.6,-2.4,-1.4,-.6,0,.6,1.4,2.4,3.6}}]

If you have a lot of categories and you have equal size bins, make a table to create the categories quickly and with less misery. Compare this plot with the other two.

Histogram[data, {-4,4,0.5}]

3. Calculating Statistics.

Use the commands here to get basic statistics of the data.

Mean[data]
Variance[data]
StandardDeviation[data]

Use the following commands to calculate the uncertainty on the mean.

StandardDeviation[data]/Sqrt[Length[data]]

4. Manipulating the Data.

If you want to make a repetitive calculation for each data point (i.e., multiply each data point by, say, 5.2), use the Table command demonstrated below.

data2 = Table[5.2*data[[i]],{i,1,Length[data]}]

You can also act on a subset  of the array by indexing things properly. In the example below, we multiply every third point by 0.52.

data3 = Table[0.52*data[[i]],{i,1,Length[data],3}]

If you want to merge two sets of data, use the Join command.

MergedData = Join[data,data2]