MCPcopy Index your code
hub / github.com/apache/groovy / selectRandom

Method selectRandom

benchmark/bench/fasta.java:70–77  ·  view source on GitHub ↗
(frequency[] a)

Source from the content-addressed store, hash-verified

68
69 // naive
70 public static final byte selectRandom(frequency[] a) {
71 int len = a.length;
72 double r = random(1.0);
73 for (int i = 0; i < len; i++)
74 if (r < a[i].p)
75 return a[i].c;
76 return a[len - 1].c;
77 }
78
79 static int BUFFER_SIZE = 1024;
80 static int index = 0;

Callers 1

makeRandomFastaMethod · 0.95

Calls 1

randomMethod · 0.95

Tested by

no test coverage detected