From: a Date: Fri, 13 Dec 2024 20:10:06 +0000 (-0500) Subject: Fri 13 Dec 2024 03:10:06 PM EST X-Git-Url: http://www.foleosoft.com/?a=commitdiff_plain;h=6d2cc89c4f6a85ede19ce111a228e8dd0b4cec29;p=QAnsel.git Fri 13 Dec 2024 03:10:06 PM EST --- diff --git a/src/bytecode.c b/src/bytecode.c index bff1faf..7635595 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -455,18 +455,16 @@ unsigned char qansel_rand_b(QAnselContext* ctx, cpx_mtx_t* stateVector, unsigned 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; }