An Interactive PCA visualizer

Understanding the Curse of Dimensionality

In statistics, more data often means more insights. However, more variables (dimensions) create exponential complexity:

  • 2 variables: Easy to visualize on a 2D plot
  • 3 variables: Still manageable in 3D space
  • 10+ variables: Impossible to visualize, computationally expensive

This is the curse of dimensionality. To combat it, we use dimensionality reduction techniques like Principal Component Analysis (PCA).

Spectral Theory: Finding Order in Chaos

Spectral theory helps us:

  • Identify the most important dimensions in our data
  • Reduce complexity while preserving information
  • Transform correlated variables into independent components

These techniques fall under spectral analysis - mathematical methods that reveal hidden structure in complex data.

Interactive 3D Visualization

This demo generates samples from a multivariate normal distribution. You can see how data distributes in 3D space and how variables correlate with each other.

How It Works

  1. Random Sampling: Generate points using the Mersenne Twister algorithm
  2. Normal Distribution: Convert uniform random numbers to normal distribution
  3. Correlation: Apply covariance matrix using Cholesky decomposition
  4. Visualization: Render in 3D space with WebGL

Using the Covariance Matrix

The covariance matrix controls how variables relate. Each row represents how one variable depends on the others:

[1.0  0.5  0.0]
[0.5  1.0  0.3]
[0.0  0.3  1.0]

This means:

  • Variables 1 and 2 are moderately correlated (0.5)
  • Variables 2 and 3 are weakly correlated (0.3)
  • Variables 1 and 3 are independent (0.0)

Controls

  • Left-click + drag: Rotate view around axis center
  • Right-click + drag: Pan camera position
  • Scroll: Zoom in/out
  • Covariance matrix: Adjust correlations between variables

What You’re Seeing

Each point represents a sample with three variables (x, y, z). The shape of the point cloud reveals:

  • Elongation: Indicates correlation
  • Orientation: Shows which variables correlate
  • Density: Higher in the center (normal distribution)

Applications

This type of visualization helps understand:

  • PCA: Find principal components (eigenvectors of covariance matrix)
  • Data exploration: Identify patterns and outliers
  • Machine learning: Understand feature relationships
  • Simulation: Test statistical methods

Technical Details

The implementation uses:

  • Mersenne Twister: High-quality random number generator
  • Box-Muller transform: Converts uniform to normal distribution
  • Cholesky decomposition: Efficiently applies covariance structure
  • WebGL: Hardware-accelerated 3D rendering

This runs entirely in your browser with no server required. Performance remains excellent even with thousands of points.

Try It Yourself

Experiment with different covariance matrices:

High correlation (elongated cloud):

[1.0  0.9  0.9]
[0.9  1.0  0.9]
[0.9  0.9  1.0]

Independent variables (spherical cloud):

[1.0  0.0  0.0]
[0.0  1.0  0.0]
[0.0  0.0  1.0]

Mixed correlations:

[1.0  0.8  0.0]
[0.8  1.0  0.0]
[0.0  0.0  1.0]

Observe how the point cloud’s shape changes with each configuration!

Logo

© 2026 Martin Munguia