cpx_mtx_get(stateVector, 0, i, &n);
if (bit == 0) prob0 += cpx_magsqr(&n);
}
- float r = (ctx->hidden_variable_set) ? qansel_rand_h() : qansel_rand_t(ctx);
- //add any error skew if desired
+ float r;
if (ctx->noise > 0)
{
- float probtot;
- float prob1 = 1 - prob0;
- prob0 += ctx->noise;
- prob1 += ctx->noise;
- probtot = prob0 + prob1;
- prob0 /= probtot;
- prob1 /= probtot;
+ r = (ctx->hidden_variable_set) ? qansel_rand_h() : qansel_rand_t(ctx);
+ if (r < ctx->noise)
+ {
+ prob0 = 0.5;
+ }
}
+ r = (ctx->hidden_variable_set) ? qansel_rand_h() : qansel_rand_t(ctx);
return r < prob0 ? 0 : 1;
}