File: afci.lua

package info (click to toggle)
vcfanno 0.3.7%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,112 kB
  • sloc: python: 335; sh: 259; makefile: 41
file content (17 lines) | stat: -rw-r--r-- 439 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function af_conf_int(n_alts, n_total)
	-- eqn 4 from: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.408.7107&rep=rep1&type=pdf
	p = n_alts / n_total
	n = n_total
    z = 1.96
    q = 1 - p

    a = 2*n*p + z^2
    denom = 2 * (n + z^2)

	bL = z * math.sqrt(z^2 - 2 - 1.0 / n + 4*p*(n*q+1))
	L = (a - 1 - bL) / denom

	bU = z * math.sqrt(z^2 + 2 - 1.0 / n + 4*p*(n*q-1))
	U = (a + 1 + bU) / denom
    return math.max(L, 0.0)
end