aboutsummaryrefslogtreecommitdiff
path: root/doc/hitrate.html
blob: e8c95952de0c4d4dec94d9c7c09cbaf4c9a9160a (plain)
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>SFX hitrate calculator</title>
<script><!--

// just for small k
function dpois(k, lambda) {
   var ret = Math.exp(-lambda) * Math.pow(lambda, k),
       i = 0;
   for (i = 2; i <= k; i++) {
      ret /= i;
   }
   return ret;
}

function calc() {
   var lambda = parseFloat(document.getElementById("lambda").value),
       blank = dpois(0, lambda) * 100,
       single = dpois(1, lambda) * 100,
       two = dpois(2, lambda) * 100,
       three = dpois(3, lambda) * 100,
       hit = 100 - blank,
       multi = 100 - blank - single;
   if (lambda < 0) return;
   document.getElementById("output").innerHTML = "<br>Blank frame: " + blank.toFixed(1) +
        "%<br>Single lattice: " + single.toFixed(1) +
        "% (" + (single / hit * 100).toFixed(1) + "% of hits)" + 
        "<br>Two lattices: " + two.toFixed(1) +
        "% (" + (two / hit * 100).toFixed(1) + "% of hits)" + 
        "<br>Three lattices: " + three.toFixed(1) +
        "% (" + (three / hit * 100).toFixed(1) + "% of hits)" + 
        "<br>Multiple lattices: " + multi.toFixed(1) +
        "% (" + (multi / hit * 100).toFixed(1) + "% of hits)" + 
        "<br>Total Hit: " + hit.toFixed(1) + "%";
}
--></script>
</head>

<body onload="calc()">
<h1>Serial crystallography Hitrate calculator</h1>

<form>
Mean number of crystals per shot: <input type="text" id="lambda" value="1.0" size=3>
<input type="button" onClick="calc()" value="Calculate">
<div id="output"></div>
</form>

<hr>
<img src="hitrate.png">
<p>Hitrate was modeled by Poisson distribution as in [1]. 
The vertical line is at rate parameter = 1.</p>

<ol>
<li>Hunter, Mark S., et
al. "<a href="http://www.nature.com/srep/2014/140812/srep06026/full/srep06026.html">Fixed-target
protein serial microcrystallography with an x-ray free electron
laser</a>" Scientific reports 4 (2014).</li>
</ol>

<p>The plot was generated by the following R code.</p>

<pre>
lambda &lt;- seq(0, 3, by=0.05)
plot(lambda, 100 - 100* dpois(0, lambda=lambda), type='l', 
     ylab="Rate (%)", xlab="Mean(#Crystal/Shot)")
lines(lambda, 100 * dpois(0, lambda=lambda), lty=2)
lines(lambda, 100 * (1 - dpois(0, lambda=lambda) - dpois(1, lambda=lambda)), lty=3)
lines(lambda, 100 * dpois(1, lambda=lambda), lty=1, col=2)
lines(lambda, 100 * dpois(2, lambda=lambda), lty=1, col=3)
lines(lambda, 100 * dpois(3, lambda=lambda), lty=1, col=4)
abline(v=1)
legend("topleft", lty=c(1, 2, 3, 1, 1, 1), col=c(1, 1, 1, 2, 3, 4),
        c("Hit rate", "Blank frame", "Multiple hit", "Single lattice", 
          "Two lattices", "Three lattices"))
</pre>

</body>

</html>