Introduction to Chemical Engineering Processes/Basic Statistics and Data Analysis
Contents
Mean and Standard Deviation[edit]
A lot of the time, when you're conducting an experiment, you will run it more than once, especially if it is inexpensive. Scientists run experiments more than once so that the random errors that result from taking measurements, such as having to guess a length between two hash marks on a ruler, cancel themselves out and leave them with a more precise measurement. However, the question remains: how should you consolidate all of the data into something that's more managable to use?
Mean[edit]
Suppose you have n data points taken under the same conditions and you wish to consolidate them to as few as feasibly possible. One thing which could help is is to use some centralized value, which is in some way "between" all of the original data points. This, in fact, is called the mean of the data set.
There are many ways of computing the mean of a data set depending on how it is believed to be distributed. One of the most common methods is to use the arithmetic mean, which is defined as:

Other types of mean include the w:Geometric mean, which should be used when the data are very widely distributed (ex. an exponential distribution) and the "logmean" which occurs often in transport phenomena.
Standard Deviation[edit]
Having a value for the mean tells you what value the data points "cluster" around but it does not tell you how spread out they are from the center. A second statistical variable called the standard deviation is used for that. The standard deviation is essentially the average distance between the data points and their mean. The distance is expressed as a squared distance in order to prevent negative deviations from lessoning the effect of positive deviations.
The mathematical formulation for the standard deviation is:

The denominator is n1 instead of n because statisticians found that it gives better results for small numbers of experiments; see w:Standard deviation for a more thorough explanation of this.
Putting it together[edit]
The standard deviation of a data set measured under constant conditions is a measure of how precise the data set is. Because this is true, the standard deviation of a data set is often used in conjunction with the mean in order to report experimental results. Typically, results are reported as:
If a distribution is assumed, knowing both the mean and standard deviation can help us to estimate the probability that the actual value of the variable is within a certain range, if there is no systematic bias in the data. If there is (such as use of broken equipment, negligence, and so on) then no statistics could predict the effects of that.
Linear Regression[edit]
Suppose you have a set of data points () taken under differing conditions which you suspect, from a graph, can be reasonably estimated by drawing a line through the points. Any line that you could draw will have (or can be written in) the following form:
where m is the slope of the line and b is the yintercept.
We seek the best line that we could possibly use to estimate the pattern of the data. This line will be most useful for both interpolating between points that we know, and extrapolating to unknown values (as long as they're close to measured values). In the most usual measure, how "good" the fit is is determined by the vertical distance between the line and the data points (), which is called the residual:
In order to normalize the residuals so that they don't cancel when one's positive and one's negative (and thus helping to avoid statistical bias), we are usually concerned with the square of when doing leastsquares regression. We use squared terms and not absolute values so that the function is differentiable, don't worry about this if you haven't taken calculus yet.
In order to take into account all of the data points, we simply seek to minimize the sum of the squared residuals:
Using calculus, we can take the derivative of this with respect to m and with respect to b and solve the equations to come up with the values of m and b that minimize the sum of squares (hence the alternate name of this technique: leastsquares regression. The formulas are as follows, where n is the total number of data points you are regressing[1]:


Example of linear regression[edit]
Example (Suppose you wanted to measure how fast you got to school by a less direct route than looking at the speedometer of your car. Instead, you look at a map and read the distances between each intersection, and then you measure how long it takes to go each distance. Suppose the results were as shown in the table below. How far from home did you start, and what is the best estimate for your average speed?):
{{{2}}}
t(min)  D (yards) 

1.1  559.5 
1.9  759.5 
3.0  898.2 
3.8  1116.3 
5.3  1308.7 
The first thing we should do with any data like this is to graph it and see if a linear fit would be reasonable. Plotting this data, we can see by inspection that a linear fit appears to be reasonable.
Now we need to compute all of the values in our regression formulas, and to do this (by hand) we set up a table:
Trial  t  t^2  D  D^2  t*D 

1  1.1  1.21  559.5  313040  615.45 
2  1.9  3.61  759.5  576840  1443.05 
3  3.0  9.00  898.2  806763  2694.6 
4  3.8  14.44  1116.3  1246126  4241.94 
5  5.3  28.09  1308.7  1712695  6936.11 
TOTAL  15.1  56.35  4642.2  4655464  15931.15 
Now that we have this data we can plug it into our linear regression equation:
So
Hence the equation for the line of best fit is:

The graph of this plotted against the data looks like this:
How to tell how good your regression is[edit]
In the previous example, we visually determined if it would be reasonable to perform a linear fit, but it is certainly possible to have a less clearcut case! If there is some slight curve to the data, is it still "close enough" to be useful? Though it will always come down to your own judgment after seeing the fit line graph against the data, there is a mathematical tool to help you called a correlation coefficient, r, which can be defined in several different ways. One of them is as follows [1]:

It can be shown that this value always lies between 1 and 1. The closer it is to 1 (or 1), the more reasonable the linear fit. In general, the more data points you have, the smaller r needs to be before it's a good fit, but a good rule of thumb is to look for high (higher than 0.85 or 0.9) values and then graph to see if the graph makes sense. Sometimes it will, sometimes it won't, the method is not foolproof.
In the above example we have:
Hence the data correlates very well with a linear model.
Linearization[edit]
In general[edit]
Whenever you have to fit a parameter or multiple parameters to data, it is a good idea to try to linearize the function first, because linear regression is much less intensive and more accurate than nonlinear regression. The goal with any linearization is to reduce the function to the form:
The difference between this and "standard" linear regression is that Variable 1 and Variable 2 can be any functions of x and y, as long as they are not combined in any way (i.e. you can't have as one variable). The technique can be extended to more than two variables using a method called w:multiple linear regression but as that's more difficult to perform, this section will focus on twodimensional regression.
Power Law[edit]
To see some of the power of linearization, let's suppose that we have two variables, x and y, related by a power law:
where A and b are constants. If we have data connecting changes in y to changes in x, we would like to know the values of a and b. This is difficult to do if the equation is in its current form but we can change it into a lineartype function!
The trick here is we need to get rid of the exponent b, so in order to do that we take the natural log of both sides:
Using laws of logarithms we can simplify the righthand side to obtain the following:

The beauty of this equation is that it is, in a sense, linear. If we graph ln(y) vs. ln(x) obtain a straight line with slope b and yintercept ln(A).
Exponentials[edit]
Another common use of linearization is with exponentials, where x and y are related by an expression of the form:
This works for any base but the most common base encountered in practice is Euler's constant, e. Again, we take the natural log of both sides, in order to get rid of the exponent:

This time, Graph ln y vs. x to obtain a line with slope ln(b) and yintercept ln(A).
Linear Interpolation[edit]
Often, when you look up properties on a chart, you will be looking them up at conditions in between two charted conditions. For example, if you were looking up the specific enthalpy of steam at 10 MPa and 430oC you would look in the steam tables and see something like this: [2]
T (oC)  H 

400  2832.4 
450  2943.4 
How can you figure out the intermediate value for this? We can't exactly but we can assume that H(T) is a linear function. If we assume that it is linear, then we can easily find the intermediate value. First, we set up a table, including the unknown value like this:
T (oC)  H 

400  2832.4 
430  x 
450  2943.4 
Then since we're assuming the relationship between T and H is linear, and the slope of a line is a constant the slope between points 3 and 2 has to equal the slope between points 3 and 1.
Therefore, we can write that:
Solving gives x = 2899 kJ/kg
The same method can be used to find an unknown T for a given H between two tabulated values.
General formula[edit]
To derive a more general formula (though I always derive it from scratch anyways, it's nice to have a formula), lets replace the numbers by variables ad give them more generic symbols:
x  y 

Setting the slope between points 3 and 2 equal to that between 3 and 1 yields:

This equation can then be solved for x* or y* as appropriate.
Limitations of Linear Interpolation[edit]
It is important to remember that linear interpolation is not exact. How inexact it is depends on two major factors:
 What the real relationship between x and y is (the more curved it is, the worse the linear approximation)
 The difference between consecutive x values on the table (the smaller the distance, the closer almost any function will resemble a line)
Therefore, it is not recommended to use linear interpolation if the spaces are very widely separated. However, if no other method of approximation is available, linear interpolation is often the only option, or other forms of interpolation (which may be just as inaccurate, depending on what the actual function is).
See also w:interpolation.
References[edit]
[1]: Smith, Karl J. The Nature of Mathematics. Pacific Grove, California: Brooks/Cole Publishing company, 6e, p. 683
[2]: Sandler, Stanley I. Chemical, Biochemical, and Engineering Thermodynamics. University of Deleware: John Wiley and Sons inc., 4e, p. 923