---
author: "Write your name here"
number: STUDENT_NUMBER
title: "Makeup Exam"
subtitle: "Computing in Molecular Biology and Genetics II"
date: "June 28, 2021"
editor_options:
  chunk_output_type: inline
---

# 1. Binomial distribution of probabilities
## 1.1 Average value of binomial, depending on `size` 
```{r}
sizes <- floor(10^seq(from=1, to=4, by=0.5))
sizes
```

```{r q1}
calc_average <- function(prob, sizes) {
  # write here
}
```

If all goes right, you will see something like this
```{r}
avg <- calc_average(prob = 0.5, sizes)
plot(avg ~ sizes)
```

## 1.2 Linear model for average depending on `size`
```{r q2}
# write here
```

## 1.3 Average value of binomial, depending on `prob`.
```{r}
probs <- seq(from=0.05, to=0.95, by=0.05)
probs
```

```{r q3}
# write here
```

Now you should be able to see this figure.
```{r}
plot(all_avg ~ probs)
```

## 1.4 Linear model for `all_avg` depending on `probs`
```{r q4, eval=FALSE}
# write here
```

# 2. Variance
## 2.1 Variance of binomial, depending on `size`
```{r q5}
calc_variance <- function(p, s) {
  # write here
}
```

If all goes right, you will see something like this
```{r}
variance <- calc_variance(p=0.5, s=sizes)
plot(log(variance) ~ log(sizes))
```

## 2.2 Linear model for Variance, depending on `size`
```{r q6}
# write here
```

Now you can show the coefficients with the following code
```{r}
c(exp(coef_var_vs_size[1]), coef_var_vs_size[2])
```

## 2.3 Variance of binomial, depending on `prob`
```{r q7}
# write here
```

Now you can plot `var_vs_prob` versus `probs` as in the following figure.
```{r}
plot(var_vs_prob ~ probs)
lines(probs*(1-probs) ~ probs, col="red")
```

# 3. In plain English
## 3.1 Average value of binomial
Given all the results of the previous questions, what is the formula for the average value of a binomial random variable, depending on `size` and `prob`?

``` q8
# write here
```

## 3.2 Variance of binomial
Given all the results of the previous questions, what is the formula for the variance of a binomial random variable, depending on `size` and `prob`?

``` q9
# write here
```
