File:GaussianScatterPCA.svg
Summary
Description |
English: A scatter plot of samples that are distributed according a multivariate (bivariate) Gaussian distribution centered at (1,3) with a standard deviation of 3 in the (0.866, 0.5) direction and of 1 in the orthogonal direction. The directions represent the Principal Components (PC) associated with the distribution.
Español: Análisis de componentes principales de una distribución normal multivariante centrada en (1,3) con desviación estándar 3 en la dirección (0,864, 0,4.01) y desviación estándar 1 en la dirección perpendicular a la anterior. |
Date | |
Source | Own work |
Author | Nicoguaro |
Creation
This file was created with Python,NumPy and Matplotlib.
{{Created with Matplotlib|v|code= import numpy as np import matplotlib.pyplot as plt from matplotlib import rcParams
rcParams['font.family'] = 'serif' rcParams['font.size'] = 16
ang = np.pi/6
mean = np.array([1, 3])
cov = np.array([[9, 0],
[0, 1]])
rot = np.array([[np.cos(ang), -np.sin(ang)],
[np.sin(ang), np.cos(ang)]])
cov = np.dot(rot, np.dot(cov, rot.T))
np.random.seed(seed=1) data = np.random.multivariate_normal(mean, cov, size=(5000)) x = data[:, 0] y = data[:, 1]
plt.figure(figsize=(8, 8)) plt.scatter(x, y, c="k", alpha=0.1, lw=0) plt.arrow(1, 3, 3*np.cos(ang), 3*np.sin(ang), width=0.02, color="k", lw=2,
overhang=0.1)
plt.arrow(1, 3, -np.sin(ang), np.cos(ang), width=0.02, color="k", lw=2,
overhang=0.1)
plt.grid(True) plt.axis("image") plt.axis([-8, 10, -6, 12]) plt.savefig("GaussianScatterPCA.svg") plt.show()}}
Licensing
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.