| 123 | |
| 124 | |
| 125 | int rand_getRandomSingleQubitOutcome(qreal probOfZero) { |
| 126 | |
| 127 | // assumes 0 <= probOfZero <= 1, and produces a Bernoulli variate, |
| 128 | // which is always consistent between distributed nodes |
| 129 | |
| 130 | std::uniform_real_distribution<qreal> distrib(0, 1); // ~[0,1] |
| 131 | |
| 132 | // advances generator on every node, retaining consensus |
| 133 | qreal sample = distrib(mainGenerator); |
| 134 | |
| 135 | // produces 0 with probOfZero probability |
| 136 | return sample > probOfZero; |
| 137 | } |
| 138 | |
| 139 | |
| 140 | qindex rand_getRandomMultiQubitOutcome(vector<qreal> probs) { |
no outgoing calls
no test coverage detected