#This scriptfile is a solution to exercise 14 i Eriksen &
#Lauritzen (2004). Answers are held in  a, b og c

import scipy
import numpy
from scipy.stats import (norm, chi2, t)

x = 108 + numpy.array([2, 1, 2, 0, 3, 4, 1, 3, 4])
m = float(sum(x)) / len(x)
s = (sum((x - m) ** 2) / (len(x) - 1)) ** 0.5
a = [m - norm.ppf(0.975) / 3, m + norm.ppf(0.975) / 3]
b = [m - t.ppf(0.975, 8) * s / 3, m + t.ppf(0.975, 8) * s / 3]
c = [s * (8 / chi2.ppf(0.975, 8)) ** 0.5, s * (8 / chi2.ppf(0.025, 8)) **
0.5]

print('a =', a)
print('b =', b)
print('c =', c)



