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

Function getRandomProbabilities

tests/deprecated/test_utilities.cpp:585–601  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

583}
584
585vector<qreal> getRandomProbabilities(int numProbs) {
586
587 // generate random unnormalised scalars
588 vector<qreal> probs;
589 qreal total = 0;
590 for (int i=0; i<numProbs; i++) {
591 qreal prob = getRandomReal(0, 1);
592 probs.push_back(prob);
593 total += prob;
594 }
595
596 // normalise
597 for (int i=0; i<numProbs; i++)
598 probs[i] /= total;
599
600 return probs;
601}
602
603QMatrix getRandomDensityMatrix(int numQb) {
604 DEMAND( numQb > 0 );

Callers 2

getRandomDensityMatrixFunction · 0.70
test_operators.cppFile · 0.70

Calls 1

getRandomRealFunction · 0.70

Tested by

no test coverage detected