Statistics and electronics - lecture 1

The ASTA team

Sources of variation

Capacitors come with a nominal value for the capacitance.

We shall study 2 sources of variation:

Data from Peter Koch

Peter has done 100 independent measurements of the capacitance of each 4 of the displayed capacitors and one additional.

load(url("https://asta.math.aau.dk/datasets?file=cap_1pct.RData"))
head(capDat, 4)
##   capacity nomval   sample
## 1    45.69     47 s_1_nF47
## 2    45.71     47 s_1_nF47
## 3    45.69     47 s_1_nF47
## 4    45.71     47 s_1_nF47

Here we see the first 4 measurements of the first capacitor with nominal value 47nF.

table(capDat$sample)
## 
##  s_1_nF47  s_2_nF47 s_3_nF100 s_4_nF150 s_5_nF150 
##       100       100       100       100       100

Relative errors

Approximation of the relative error

n <- 47 
m <- seq(47-5*0.01*47, 47+5*0.01*47, length.out = 100) 
plot(m, log(m/n), col = "red", type = "l") 
lines(m, (m - n)/n, col = "blue", type = "l") 
legend("topleft", legend = c("log(m/n)", "(m-n)/n"), lty = 1, col = c("red", "blue"))

Transformation of errors

Transformed data

capDat = within(capDat, lnError <- log(capacity/nomval))
head(capDat, 2)
##   capacity nomval   sample     lnError
## 1    45.69     47 s_1_nF47 -0.02826815
## 2    45.71     47 s_1_nF47 -0.02783051
tail(capDat, 2)
##     capacity nomval    sample     lnError
## 499    145.7    150 s_5_nF150 -0.02908558
## 500    145.6    150 s_5_nF150 -0.02977216

Model considerations

favstats(lnError~sample, data=capDat)
##      sample         min          Q1      median          Q3         max
## 1  s_1_nF47 -0.02958221 -0.02832287 -0.02804930 -0.02804930 -0.02783051
## 2  s_2_nF47 -0.02914399 -0.02783051 -0.02761176 -0.02761176 -0.02717441
## 3 s_3_nF100 -0.03521276 -0.03399638 -0.03386707 -0.03366020 -0.03334998
## 4 s_4_nF150 -0.02565975 -0.02446352 -0.02429269 -0.02429269 -0.02360987
## 5 s_5_nF150 -0.03045921 -0.02977216 -0.02908558 -0.02908558 -0.02908558
##          mean           sd   n missing
## 1 -0.02832518 0.0005062160 100       0
## 2 -0.02786346 0.0005171088 100       0
## 3 -0.03398306 0.0005057586 100       0
## 4 -0.02453879 0.0005870180 100       0
## 5 -0.02947702 0.0005543930 100       0

Sources of variation

Statistical model

Estimation of systematic error

muhat <- mean(capDat$lnError)
muhat
## [1] -0.0288375

Estimation of random error

Fit

fit <- lm(lnError ~ sample, data = capDat)
anova(fit)
## Analysis of Variance Table
## 
## Response: lnError
##            Df    Sum Sq    Mean Sq F value    Pr(>F)    
## sample      4 0.0046576 0.00116440  4067.4 < 2.2e-16 ***
## Residuals 495 0.0001417 0.00000029                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
SS <- anova(fit)$`Sum Sq`
SSA <- SS[1]
SSE <- SS[2]
SSA
## [1] 0.004657588
SSE
## [1] 0.0001417076

Solution

\[E(SSA)=(k-1)\sigma^2+n(k-1)\sigma_\alpha^2\] \[E(SSE)=k(n-1)\sigma^2\]

Summing up

Test of no random effect

Coefficient of variation

The lognormal distribution

Coefficient of variation for lognormal distribution

Linear calibration

Linear calibration fit

fit <- lm(log(capacity) ~ log(nomval), data = capDat)
summary(fit)
## 
## Call:
## lm(formula = log(capacity) ~ log(nomval), data = capDat)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0064121 -0.0010784  0.0007315  0.0013879  0.0050839 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.0300145  0.0011907  -25.21   <2e-16 ***
## log(nomval)  1.0002636  0.0002648 3776.74   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.003101 on 498 degrees of freedom
## Multiple R-squared:      1,  Adjusted R-squared:      1 
## F-statistic: 1.426e+07 on 1 and 498 DF,  p-value: < 2.2e-16

Calibrated values

ab = coef(fit)
ab
## (Intercept) log(nomval) 
## -0.03001454  1.00026359
capDat$lnError_c = (capDat$lnError - ab[1])/ab[2]
head(capDat)
##   capacity nomval   sample     lnError   lnError_c
## 1    45.69     47 s_1_nF47 -0.02826815 0.001745930
## 2    45.71     47 s_1_nF47 -0.02783051 0.002183452
## 3    45.69     47 s_1_nF47 -0.02826815 0.001745930
## 4    45.71     47 s_1_nF47 -0.02783051 0.002183452
## 5    45.70     47 s_1_nF47 -0.02804930 0.001964715
## 6    45.69     47 s_1_nF47 -0.02826815 0.001745930