-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.htm
166 lines (120 loc) · 5.88 KB
/
index.htm
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
---
layout: default
---
<h1>Positive Probability Limited Optimal Pool Size Calculator</h1>
<!--<p>This calculates the optimal pool size based on the desired maximum probability of positive pooled tests, and the probability of positive un-pooled tests. Dilution due to pooling is ignored for simplicity.</p>-->
<h2>Input</h2>
<h3>Desired Maximum Pooled Test Positive Probability (<1)</h3>
<p>Input the desired maximum probability of positive pooled tests. Use decimal fraction (say 0.5) instead of % (say 50%).</p>
<p>The default value of the desired maximum probability is 0.5, meaning that you want the largest pool size such that about 50% of the pooled tests are expected to be positive.</p>
<h3>Un-pooled Test Positive Probability (<1)</h3>
<p>Input the probability of positive un-pooled tests, based on historical and other data. Use decimal fraction (say 0.1) instead of % (say 10%).</p>
<h2>Calculator</h2>
<b>Desired Maximum Pooled Test Positive Probability (<1)</b>
<br>
<input type="text" placeholder="Input 0.5 for 50%" id="p" value="0.5">
<br><br>
<b>Un-pooled Test Positive Probability (<1)</b>
<br>
<input type="text" placeholder="Input 0.1 for 10%" id="i">
<br><br>
<button type="button" onclick="main();">Calculate</button>
<h2>Result</h2>
<div id="result"></div>
<hr>
<h1>Bayesian Positive Probability Limited Optimal Sub-Pool Size Calculator</h1>
<!--<p>This calculates the optimal sub-pool size if the current pool tests positive. It is based on the current pool size, the desired maximum probability of positive sub-pooled tests, and the probability of positive un-pooled tests. Dilution due to pooling is ignored for simplicity.</p>-->
<h2>Input</h2>
<h3>Desired Maximum Sub-pooled Test Positive Probability (<1)</h3>
<p>Input the desired maximum probability of positive sub-pooled tests. Use decimal fraction (say 0.5) instead of % (say 50%).</p>
<p>The default value of the desired maximum probability is 0.5, meaning that you want the largest sub-pool size such that about 50% of the sub-pooled tests are expected to be positive.</p>
<h3>Un-pooled Test Positive Probability (<1)</h3>
<p>Input the probability of positive un-pooled tests, based on historical and other data. Use decimal fraction (say 0.1) instead of % (say 10%).</p>
<h3>Current Pool Size</h3>
<p>Input the number of samples in the current pool, to be sub-pooled on testing postive.</p>
<h2>Calculator</h2>
<b>Desired Maximum Sub-pooled Test Positive Probability (<1)</b>
<br>
<input type="text" placeholder="Input 0.5 for 50%" id="p2" value="0.5">
<br><br>
<b>Un-pooled Test Positive Probability (<1)</b>
<br>
<input type="text" placeholder="Input 0.1 for 10%" id="i2">
<br><br>
<b>Current Pool Size</b>
<br>
<input type="text" placeholder="Input a natural number" id="t2">
<br><br>
<button type="button" onclick="main2();">Calculate</button>
<h2>Result</h2>
<div id="result2"></div>
<hr>
<h1>No Sub-Pooling Optimal Pool Size Calculator</h1>
<!--<p>This calculates the optimal pool size in cases where sub-pooling is not possible, either due to dilution, limited sample quantity, or other considerations. The optimal pool size in this case is the pool size that minimizes the expected number of tests per individual, that need to be conducted to determine the infection status of all individuals in the pool.</p>-->
<h2>Input</h2>
<h3>Un-pooled Test Positive Probability (<1)</h3>
<p>Input the probability of positive un-pooled tests, based on historical and other data. Use decimal fraction (say 0.1) instead of % (say 10%).</p>
<h2>Calculator</h2>
<b>Un-pooled Test Positive Probability (<1)</b>
<br>
<input type="text" placeholder="Input 0.1 for 10%" id="i3">
<button type="button" onclick="main3();">Calculate</button>
<h2>Result</h2>
<div id="result3"></div>
<script>
function poolsize (p,i) {
var res = Math.floor(Math.log(1-p)/Math.log(1-i));
if (res > 1) return res;
else return 1;
}
function subpoolsize (p2,i2,t2) {
var k;
for (k=0;k<t2;k++) if ((1-Math.pow((1-i2),k))/(1-Math.pow((1-i2),t2))>p2) break;
if (k>2) return (k-1);
else return 1;
}
function main () {
var p = document.getElementById("p").value;
var i = document.getElementById("i").value;
var s = poolsize(p,i);
var outp = 1-Math.pow((1-i),s);
var out = document.getElementById("result");
out.innerHTML = '<h3>Optimal pool size: <b>'+s+'</b> | Positive probability = <b>'+outp.toFixed(4)+'</b></h3>';
}
function main2 () {
var p2 = document.getElementById("p2").value;
var i2 = document.getElementById("i2").value;
var t2 = document.getElementById("t2").value;
var s2 = subpoolsize(p2,i2,t2);
var outp2 = (1-Math.pow((1-i2),s2))/(1-Math.pow((1-i2),t2));
var parts = Math.ceil(t2/s2);
var q = Math.floor(t2/parts);
var r = t2%parts;
var j;
var out2 = document.getElementById("result2");
out2.innerHTML = '<h3>If a pool of <b>'+t2+' samples</b> is tested positive, sub-dividing it into <b>'+parts+' pools</b> of following sizes would make the sub-pooled test positive probability to be:</h3>';
for (j=0;j<parts;j++) {
if (r != 0) {
out2.innerHTML += '<h3>Optimal sub-pool '+(j+1)+' size: <b>'+(q+1)+'</b> | Positive probability = <b>'+((1-Math.pow((1-i2),q+1))/(1-Math.pow((1-i2),t2))).toFixed(4)+'</b></h3>';
r--;
}
else {
out2.innerHTML += '<h3>Optimal sub-pool '+(j+1)+' size: <b>'+(q)+'</b> | Positive probability = <b>'+((1-Math.pow((1-i2),q))/(1-Math.pow((1-i2),t2))).toFixed(4)+'</b></h3>';
}
}
}
function main3 () {
var i3 = document.getElementById("i3").value;
var x = 2;
var pre = 1;
while ((Math.pow((1-i3),x)+(1-Math.pow((1-i3),x))*x)/x<pre) {
pre = (Math.pow((1-i3),x)+(1-Math.pow((1-i3),x))*x)/x;
x++;
}
var out3 = document.getElementById("result3");
if (x>1)
out3.innerHTML = '<h3>Optimal pool size: <b>'+(x-1)+'</b> | Positive probability = <b>'+(1-Math.pow((1-i3),(x-1))).toFixed(4)+'</b></h3>';
else
out3.innerHTML = '<h3>Optimal pool size: <b>'+1+'</b> | Positive probability = <b>'+i3+'</b></h3>';
}
</script>