π€ Calculating Error and Parameter Estimation
This page consolidates notes from CEE308 Environmental Engineering Lab at Princeton University, Spring 2022, taught by Professor Peter Jaffe.
Mean, variance, and standard deviation from n direct measurements
The mean Λx is calculated as:
Λx=βixinWhere Λx is the mean, xi is the i-th measurement, and n is the number of measurements.
If the true standard error Ο or variance Ο2 for the population is known, and if the mean Λx was estimated from n samples, then variance of the mean Ο2Λx can be calculated as
Ο2Λx=Ο2nIf the variance S2 of the population is not known and must be estimated (as in most cases), then use the following equation:
S2=1nβ1βi(xiβΛx)2Where in all these equations:
- Ο refers to the true error
- S refers to the estimated error
Least-squares Linear Regression
Suppose you want to fit the function
y=a+bxto a set of 2D data of n samples. Then parameters a and b can be estimated using the following equations:
a=βix2iβiyiββixiβixiyinβix2iβ(βixi)2 b=nβixiyiββixiβyinβix2iβ(βixi)2Where, for clarity, a is the intercept and b is the slope of the regression.
Parameter error estimation
The set of residuals E can be defined as the set of differences between the original y-values and the y-values estimated by the regression using the original x-values as arguments:
E={Ο΅i:Ο΅i=yiβ(a+bxi),β(xi,yi)}Then the variance of the regression model can be calculated as follows:
S2y/x=1nβ2βiΟ΅2i,βΟ΅iβEAnd the variance of the slope b:
S2b=S2y/xβi(xiβΛx)2And the variance of the intercept a:
S2a=S2x/y(1n+Λx2βi(xiβΛx)2)Note that the error S (usually denoted Ο, even when estimated) of either parameter is simply the square root of the respective variance.
Therefore when writing a technical paper where you produce βerror barsβ or Β± standard deviation, calculate Ο=βS2 for each determined parameter.
Error propagation
Given the analytical model
y=f(x1,x2,...,x3)Then the variance of the model is
Ο2y=βiΟ2Λx,ixi(βyβxi)2