Skip to content

jlTransform

linear-algebra · scripts/linear-algebra/jlTransform.m

: Y = jlTransform (X, k)
: [Y, R] = jlTransform (X, k)

Johnson–Lindenstrauss Gaussian random projection of the columns of X.

Y = jlTransform (X, K) maps an n-by-d numeric matrix X (rows are points / observations) to an n-by-k sketch Y via a dense Gaussian projection matrix R = randn (d, k) / sqrt (k), so that Y = X * R.

The optional second output returns that projection matrix R. Randomness comes from the current global random stream (randn); seed with rng for reproducibility.

Output class follows X for floating-point inputs (double / single). Logical and integer X are promoted to double.

Behaviour note (MATLAB R2026a): MathWorks does not ship jlTransform in R2026a (exist ('jlTransform') is 0; the closest core sketching entry point is svdsketch). This Nexus API is the classical scaled Gaussian Johnson–Lindenstrauss map, which preserves pairwise \ell_2 distances among rows of X with high probability for k on the order of O(\varepsilon^{-2} \log n) (nexus#1945).