]> foleosoft.com Git - QAnsel.git/commitdiff
Fri 13 Dec 2024 03:10:06 PM EST
authora <[email protected]>
Fri, 13 Dec 2024 20:10:06 +0000 (15:10 -0500)
committera <[email protected]>
Fri, 13 Dec 2024 20:10:06 +0000 (15:10 -0500)
src/bytecode.c

index bff1faf8a3f3c68e89a9332873f6a59c3e43eaae..76355954a7c3bc59bbfa2b888697ef6c26974927 100644 (file)
@@ -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;       
 }