Last active
August 20, 2019 09:23
-
-
Save jenjenjiang/d72a05afb895b891e75156a284c96710 to your computer and use it in GitHub Desktop.
Plot the average distances and minimum distances with respect to dimensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import math | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import seaborn | |
seaborn.reset_orig() | |
i = 0 | |
mList = [] | |
avgList = [] | |
ratioList = [] | |
while i < 100: | |
j = 0 | |
aList = [] | |
while j < 10000: | |
a = np.random.random((2,1)) | |
length = np.linalg.norm(a) | |
aList.append(length) | |
j += 1 | |
m = min(aList) | |
mList.append(m) | |
avg = sum(aList) / 10000 | |
avgList.append(avg) | |
ratio = m / avg | |
ratioList.append(ratio) | |
i += 1 | |
x,y = zip(*sorted(zip(mList, avgList))) | |
plt.plot(x,y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment