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
    • 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

kstest — Perform a one-sample Kolmogorov-Smirnov test.

kstest(x) performs a one-sample Kolmogorov-Smirnov test of whether the sample in x could come from a standard normal distribution. [h,p,ksstat,cv] = kstest(...) also returns an approximate p-value, the KS statistic, and an approximate critical value.

Syntax

h = kstest(x)
h = kstest(x, Name, Value)
[h, p] = kstest(___)
[h, p, ksstat, cv] = kstest(___)

Inputs

NameTypeRequiredDefaultDescription
xAnyYes—Sample data.
nameValuePairsAnyVariadic—Alpha, CDF, and Tail options.

Returns

NameTypeDescription
hLogicalArrayHypothesis test decision.
pNumericArrayP-value.
ksstatNumericArrayKolmogorov-Smirnov test statistic.
cvNumericArrayApproximate critical value.

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

Errors

IdentifierWhenMessage
RunMat:kstest:InvalidArgumentInputs, CDF specification, tail, or significance level are malformed.kstest: invalid argument
RunMat:kstest:InternalRunMat cannot construct kstest outputs.kstest: internal error

How kstest works

  • kstest(x) requires numeric vector input, omits NaN sample values, and tests against the standard normal CDF.
  • kstest(x,"Alpha",alpha) changes the significance level. alpha must be a scalar in (0,1).
  • kstest(x,"Tail",tail) accepts "unequal"/"both", "larger", and "smaller".
  • kstest(x,"CDF",cdf) accepts a two-column numeric matrix whose first column contains sample points and whose second column contains CDF probabilities in [0,1]. Rows are sorted by sample point, duplicate sample points are collapsed to the largest probability at that point, and probabilities must be nondecreasing after normalization. Sample values must lie inside the table's x range. Values are linearly interpolated between table rows.
  • "CDF" also accepts "normcdf", "normal", "norm", or a @normcdf function handle for the standard normal CDF.
  • The p-values use standard large-sample approximations. For two-sided tests, cv is returned for Alpha in [0.01,0.20]; for one-sided tests, cv is returned for Alpha in [0.005,0.10]. Outside those ranges, cv is NaN, matching MATLAB's documented critical-value limitations.
  • Continuous probability distribution objects for "CDF" are not supported until RunMat's makedist/fitdist distribution object surface exists.
  • Typed-integer sample and CDF-table data are RunMat-only extensions. Admitted values must be exactly representable as double before the statistical boundary; integer Alpha has no valid value in the required open interval (0,1) and is rejected.

Examples

Test a centered sample against the standard normal CDF

h = kstest([-1 -0.25 0 0.25 1])

Request all outputs with a one-sided alternative

[h,p,ksstat,cv] = kstest(x, "Tail", "smaller")

Use an explicit CDF table

cdf = [0 0; 0.5 0.5; 1 1];
h = kstest(x, "CDF", cdf)

Using kstest with coding agents

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

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

FAQ

Does kstest accept arbitrary CDF function handles?⌄

Only @normcdf is recognized as a function handle. Use a two-column CDF table for custom reference distributions.

Related Stats functions

Summary

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

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 · tsne

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 kstest is executed, line by line, in Rust.

  • View the source for kstest 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 kstest works
  • Examples
  • Test a centered sample against the standard normal CDF
  • Request all outputs with a one-sided alternative
  • Use an explicit CDF table
  • Using kstest with coding agents
  • FAQ
  • Related Stats functions
  • Summary
  • Ml
  • Random
  • Hist
  • Options
  • Open-source implementation
  • About RunMat