MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / rand_getRandomSingleQubitOutcome

Function rand_getRandomSingleQubitOutcome

quest/src/core/randomiser.cpp:125–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123
124
125int 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
140qindex rand_getRandomMultiQubitOutcome(vector<qreal> probs) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected