RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • bayesopt
    • classify
    • confusionmat
    • crossvalind
    • cvpartition
    • fitclinear
    • fitctree
    • fitlm
    • kmeans
    • knnsearch
    • lasso
    • lassoglm
    • linkage
    • lscov
    • mnrfit
    • optimizableVariable
    • pdist
    • pdist2
    • perfcurve
    • predict
    • regress
    • ridge
    • squareform
    • test
    • training
    • tsne

tsne — Embed high-dimensional observations using t-distributed stochastic neighbor embedding.

tsne(X) embeds the rows of a numeric observation matrix into a lower-dimensional numeric matrix. [Y,loss] = tsne(...) also returns the final Kullback-Leibler divergence.

Syntax

Y = tsne(X)
Y = tsne(X, Name, Value)
[Y, loss] = tsne(___)

Inputs

NameTypeRequiredDefaultDescription
XNumericArrayYes—Observation matrix with observations in rows.
optionsAnyVariadic—Name-value options such as Algorithm, Distance, NumDimensions, NumPCAComponents, Perplexity, Standardize, InitialY, LearnRate, Options, Theta, and Verbose.

Returns

NameTypeDescription
YNumericArrayLow-dimensional embedding matrix.
lossNumericArrayKullback-Leibler divergence for the final embedding.

Returned values from tsne depend on how many outputs the caller requests.

Errors

IdentifierWhenMessage
RunMat:tsne:InvalidArgumentInputs, dimensions, distances, initialization, or name-value options are malformed or unsupported.tsne: invalid argument
RunMat:tsne:InternalRunMat cannot allocate or construct the t-SNE result.tsne: internal error

How tsne works

  • X must be a real single- or double-precision vector or 2-D matrix. Matrix rows are observations; a column vector has one predictor per row, while a row vector is one observation with multiple predictors.
  • Rows containing NaN are omitted before fitting. Inf values are rejected.
  • NumDimensions selects the output dimension and defaults to 2. InitialY can match either all input rows or the complete rows that remain after NaN omission.
  • Algorithm accepts "barneshut" and "exact". RunMat computes a bounded exact CPU embedding for both modes so scripts receive compatible outputs without silent shape changes.
  • Distance supports "euclidean", "fasteuclidean", "seuclidean", "fastseuclidean", "cityblock", "chebychev", "minkowski", "mahalanobis", "cosine", "correlation", "spearman", "hamming", and "jaccard". The "minkowski" option uses the default exponent 2. Custom function-handle distances are rejected explicitly.
  • Standardize centers and scales each predictor column before distance computation. NumPCAComponents applies PCA before pairwise distance computation when it is positive and smaller than the predictor count.
  • Perplexity, Exaggeration, LearnRate, Theta, Verbose, NumPrint, and CacheSize are parsed and validated for MATLAB-style script compatibility. Theta, Verbose, NumPrint, and CacheSize do not affect the exact CPU optimizer.
  • Options accepts a statset-style struct with MaxIter, TolFun, and empty OutputFcn. Nonempty OutputFcn is rejected because RunMat does not invoke iteration callbacks from builtins yet.
  • RunMat rejects very large dense exact workloads before allocation to avoid unbounded pairwise, PCA, and Mahalanobis memory use.
  • Native integer observation data and numeric option values are RunMat language extensions. Each integer value must be exactly representable at the binary64 optimization boundary.

Examples

Embed observations into two dimensions

X = [0 0; 0.2 0.1; 9.8 9.9; 10 10.1];
Y = tsne(X, 'Perplexity', 2)

Expected output:

`Y` is a 4-by-2 embedding matrix.

Request the final loss

[Y,loss] = tsne(X, 'Algorithm', 'exact', 'Options', struct('MaxIter', 250))

Expected output:

`loss` is the final Kullback-Leibler divergence for the embedding.

Omit incomplete rows

Y = tsne([1 2; NaN 3; 10 11])

Expected output:

`Y` has two rows because the incomplete observation is omitted.

Using tsne with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how tsne changes the result.

Run a small tsne example, explain the result, then change one input and compare the output.

FAQ

Does RunMat implement Barnes-Hut acceleration?⌄

No. Algorithm="barneshut" is accepted for compatibility, but RunMat currently uses its bounded exact CPU optimizer for both algorithm names.

Are stochastic results bit-for-bit identical to MATLAB?⌄

No. RunMat uses its own RNG stream behind rng, so output shape and semantics are compatible but random initial embeddings are not bit-for-bit identical.

Related Stats functions

Ml

bayesopt · classify · confusionmat · crossvalind · cvpartition · fitclinear · fitctree · fitlm · kmeans · knnsearch · lasso · lassoglm · linkage · lscov · mnrfit · optimizableVariable · pdist · pdist2 · perfcurve · predict · regress · ridge · squareform · test · training

Summary

binocdf · boxplot · cdf · cdfplot · chi2cdf · corr · corrcoef · corrcov · cov · cov2corr · dummyvar · ecdf · filloutliers · fitdist · geomean · grpstats · harmmean · icdf · isoutlier · kstest · kurtosis · lsline · mad · mode · nanmax · normalize · normcdf · norminv · normpdf · onehotdecode · onehotencode · pdf · prctile · quantile · refline · rmse · skewness · tabulate · tcdf · tiedrank · tinv · tpdf · ttest2 · wblinv

Random

binornd · bootstrp · datasample · dividerand · exprnd · gamrnd · lhsdesign · mvnrnd · normrnd · random · randsample · rng · trnd · unidrnd · unifrnd · wblrnd

Hist

histc · histcounts · histcounts2

Options

statget · statset

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how tsne is executed, line by line, in Rust.

  • View the source for tsne in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How tsne works
  • Examples
  • Embed observations into two dimensions
  • Request the final loss
  • Omit incomplete rows
  • Using tsne with coding agents
  • FAQ
  • Related Stats functions
  • Ml
  • Summary
  • Random
  • Hist
  • Options
  • Open-source implementation
  • About RunMat