### ESD-FYS  -  module 4-2  - exercises



#### Component variation: Resistor


We return to the 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]
```
Investigate whether it is realistic to assume normality of 
- `ln_Error=log(R1000/1000)`.

Lets repeat the code to calculate cut-values and observed values in `B` bins for the data vector `x`.


```{r eval=FALSE}
m=mean(x)
s=sd(x)
cut_values=qnorm((0:B)/B,m,s)
expected=length(x)/B
observed=table(cut(x,cut_values))
```

#### Wind data

We return to the wind speed measurements
from the weather station located at Sjælsmark (in Exam 1). Load the data set:

```{r}
speed<-read.delim("https://asta.math.aau.dk/datasets?file=windSpeed.txt",header=FALSE)[,1]
```

Make a goodness of fit test to see whether the Weibull distribution fits the data.

Code to calculate cut-values and observed values in `B` bins for the data vector `x`.


```{r eval=FALSE}
intercept=-2.82   
k=slope=1.78
lambda=exp(-intercept/k)
cut_values=qweibull((0:B)/B,shape=k,scale=lambda)
expected=length(x)/B
observed=table(cut(x,cut_values))
```

#### Excercise 10.79 in WMM.

#### Another type of measurement variation.

Peter Koch has done 100 consecutive measurements on a capacitor with nominal value 100 nF. We make a plot of the consecutive values and load parameters for calibration.


```{r }
Cap100=read.table(url("https://asta.math.aau.dk/datasets?file=instrument_variation_100nF_1procent.txt"))[,1]
load("ab.RData")
ts.plot(Cap100)
```
This looks like the meter swings between 2 levels. 

According to Peter, it can be due to some random mechaninal impact on the system.

Calculate `ln_Error_corrected`  and do a mixture analysis determining the two different levels of the meter.





