### ESD-FYS  -  module 4-1  - exercises



#### Component variation: Capacitor

```{r, fig.width=10, echo=FALSE, fig.align='center', fig.caption="Lot of capacitors with nominal value 220 NF and tolerance 10%"}
url <- "https://asta.math.aau.dk/static-files/asta/img/220nF-10procent.jpg"
z <- tempfile()
download.file(url, z, mode = "wb")
grid::grid.raster(jpeg::readJPEG(z))
invisible(file.remove(z))
```

Picture of a "lot" of capacitors. 

The word lot is used to identify several components produced in a single run. 
Where a run is a production series limited to a given timeinterval and fixed production parameters.

Peter Koch has tested 269 of the capacitors in the displayed lot.

Read in data:

```{r }
Cap220=read.csv(url("https://asta.math.aau.dk/datasets?file=capacitor_lot_220_nF.txt"))[,1]
```

Calculate ln error

- $\mbox{ln_Error=log(Cap220/220)}$

and make a histogram of ln_Error. Does it look normal?

Do a t-test to evaluate whether the mean value of ln_Error is significantly different from zero.

In lecture 1 we do a linear calibration of ln_Error. Load the "ab" parameters


```{r }
load("ab.RData")
```

Determine ln_Error_corrected.

Conclude by a t-test that the mean value of ln_Error_corrected is significantly different from zero.

So the lot has a systematic error.

Estimate mean and standard deviation of ln_Error_corrected
and calculate a 3 sigma interval for the lot values.

Does it respect the 10% tolerance?

An alternative is based on CV and mean of CAP220/220.

Assuming log normality of ln_Error estimate these parameters.

Denote the estimates by cv and M calculate

- M*(1 $\pm$ 3*cv)-1

and compare to the 3 sigma interval.

#### Component variation: Resistor


Peter Koch has also tested a lot(250 components) of resistors with nominal value 1 kOhm.

Read in data:

```{r }
R1000=read.csv(url("https://asta.math.aau.dk/datasets?file=Ohm.txt"))[,2]
```

Do a similar analysis, except that

 - we haven't calibrated the meter, so that we can only analyse ln_Error. This means that an eventual systematic deviation from zero has two sources: A systematic measurement error and a systematic lot error. 

#### WMM example 13.7

Data:

```{r }
yield=c(9.7,5.6,8.4,7.9,8.2,7.7,8.1,
  10.4,9.6,7.3,6.8,8.8,9.2,7.6,
  15.9,14.4,8.3,12.8,7.9,11.6,9.8,
  8.6,11.1,10.7,7.6,6.4,5.9,8.1,
  9.7,12.8,8.7,13.4,8.3,11.7,10.7)
batch=factor(rep(1:5,each=7))
data=data.frame(batch=batch,yield=yield)
```

Repeat the analysis in R.
