Merge branch 'master' of gitlab.com:pisquared/quantum

This commit is contained in:
Kristina Kirova 2020-02-01 10:54:24 +00:00
commit 911d58bfde
1 changed files with 10 additions and 5 deletions

View File

@ -33,8 +33,11 @@ def math_sim(q2func=State.from_angles, iterations=1000, sample_count=1):
all_samples = defaultdict(int)
for i in range(iterations):
# print("Running iteration {}".format(i))
# theta = round(np.random.uniform(0, np.pi), 3)
# phi = round(np.random.uniform(0, 2 * np.pi), 3)
# Generating uniform random points on a sphere is not trivial
# https://www.bogotobogo.com/Algorithms/uniform_distribution_sphere.php
# theta = np.arccos(2 * np.random.uniform(0, 1) - 1.0)
# phi = 2 * np.pi * np.random.uniform(0, 1.0)
t = round(np.random.uniform(0, 1), 10)
phi = round(np.random.uniform(0, 2 * np.pi), 10)
theta = np.arccos(1 - 2 * t)
@ -76,9 +79,11 @@ class MemoizedExp(object):
def gen_exp_for_cirq_0():
t = round(np.random.uniform(0, 1), 10)
phi = round(np.random.uniform(0, 2), 10)
theta = np.arccos(1 - 2 * t) / (2 * np.pi)
# TODO: FIX THIS AS AN EXPONENT UNIFORM DISTRIBUTION
# Generating uniform random points on a sphere is not trivial
# https://www.bogotobogo.com/Algorithms/uniform_distribution_sphere.php
theta = round(np.random.uniform(0, 1), 10)
phi = round(np.random.uniform(0, 1), 10)
return theta, phi