-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfidence.py
More file actions
31 lines (22 loc) · 777 Bytes
/
confidence.py
File metadata and controls
31 lines (22 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import numpy as np
os.system('cls')
n = int(input('Enter the number of sites in the data set: '))
x = int(input('Enter the number of differences among those sites: '))
def P(diff, num):
p = diff / num
return p
def distance(diff, num):
p = P(diff, num)
d = ((-3/4) * np.log(1 - ((4 / 3) * p)))
return d
def sterr(diff, num):
p = P(diff, num)
err = (p * (1 - p)) / ((1 - ((4 * p) / 3) ** 2) * num)
conf = (1.96 * np.sqrt(err))
return conf
os.system('cls')
print('The distance of the two sequences is {} +/- {}'.format(round(distance(x, n), 4), round(sterr(x, n), 4)))
print('The 95% confidence interval is ({}, {})'.format(
(round((distance(x, n) - sterr(x, n)), 4)), (round((distance(x, n) + sterr(x, n)), 4))))
##test