Web Simulation 

 

 

 

 

Principal Component Analysis (PCA) - Dimensionality Reduction Tutorial 

This interactive tutorial demonstrates Principal Component Analysis (PCA), a fundamental technique for dimensionality reduction in data science and machine learning. PCA finds the directions of maximum variance in high-dimensional data and projects the data onto a lower-dimensional subspace, preserving the most important information while reducing complexity. The tutorial visualizes a 3D point cloud (stretched "blob") that can be projected onto a 2D plane, making it easy to understand how PCA works geometrically and how dimensionality reduction preserves information.

The visualization displays three main components: (1) 3D Visualization Canvas (main area) - shows a cloud of 3D points forming a stretched "blob" shape with three principal component arrows (PC1 in red, PC2 in green, PC3 in blue) indicating the directions of maximum variance, a semi-transparent yellow plane aligned with PC1 and PC2 representing the 2D projection subspace, and camera controls for rotating/viewing the scene, (2) Control Panel (below canvas) - contains a "Regenerate Data" button to generate a new random point cloud, a "Reduce Dimensions" button to animate the projection from 3D to 2D, a "Data Spread" slider to adjust the randomness/scatter of points, toggles to show/hide the projection plane and residual lines (connecting original points to projected points), and a variance explained display showing the percentage of variance captured by each principal component, (3) Interactive Animation - when "Reduce Dimensions" is clicked, points smoothly animate from their original 3D positions to their projected positions on the 2D plane, with optional dashed lines showing the "reconstruction error" (information lost).

The simulator implements the geometric intuition behind PCA: PCA finds the axes of maximum variance in the data. For the 3D point cloud, the data has the most spread along the X-axis (PC1, red arrow), medium spread along the Y-axis (PC2, green arrow), and minimal spread along the Z-axis (PC3, blue arrow). By projecting onto the PC1-PC2 plane (flattening the Z-axis), we preserve most of the information (high variance in X and Y) while discarding the least informative dimension (low variance in Z). You can adjust the data spread using the slider to see how variance changes, toggle the plane visibility to see the projection subspace, toggle residual lines to visualize reconstruction error, and click "Reduce Dimensions" to animate the dimensionality reduction. The variance explained display shows PC1, PC2, and PC3 as percentages, with progress bars indicating the relative importance of each component.

NOTE : This simulation demonstrates PCA using the geometric "shadow" analogy - if you hold a 3D object and shine a light on it, the shadow it casts on the wall is a 2D projection. PCA finds the angle where the shadow is the "widest" (preserves the most information/variance). The simplified 3D point cloud with clearly separated variances (large X, medium Y, small Z) makes it easy to visualize how PCA identifies the most important directions and projects the data onto a lower-dimensional subspace. The key insight is that dimensionality reduction discards the dimensions with the least variance (least information), preserving the dimensions with the most variance (most information). This demonstrates how PCA enables data compression, noise reduction, and feature extraction in machine learning and data analysis.

Mathematical Model

Principal Component Analysis (PCA) is a linear dimensionality reduction technique that transforms high-dimensional data into a lower-dimensional subspace while preserving the maximum amount of variance. PCA finds the orthogonal directions (principal components) along which the data has the most variation, and projects the data onto these directions.

PCA Algorithm:

  1. Compute Covariance Matrix: C = (1/n) × X^T × X
  2. Eigendecomposition: C = P × Λ × P^T
  3. Principal Components: Columns of P (eigenvectors)
  4. Variance Explained: Diagonal of Λ (eigenvalues)
  5. Projection: Y = X × P_k (project onto first k components)

where:

  • X: Data matrix (n×d) - n samples, d dimensions (features)
  • C: Covariance matrix (d×d) - measures how features vary together
  • P: Principal components matrix (d×d) - columns are eigenvectors (PC directions)
  • Λ: Eigenvalues matrix (d×d diagonal) - variance along each PC direction
  • P_k: First k principal components (d×k) - top k eigenvectors
  • Y: Projected data (n×k) - data in lower-dimensional space
  • PC1, PC2, PC3: Principal components - directions of maximum variance, ordered by importance

Understanding the Terms:

Principal Components (PCs): The principal components are orthogonal directions in the original data space that capture the maximum variance. PC1 (first principal component) is the direction along which the data varies the most, PC2 is the direction of second-most variance (orthogonal to PC1), and so on. In this tutorial, PC1 aligns with the X-axis (red arrow), PC2 with the Y-axis (green arrow), and PC3 with the Z-axis (blue arrow), because the data has been generated with different variances along these axes.

Variance Explained: The variance explained by each principal component indicates how much information is preserved when projecting onto that direction. PC1 typically explains the most variance (e.g., 60-80%), PC2 explains less (e.g., 20-30%), and PC3 explains the least (e.g., 5-10%). The sum of all variances equals 100%. By projecting onto PC1 and PC2 (discarding PC3), we preserve most of the information while reducing from 3D to 2D.

Dimensionality Reduction: Dimensionality reduction projects high-dimensional data onto a lower-dimensional subspace. In this tutorial, we reduce from 3D to 2D by projecting onto the PC1-PC2 plane (flattening the Z-axis). This is equivalent to "casting a shadow" - the 2D projection is like a shadow of the 3D data. PCA finds the best angle (orientation of the shadow) to preserve the most information (widest shadow).

Reconstruction Error: When we project data onto a lower-dimensional space, we lose some information. The reconstruction error is the distance between the original 3D point and its projected 2D position (flattened back to 3D with Z=0). The dashed orange lines in the visualization show these residual distances. Points that lie close to the projection plane have small reconstruction errors, while points far from the plane have large errors. PCA minimizes this error by choosing the projection that preserves the most variance.

Geometric Intuition: The best analogy for PCA is casting a shadow. If you hold a 3D object (the data cloud) and shine a light on it, the shadow it casts on a wall (the 2D projection) shows the object from a specific angle. PCA finds the angle that produces the "widest" shadow - the projection that preserves the most information. In this tutorial, the stretched "blob" shape naturally casts a wide shadow when viewed from above (along the Z-axis), which is why projecting onto the XY plane (PC1-PC2 plane) preserves most of the variance.

Why PCA Works: PCA works because real-world data often has structure - it lies along certain directions more than others. For example, if you measured people's height and weight, the data would form an elongated cloud (tall people tend to be heavier). PCA finds this "elongation" direction (PC1) and the perpendicular direction (PC2). By projecting onto PC1 (the direction of maximum variance), we preserve the most information while discarding noise in the perpendicular directions.

Visualization Flow: The visualization shows the complete PCA process: (1) 3D Point Cloud - displays 100 random 3D points forming a stretched "blob" with different variances along X (large), Y (medium), and Z (small) axes, (2) Principal Component Arrows - red arrow (PC1) points along X-axis (highest variance), green arrow (PC2) points along Y-axis (second highest variance), blue arrow (PC3) points along Z-axis (lowest variance), (3) Projection Plane - semi-transparent yellow plane aligned with PC1 and PC2 (XY plane), representing the 2D subspace onto which data will be projected, (4) Dimensionality Reduction Animation - when "Reduce Dimensions" is clicked, points smoothly move from their 3D positions to their 2D projections (Z-coordinate flattened to 0), (5) Residual Lines - optional dashed orange lines connecting original 3D points to their 2D projections, showing reconstruction error (information lost). The variance explained display shows PC1: ~60-80%, PC2: ~20-30%, PC3: ~5-10%, demonstrating that most variance is captured by PC1 and PC2, so discarding PC3 loses minimal information.

Projected View
Preset Data:
Projection Plane:
Data Spread: 1.0
Show Grid:
Show Residuals:
PC1 (Red): 0.0%
PC2 (Green): 0.0%
PC3 (Blue): 0.0%
Covariance Matrix (C):
[ ]
Eigendecomposition: C = P × Λ × P^T
Eigenvalues (Λ):
Eigenvectors (P):

 

Usage Example

Follow these steps to explore how PCA reduces dimensionality while preserving maximum variance:

  1. Initial State: When you first load the simulation, you'll see: (1) 3D Visualization Canvas (main area) - displays 100 random 3D points forming a stretched "blob" shape with large variance along X-axis, medium variance along Y-axis, and small variance along Z-axis, three principal component arrows (PC1 in red along X-axis, PC2 in green along Y-axis, PC3 in blue along Z-axis), a semi-transparent yellow plane aligned with PC1 and PC2 (XY plane), and camera control buttons in the top-left corner, (2) Control Panel (below canvas) - contains "Regenerate Data" and "Reduce Dimensions" buttons, "Data Spread" slider (set to 1.0), "Show Plane" toggle (ON), "Show Residuals" toggle (OFF), and variance explained display showing PC1, PC2, PC3 as percentages with progress bars. The default spread creates a clear "blob" shape that makes PCA intuitive.
  2. Understand the Data Structure: Observe the 3D point cloud and the principal component arrows. Notice that the data has the most spread along the X-axis (PC1, red arrow is longest), medium spread along the Y-axis (PC2, green arrow is medium length), and minimal spread along the Z-axis (PC3, blue arrow is shortest). This structure makes it clear why projecting onto the PC1-PC2 plane (XY plane) preserves most of the information while discarding the least informative dimension (Z-axis).
  3. Observe Variance Explained: Look at the variance explained display in the control panel. You should see something like PC1: ~65%, PC2: ~25%, PC3: ~10% (percentages may vary slightly due to random data generation). This shows that PC1 and PC2 together explain ~90% of the variance, meaning that projecting onto the PC1-PC2 plane preserves most of the information while reducing from 3D to 2D. The progress bars visually show the relative importance of each component.
  4. Reduce Dimensions: Click the "Reduce Dimensions (3D → 2D)" button to animate the dimensionality reduction. Watch as points smoothly move from their original 3D positions to their projected positions on the 2D plane (Z-coordinate flattened to 0). Notice how points near the plane move only a short distance (small reconstruction error), while points far from the plane move a longer distance (large reconstruction error). This animation demonstrates how PCA projects data onto the lower-dimensional subspace.
  5. Show Residuals: After reducing dimensions, toggle the "Show Residuals" checkbox to ON. This displays dashed orange lines connecting each original 3D point to its projected 2D position. These lines represent the reconstruction error - the information lost when reducing dimensions. Notice that points near the projection plane have short residual lines (low error), while points far from the plane have long residual lines (high error). Points at the edges of the blob (high Z-coordinate) have the largest reconstruction errors.
  6. Adjust Data Spread: Use the "Data Spread" slider to change the randomness/scatter of the points. Increase the spread (move slider right) to make the blob more stretched and increase variance differences. Decrease the spread (move slider left) to make the blob more compact and reduce variance differences. Notice how changing the spread affects the variance explained percentages - higher spread leads to more imbalanced variances (one component dominates), while lower spread leads to more balanced variances. When spread is very low, all components have similar variance, making dimensionality reduction less effective.
  7. Regenerate Data: Click the "Regenerate Data" button to generate a new random point cloud with the current spread setting. Each regeneration creates a slightly different "blob" shape, but the overall structure (large X variance, medium Y variance, small Z variance) remains the same. This allows you to explore how PCA works with different random data sets while maintaining the same variance structure.
  8. Toggle Plane Visibility: Click the "Show Plane" toggle to hide/show the projection plane. When the plane is hidden, you can better see the 3D structure of the point cloud. When the plane is shown, you can clearly see the 2D subspace onto which data will be projected. The plane helps visualize the projection operation geometrically.
  9. Explore Camera Views: Use the camera control buttons to view the scene from different angles: (1) Front View - view along Z-axis, shows the blob from the front (X-Y plane visible), (2) Top View - view from above (along -Y axis), shows the blob from the top (X-Z plane visible, blob appears flat), (3) Side View - view from the side (along X-axis), shows the blob from the side (Y-Z plane visible), (4) Zoom In/Out - adjust the viewing distance, (5) Reset View - return to the default isometric view. Different views help you understand the 3D structure and see how the projection plane aligns with the data.
  10. Understand the Result: After reducing dimensions, observe that all points lie on the XY plane (Z = 0). This is the 2D projection - we've compressed 3D data into 2D by discarding the Z-coordinate. However, because most variance is in X and Y directions, we've preserved most of the information. The variance explained display confirms this - PC1 and PC2 together explain ~90% of the variance, so we've only lost ~10% of the information by reducing from 3D to 2D. This demonstrates the key benefit of PCA: it reduces dimensionality while minimizing information loss by focusing on the directions of maximum variance.

Tip: The key insight to look for is how PCA preserves information by focusing on variance. In this simulation, the data has much more variance along the X and Y axes than along the Z axis. By projecting onto the XY plane (discarding Z), we preserve the dimensions with the most information (high variance) while discarding the dimension with the least information (low variance). This is why PC1 and PC2 together explain ~90% of the variance - most of the "action" in the data is in the XY plane. The dashed residual lines help visualize the reconstruction error - points far from the projection plane have large errors (long lines), while points near the plane have small errors (short lines). This geometric intuition - casting a shadow and finding the widest projection - is the core of PCA.

Parameters

Followings are short descriptions on each parameter
  • Channel Matrix H: A 2×2 real-valued matrix describing the physical channel between transmit and receive antennas in a MIMO system. Each element H[i,j] represents the gain from transmit antenna j to receive antenna i. Range: -3.0 to 3.0 per element (adjustable using spin boxes). Default: [[1.5, 0.5], [0.5, 1.2]] (Asymmetric preset). Off-diagonal elements represent interference (cross-talk between antennas). The channel matrix can be edited directly using spin boxes in the matrix display, or selected from preset options using the H Preset dropdown. The matrix is automatically decomposed using SVD to compute U, S, and V matrices.
  • H Preset: A dropdown menu for selecting common preset channel matrices. Options include: Custom (no change), Identity [[1,0],[0,1]] (no transformation), Diagonal Strong [[2,0],[0,1.5]] (strong channel gains, no interference), Diagonal Weak [[0.5,0],[0,1]] (weak channel gains, no interference), Coupled [[1,0.8],[0.8,1]] (significant interference), Strong Coupling [[1.5,1],[1,1.2]] (strong interference), Asymmetric [[1.5,0.5],[0.5,1.2]] (default, moderate interference), Singular [[1,1],[1,1]] (singular matrix, one eigenmode is zero), Rotation [[0.707,-0.707],[0.707,0.707]] (pure rotation). Selecting a preset updates the channel matrix H and recomputes the SVD decomposition.
  • SVD Precoding Toggle: A checkbox that toggles between SVD Precoding mode (ON) and Raw Transmission mode (OFF). When ON (SVD mode): precoding matrix P is applied at the transmitter (x = P × s), and combining matrix U^T is applied at the receiver (r = U^T × y), resulting in parallel independent streams (r = S × s). When OFF (Raw mode): no precoding or combining is applied, resulting in interference (y = H × s, r = y). Default: ON. Toggle this to compare interference in raw mode versus parallel streams in SVD mode.
  • Input Vector s: A 2×1 vector representing the two data streams to be transmitted [s₁, s₂]^T. Default: [0.707, 0.707] (magnitude 1, angle 45 degrees on the unit circle). The input vector can be controlled by dragging it directly on the visualization canvas (in the "Input Vector s" stage, leftmost plot). The vector is constrained to stay within reasonable bounds (magnitude ≤ 2). When you drag the input vector, all subsequent stages (precoded x, received y, recovered r) update in real-time.
  • Left Singular Vectors Matrix U: A 2×2 orthogonal matrix containing the output directions (eigenmodes at receiver), used for combining. The columns of U are the left singular vectors (output directions). U is computed automatically from the SVD decomposition of H. The transpose of U (U^T) is used as the combining matrix at the receiver. U is displayed in the mathematical dashboard and is read-only (computed from H).
  • Singular Values Matrix S: A 2×2 diagonal matrix containing the channel gains (singular values σ₁, σ₂) for each eigenmode. The diagonal elements are the singular values: S[0,0] = σ₁ (first singular value, largest), S[1,1] = σ₂ (second singular value, smallest), with S[0,1] = S[1,0] = 0. The singular values are always non-negative and are ordered from largest to smallest (σ₁ ≥ σ₂). S is computed automatically from the SVD decomposition of H. More uniform singular values (σ₁ ≈ σ₂) indicate better capacity (two strong independent streams), while imbalanced singular values (σ₁ >> σ₂) indicate reduced capacity (one dominant stream). S is displayed in the mathematical dashboard and statistics display, with singular values highlighted in green.
  • Right Singular Vectors Matrix V: A 2×2 orthogonal matrix containing the input directions (eigenmodes at transmitter) from SVD decomposition. The columns of V are the right singular vectors (input directions). V is computed automatically from the SVD decomposition of H. V is used as the precoding matrix P at the transmitter (P = V). V is displayed in the mathematical dashboard and is read-only (computed from H).
  • Precoding Matrix P: A 2×2 matrix applied at the transmitter for SVD precoding. P equals V from the SVD decomposition (P = V). When SVD Precoding mode is ON, the precoding matrix P is applied to rotate the input signal vector s to align with the input eigenmodes: x = P × s. This precoding step enables the channel to appear diagonal when viewed from the right coordinate system. P is displayed in the mathematical dashboard and is read-only (computed from V).
  • Combiner Matrix U^T: A 2×2 matrix (transpose of U) applied at the receiver for SVD combining. When SVD Precoding mode is ON, the combining matrix U^T is applied to rotate the received signal vector y to align with the output eigenmodes: r = U^T × y. Together with precoding, this creates the diagonal effective channel: r = U^T × H × V × s = S × s. U^T is displayed in the mathematical dashboard and is read-only (computed from U).
  • Precoded Signal Vector x: A 2×1 vector representing the transmitted signal after precoding. In SVD mode: x = P × s (where P = V). In raw mode: x = s (no precoding). The precoded vector x is displayed in the visualization canvas (second stage, "Precoded x = P×s" or "x = s (No Precoding)") and in the statistics display. In SVD mode, x shows the rotation applied by the precoding matrix P.
  • Received Signal Vector y: A 2×1 vector representing the signal after passing through the channel matrix H. y = H × x (or y = H × s in raw mode). The received vector y is displayed in the visualization canvas (third stage, "Received y = H×x") and in the statistics display. The received vector shows the transformation applied by the channel matrix H (stretching and rotation).
  • Recovered Signal Vector r: A 2×1 vector representing the signal after combining (in SVD mode) or after reception (in raw mode). In SVD mode: r = U^T × y = S × s (parallel independent streams, just scaled by singular values). In raw mode: r = y (no combining, interference present). The recovered vector r is displayed in the visualization canvas (fourth stage, "Output r = U^T×y" or "Output r = y") and in the statistics display. In SVD mode, r aligns with the input s (just scaled), demonstrating that interference is eliminated.
  • Singular Value σ₁: The first (largest) singular value, representing the channel gain for the first eigenmode. Range: ≥ 0 (non-negative). σ₁ is the diagonal element S[0,0] of the singular values matrix S. A larger σ₁ indicates a stronger channel direction. σ₁ is displayed in both the matrix dashboard (in matrix S) and the statistics display (highlighted in green). More uniform singular values (σ₁ ≈ σ₂) indicate better capacity.
  • Singular Value σ₂: The second (smallest) singular value, representing the channel gain for the second eigenmode. Range: ≥ 0 (non-negative), with σ₂ ≤ σ₁. σ₂ is the diagonal element S[1,1] of the singular values matrix S. A larger σ₂ indicates a stronger second channel direction. σ₂ is displayed in both the matrix dashboard (in matrix S) and the statistics display (highlighted in green). When σ₂ is very small compared to σ₁, the channel has reduced capacity (one dominant stream).

Controls and Visualizations

Followings are short descriptions on each control
  • Channel Matrix H Spin Boxes: Four spin box input fields (H[0,0], H[0,1], H[1,0], H[1,1]) located within the "Channel Matrix H" box in the mathematical dashboard. Each spin box allows you to edit the corresponding channel matrix element directly. Range: -3.0 to 3.0 per element (adjustable using spin box arrows or by typing values). Step: 0.1. Default: [[1.5, 0.5], [0.5, 1.2]] (Asymmetric preset). When you change a matrix element, the SVD decomposition (U, S, V) is automatically recomputed, and all matrices (U, S, V, P, U^T) and vectors (x, y, r) are updated in real-time. The spin boxes use right-aligned text with spin buttons on the right edge for Excel-like data entry.
  • H Preset Dropdown: A dropdown menu located in the control panel (on the same line as the SVD Precoding toggle) for selecting common preset channel matrices H. Options include: Custom (no change), Identity [[1,0],[0,1]], Diagonal Strong [[2,0],[0,1.5]], Diagonal Weak [[0.5,0],[0,1]], Coupled [[1,0.8],[0.8,1]], Strong Coupling [[1.5,1],[1,1.2]], Asymmetric [[1.5,0.5],[0.5,1.2]] (default), Singular [[1,1],[1,1]], and Rotation [[0.707,-0.707],[0.707,0.707]]. When you select a preset, the channel matrix H is updated, the SVD decomposition is recomputed, and all displays are updated in real-time. This allows you to quickly explore different channel configurations.
  • SVD Precoding Toggle Checkbox: A checkbox located in the control panel for toggling between SVD Precoding mode (ON) and Raw Transmission mode (OFF). When checked (ON, default): precoding matrix P is applied at the transmitter (x = P × s), and combining matrix U^T is applied at the receiver (r = U^T × y), resulting in parallel independent streams (r = S × s). When unchecked (OFF): no precoding or combining is applied, resulting in interference (y = H × s, r = y). The checkbox is labeled "SVD Precoding:" with an "ON"/"OFF" text display next to it. Toggle this to compare interference in raw mode versus parallel streams in SVD mode.
  • Mouse Drag on Visualization Canvas: Interactive mouse dragging on the visualization canvas to control the input vector s. Click and drag the input vector s directly on the canvas in the "Input Vector s" stage (leftmost plot). The input vector is constrained to stay within reasonable bounds (magnitude ≤ 2). As you drag, all subsequent stages (precoded x, received y, recovered r) update in real-time. The visualization canvas uses mouse event listeners (mousedown, mousemove, mouseup, mouseleave) to detect dragging within the Input Vector s stage area. This allows intuitive control of the input vector by directly manipulating it on the visualization.
  • Mathematical Dashboard: A display panel at the top of the simulation showing all matrices in a grid layout. Displays six matrices: (1) Channel Matrix H - editable with spin boxes, (2) Left Singular Vectors U - computed from SVD, read-only, (3) Singular Values S - diagonal matrix with singular values σ₁ and σ₂ highlighted in green, (4) Right Singular Vectors V - computed from SVD, read-only, (5) Precoding Matrix P - equals V, read-only, (6) Combiner U^T - transpose of U, read-only. All matrices are displayed in a responsive grid layout with centered text. The matrices update in real-time when the channel matrix H is changed. The singular values are highlighted in green to emphasize channel strength.
  • Visualization Canvas: Canvas displaying the signal flow from transmitter to receiver in four stages, each showing a unit circle for reference. The four stages are: (1) Input Vector s (leftmost, green vector) - shows the input data streams on the unit circle, draggable with mouse, (2) Precoded x = P×s (or "x = s (No Precoding)" in raw mode, second, cyan vector) - shows the precoded signal after applying precoding matrix P (only in SVD mode), (3) Received y = H×x (third, orange vector) - shows the signal after passing through the channel matrix H, (4) Output r = U^T×y (or "Output r = y" in raw mode, rightmost, magenta vector) - shows the recovered signal after applying combining matrix U^T (only in SVD mode). Each stage displays: unit circle (gray), coordinate axes (dashed lines), vector (colored arrow), vector endpoint (filled circle), and stage label (text). The crucial visual difference is that in SVD mode, the output vector aligns with the input vector (just scaled), while in raw mode, it is rotated/distorted (interference).
  • Statistics Display: Text display panel in the control panel showing current vector values and singular values in real-time. Displays: (1) Input s: [s₁, s₂] - the input vector, (2) Transmitted x: [x₁, x₂] - the precoded/transmitted vector, (3) Received y: [y₁, y₂] - the received vector, (4) Recovered r: [r₁, r₂] - the recovered vector, (5) Singular Value σ₁: (value, highlighted in green) - the first (largest) singular value, (6) Singular Value σ₂: (value, highlighted in green) - the second (smallest) singular value. The statistics update continuously as you change the channel matrix H, toggle SVD mode, or drag the input vector s. Uses Courier New font with bright text on dark background for visibility. The singular values are highlighted in green to emphasize channel strength.

Key Concepts

  • Singular Value Decomposition (SVD): A fundamental matrix factorization technique that decomposes any m×n matrix H into three matrices: H = U × S × V^T, where U is an m×m orthogonal matrix (left singular vectors), S is an m×n diagonal matrix (singular values), and V is an n×n orthogonal matrix (right singular vectors). In the context of MIMO communication, SVD decomposes the channel matrix H into orthogonal directions (singular vectors) with independent gains (singular values), allowing simultaneous transmission of multiple data streams without interference. SVD is the mathematical foundation for spatial multiplexing in MIMO systems, enabling precoding and combining to transform a coupled channel into parallel independent streams.
  • MIMO (Multiple-Input Multiple-Output): A communication system architecture that uses multiple transmit antennas and multiple receive antennas to improve communication performance. In a 2×2 MIMO system (used in this tutorial), there are 2 transmit antennas and 2 receive antennas. The channel matrix H describes how signals propagate between all transmit-receive antenna pairs. MIMO systems can achieve higher capacity (more data streams) and better reliability compared to single-antenna systems. The key advantage is spatial multiplexing: transmitting multiple independent data streams simultaneously over the same frequency band by exploiting spatial diversity.
  • Channel Matrix (H): A 2×2 matrix describing the physical channel between transmit and receive antennas in a MIMO system. Each element H[i,j] represents the gain from transmit antenna j to receive antenna i. In real wireless scenarios, these would be complex numbers representing amplitude and phase. For this tutorial, we use real numbers for simplicity. A non-diagonal matrix (off-diagonal elements are non-zero) means that signals interfere with each other (cross-talk between antennas). The goal of SVD precoding is to transform this coupled channel into independent parallel streams.
  • Eigenmodes (Parallel Streams): The orthogonal directions along which data can be transmitted independently in a MIMO system. For a 2×2 system, there are two eigenmodes (corresponding to the two singular values). The eigenmodes are the columns of V (input directions) and the columns of U (output directions). When SVD precoding is used, data stream 1 (s₁) is sent along eigenmode 1 and received as σ₁ × s₁ (scaled by the first singular value), while data stream 2 (s₂) is sent along eigenmode 2 and received as σ₂ × s₂ (scaled by the second singular value). These streams do not interfere with each other because they are orthogonal.
  • Precoding: A technique applied at the transmitter in MIMO systems to align the input signal with the channel eigenmodes. The precoding matrix P (which equals V from the SVD decomposition) rotates the input signal vector s to align with the input eigenmodes (columns of V). When we transmit x = P × s, we are sending data along the directions that the channel naturally "wants" to see. This precoding step enables the channel to appear diagonal when viewed from the right coordinate system, eliminating interference.
  • Combining: A technique applied at the receiver in MIMO systems to align the received signal with the output eigenmodes. The combining matrix U^T (transpose of U) rotates the received signal vector y to align with the output eigenmodes (columns of U). When we combine r = U^T × y, we are receiving data along the directions that the channel naturally produces. Together with precoding, combining creates the diagonal effective channel: r = U^T × H × V × s = S × s, resulting in parallel independent streams.
  • Singular Values (σ₁, σ₂): The diagonal elements of the singular values matrix S, representing the channel gains for each eigenmode. The singular values are always non-negative and are ordered from largest to smallest (σ₁ ≥ σ₂). The largest singular value (σ₁) represents the strongest channel direction, while the smallest singular value (σ₂) represents the weakest channel direction. In MIMO systems, the capacity is determined by these singular values - more uniform singular values (σ₁ ≈ σ₂) mean higher capacity (two strong independent streams), while highly imbalanced singular values (σ₁ >> σ₂) mean lower capacity (one dominant stream).
  • Spatial Multiplexing: The ability of MIMO systems to transmit multiple independent data streams simultaneously over the same frequency band by exploiting spatial diversity (multiple antennas). SVD precoding and combining enable spatial multiplexing by transforming a coupled channel (with interference) into parallel independent streams (without interference). Each stream is scaled independently by its singular value (σ₁ or σ₂), allowing simultaneous transmission of multiple data streams. The number of independent streams is determined by the rank of the channel matrix (typically equal to the minimum of the number of transmit and receive antennas).
  • Interference vs. Parallel Streams: In raw transmission mode (no precoding/combining), signals interfere with each other because off-diagonal elements of H cause cross-talk between antennas. The output is a rotated and scaled version of the input, making it difficult to recover the original data streams. In SVD precoding mode, precoding and combining eliminate interference by transforming the channel into a diagonal matrix (S). The output is just a scaled version of the input (no rotation, no interference), making it easy to recover the original data streams by simply dividing by the singular values. This is the key benefit of SVD precoding.
  • Channel Capacity: The maximum achievable data rate (in bits per second) over a communication channel. In MIMO systems, the capacity is determined by the singular values of the channel matrix H. More uniform singular values (σ₁ ≈ σ₂) mean higher capacity (two strong independent streams can be transmitted), while highly imbalanced singular values (σ₁ >> σ₂) mean lower capacity (one dominant stream, the other stream is weak). The capacity scales with the number of antennas and the uniformity of the singular values. SVD precoding enables the system to achieve the maximum capacity by creating parallel independent streams.
  • What to Look For: When exploring the simulation, observe: (1) How the visualization canvas shows four stages of signal flow (Input s, Precoded x, Received y, Output r), each displaying a unit circle for reference, (2) How in SVD mode, the output vector aligns with the input vector (just scaled), while in raw mode, it is rotated/distorted (interference), (3) How the singular values change with different channel matrices H - more uniform values mean better capacity, (4) How the mathematical dashboard displays all matrices (H, U, S, V, P, U^T) in real-time, showing how SVD decomposes H, (5) How dragging the input vector on the canvas updates all stages in real-time, demonstrating the signal transformations. The key insight is the diagonalization: SVD transforms a coupled channel into parallel independent streams, enabling spatial multiplexing in MIMO systems.

NOTE : This simulation demonstrates SVD in a completely transparent "glass box" architecture where every matrix, vector transformation, and calculation is visible. The simplified 2×2 MIMO system (real-valued matrices for clarity) is structured enough to visualize the complete SVD decomposition and understand how precoding and combining transform a coupled channel into parallel eigenmodes, yet complex enough to demonstrate the fundamental concepts of SVD-based MIMO precoding. The key insight is the diagonalization: SVD decomposes the channel matrix H into orthogonal directions (singular vectors) with independent gains (singular values), allowing simultaneous transmission of multiple data streams without interference. This is visualized in the mathematical dashboard (all matrices H, U, S, V, P, U^T displayed in real-time) and in the visualization canvas (four stages showing signal flow: Input s, Precoded x, Received y, Output r, each with unit circles for reference). Try toggling between SVD Precoding mode (ON) and Raw Transmission mode (OFF) to compare interference versus parallel streams - in SVD mode, the output vector aligns with the input vector (just scaled), while in raw mode, it is rotated/distorted (interference). Try different H presets (e.g., "Coupled" preset) to see how different channel configurations affect the singular values and signal transformations. The mathematical dashboard shows all matrices updating in real-time as you change H, making the mathematical process transparent. This demonstrates the fundamental concept behind Singular Value Decomposition (SVD) used in modern MIMO communication systems: SVD decomposes any channel matrix into orthogonal directions with independent gains, enabling spatial multiplexing through precoding and combining. The system automatically transforms a coupled channel (with interference) into parallel independent streams (without interference) without any explicit programming - this is the power of SVD. In practice, real-world MIMO systems use larger channel matrices (with complex-valued entries representing amplitude and phase) and more sophisticated signal processing, but the core principle remains the same: SVD enables spatial multiplexing by diagonalizing the channel matrix through precoding and combining.