Skip to content

Instantly share code, notes, and snippets.

@VuongNM
Created May 2, 2022 12:34
Show Gist options
  • Save VuongNM/085b256f41e1241ad7032662fb9cc421 to your computer and use it in GitHub Desktop.
Save VuongNM/085b256f41e1241ad7032662fb9cc421 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
import seaborn as sns
dims = [1,10,100,500]
plt.figure(figsize=(10,5),dpi=500)
for d in dims:
cov = np.eye(d)
n = np.random.multivariate_normal(mean=np.zeros((d,)),cov=cov,size=10000)
dist = np.linalg.norm(n,axis=1)
sns.kdeplot(dist,fill=True,label='dims={}'.format(d))
plt.xlim([0,30])
plt.legend()
plt.title("Distance of points from multivariate normal to the Origin")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment