Week 3 Homework

10. Eigen's Paradox

Probability - Fundamentals
!hw_part2, p.4
Probability of a mutation per nucleotide without enzymes: p=0.01

Probability of no mutation: q=1−p=0.99

Since each nucleotides chance of mutation is independent, the probability of no mutation in strand of length n is qn.

To have 1 mutation in 5 copies - P(no mutation)=1/5

15=(0.99)nn=ln(1/5)ln(0.99)≈160

So given this probability, maximum length of nucleotide chain that is 1 mutation in 5 is 160

14. Frequency of identical twin births

Bayes' Theorem
!hw_part2, p.5
P(twins)=P(id,all)+P(frat,all)=0.003+0.017=0.02
P(id,twins)=0.0030.02=0.15
This is the prior probability - the probability that twins are monozygotic (identical) given that they are twins.

Using Bayes' theorem we can get the posterior probability given that the twins are the same sex:

P(id|samesex)=P(samesex|id)P(id)P(same sex twins)

Total probability:
P(same sex twins)=P(samesex|id)P(id)+P(samesex|frat)P(frat)
=(1)(0.15)+(0.5)(0.85)=0.575

P(id|samesex)=(1)(0.15)(0.575)=0.2609
Skipping the part where we only look within twins

If we skip the first part where we determine the probability that they are monozygotic given that they are twins and only use the probability from all births in our Bayes' Theorem, we will still get the same result. We are dividing each number by 0.02, so these could be factored out. However it's probably best to include this step, since the numbers make more logical sense in this case.

Now, let's see what happens when the frequency of fraternal twin births goes up:

New frequency:
P(twins)=P(id,all)+P(frat,all)=0.003+0.03=0.033
P(id,twins)=0.0030.033=0.0909

This gives a new posterior probability of 0.1818 - lower than the previous one. A lower prior probability results in a lower posterior prob.

17. Cohort survival

Binomial Distribution
!hw_part2, p.7

(a) Plotting the binomial distributions

We build a binomial distribution Bin(5,0.7t), where t is the number of years. P(k) is the probabililty of k birds surviving. Below I plot three cases for P(k): t=1 (red), t=3 (green) and t=10 (blue). Note that histograms would be better to plot here but I'm not sure how to do that. These probabilities are only valid for integer values of k that are 5 or less.

Formula:

P(k)=(5k)0.7tk(1−0.7t)5−k
bottom=-0.1
top=1
right=7
left=-0.5
---
n=5
p=0.7

y = (n! / (x!(n-x)!)) * p^x * (1-p)^{n-x}|red|dashed
\binomialdist(n,p)|red

y = (n! / (x!(n-x)!)) * p^{3x} * (1-p^3)^{n-x}|green|dashed
\binomialdist(n,p^3)|green

y = (n! / (x!(n-x)!)) * p^{10x} * (1-p^{10})^{n-x}|blue|dashed
\binomialdist(n,p^{10})|blue

(b) Years until 95% chance that all birds have died

This is where surviving birds k=0 and probability of survival P(k)=0.95 . If we plot P as a function of t, with n=5,k=0 , then show P(t)=0.95 as a dotted blue line:

bottom=-0.1
top=1
right=20
left=-1
---
n=5
p=0.7

y = (n! / (0!(n-0)!)) * p^{0x} * (1-p^x)^{n-0}|red
y=0.95|blue|dashed

Again, imagine that this is using discrete histogram bars or dots on the integer values of t since it was not stated that this is a constant rate.

We can see that these intersect around t=13 - so it will be 13 years until there is a 95% probability of 0 birds surviving.

Alternatively we could solve this with some algebra. It's not so bad if we start with k=0, since n choose 0 is always equal to 1:

(n0)=n!0!(n−0)!=n!(1)(n)!=1

So our equation is:

P(k)=(n0)p0t(1−pt)n−0P(k)=(1)(1)(1−pt)nln(P(k))=n⋅ln(1−pt)exp(ln(P(k))n)=1−ptt=ln(1−exp(ln(P(k))n))ln(p)t=ln(1−exp(ln(0.95)5))ln(0.7)=12.86

Same as before - we need to wait 13 years to be at least 95% sure. If we assume it was a constant rate, then we would have 12 years and 10 months, but this was not stated and its likely that it is not constant throughout the year.

18. Cancer diagnosis

Binomial Distribution
!hw_part2, p.7

19. Binomial random number generators

Binomial Distribution
(a) In a uniform distribution, the probability of getting a number between 0 and 0.2 is just 0.2.
(b) A random number from a uniform distribution below p will happen with probability p. If we generate n random numbers between 0 and 1 and record how many times it was below p - this number gives is k and its frequency is P(k) following a Binomial distribution with parameters n and p.