---
output: html_document
---

# Exam exercise: Quality control

```{r message=FALSE}
library(qcc)
```

## Control charts

A certain type of integrated circuit is connected to its frame by five wires. Thirty samples of five units each were taken, and the pull strength (in grams) was measured.
You can access the data from this file <http://asta.math.aau.dk/eng/static/datasets?file=wire.dat>.

```{r}
wire <- read.table("http://asta.math.aau.dk/eng/static/datasets?file=wire.dat")
```

Use the data to 

* explain and illustrate the construction of an S-chart, where the control limits are requested to give average run length equal to 1000 (set `nsigmas` in the `qcc()` command to the proper value (default is `nsigmas=3`).

```{r}
#state your command(s) here and give additional textual information  
#hint:
# h <- qcc(wire, type="S", nsigmas=.., title="S chart: pull strength")
```

* explain and illustrate the construction of a CUSUM-chart.

```{r}
#state your command(s) here and give additional textual information  
```

## Sampling plan

You are confronted with the demand to construct a sampling plan, that requires that

* Producer: The acceptance probability should be (at least) 90%, when the failure rate is 2%.

* Consumer: The acceptance probability should be (at most) 1%, when the failure rate is 5%.
You are requested to

```{r message = FALSE}
library(AcceptanceSampling)
```

* determine a binomial sampling plan that fulfills these requirements.

```{r}
#state your command(s) here  
```

* display and explain the OC-curve of the plan. This includes determining the acceptance probabilities for failure rates 2% and 5%.

```{r}
#state your command(s) here and give additional textual information  
#please use "pd=seq(0,0.1,0.002)" in your OC2c() command 
```
