countSketch
- :
Y =countSketch(X, k)¶ - :
[Y, S] =countSketch(X, k)¶ CountSketch dimensionality reduction of the columns of X.
Y = countSketch (X, K)maps an n-by-d numeric matrix X (rows are points / observations) to an n-by-k sketch Y. The sketch is formed by a sparse CountSketch matrix S (d-by-k) with exactly one nonzero \pm 1 in each row, so thatY = X * Sexactly.The optional second output returns that sparse sketch matrix S. Randomness comes from the current global random stream (
randi); seed withrngfor reproducibility.Output class follows X for floating-point inputs (
double/single). Logical and integer X are promoted todouble.Behaviour note (MATLAB R2026a): MathWorks does not ship
countSketchin R2026a (exist ('countSketch')is 0; the closest core sketching entry point issvdsketch). This Nexus API follows the Clarkson–Woodruff CountSketch convention used in randomized linear algebra (column hashing with random signs) so that pairwise \ell_2 distances among rows of X are preserved in expectation for sufficiently large k (nexus#1945).