Skip to content

Instantly share code, notes, and snippets.

@jenjenjiang
Last active August 20, 2019 09:23
Show Gist options
  • Save jenjenjiang/d72a05afb895b891e75156a284c96710 to your computer and use it in GitHub Desktop.
Save jenjenjiang/d72a05afb895b891e75156a284c96710 to your computer and use it in GitHub Desktop.
Plot the average distances and minimum distances with respect to dimensions
Display the source blob
Display the rendered blob
Raw
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