From 6d2cc89c4f6a85ede19ce111a228e8dd0b4cec29 Mon Sep 17 00:00:00 2001 From: a Date: Fri, 13 Dec 2024 15:10:06 -0500 Subject: [PATCH] Fri 13 Dec 2024 03:10:06 PM EST --- src/bytecode.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) 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; } -- 2.39.5