RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

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.

/
See all docs
Builtin Reference
    • anova1
    • binocdf
    • binscatter
    • boxplot
    • cdf
    • cdfplot
    • chi2cdf
    • corr
    • corrcoef
    • corrcov
    • cov
    • cov2corr
    • dummyvar
    • ecdf
    • filloutliers
    • fitdist
    • geomean
    • grpstats
    • harmmean
    • icdf
    • isoutlier
    • ksdensity
    • kstest
    • kurtosis
    • lsline
    • mad
    • mode
    • nanmax
    • normalize
    • normcdf
    • norminv
    • normpdf
    • onehotdecode
    • onehotencode
    • pca
    • pdf
    • prctile
    • qqplot
    • quantile
    • refline
    • rmse
    • scatterhist
    • skewness
    • tabulate
    • tcdf
    • tiedrank
    • tinv
    • tpdf
    • ttest
    • ttest2
    • wblinv

ttest — One-sample and paired-sample Student-t tests.

Test a population mean with unknown variance, or test the mean of paired differences.

Syntax

[h,p,ci,stats] = ttest(x,Name,Value,...)
[h,p,ci,stats] = ttest(x,reference,Name,Value,...)

Inputs

x
Type
NumericArray
Required
Yes
Default
—
Description
Real single or double sample array.
name_value_pairs
Type
Any
Required
Variadic
Default
—
Description
Alpha, Dim, and Tail name/value pairs.
reference
Type
NumericArray
Required
No
Default
0
Description
Scalar population mean or same-sized paired sample.
NameTypeRequiredDefaultDescription
xNumericArrayYes—Real single or double sample array.
name_value_pairsAnyVariadic—Alpha, Dim, and Tail name/value pairs.
referenceNumericArrayNo0Scalar population mean or same-sized paired sample.

Returns

h
Type
LogicalArray
Description
Reject when p is less than Alpha.
p
Type
NumericArray
Description
Student-t tail probability.
ci
Type
NumericArray
Description
Confidence limits for the population mean or paired mean difference.
stats
Type
Any
Description
Scalar structure containing tstat, df, and sd arrays.
NameTypeDescription
hLogicalArrayReject when p is less than Alpha.
pNumericArrayStudent-t tail probability.
ciNumericArrayConfidence limits for the population mean or paired mean difference.
statsAnyScalar structure containing tstat, df, and sd arrays.

Errors

RunMat:ttest:InvalidArgument
When
Sample class, paired geometry, option grammar/value, device residency intent, or output count is unsupported.
Message
ttest: invalid argument
IdentifierWhenMessage
RunMat:ttest:InvalidArgumentSample class, paired geometry, option grammar/value, device residency intent, or output count is unsupported.ttest: invalid argument

Samples and hypotheses

ttest(x) tests mean zero. ttest(x,m) tests a finite scalar population mean m. A nonscalar second sample selects the paired test and must have exactly the same size as x; paired observations are subtracted before estimating variance. Samples and numeric controls accept real single or double values. Native integer, logical, complex, object, and distributed sample inputs are unsupported rather than implicitly coerced.

NaN observations are omitted; a paired observation is omitted if either member is NaN. Each lane uses its observed count n, sample standard deviation sd, and n-1 degrees of freedom. Fewer than two observations produce NaN probabilities and a false decision. Computed confidence endpoints are NaN in that case; the untested endpoint of a one-sided interval remains infinite. Zero standard error gives the formula's signed infinite or undefined t statistic, and finite confidence bounds can collapse to the observed mean. Infinite observations can produce undefined statistics.

The default tests the first nonsingleton dimension. Dim selects a positive, platform-representable 1-based integer dimension; dimensions beyond the input rank are singleton dimensions. Dimension-derived metadata must have representable geometry and a successful allocation. Result arrays have length one in that dimension; confidence limits have length two there. No broadcasting is performed for nonscalar paired samples.

Options and results

Name/value options are case-insensitive Alpha, Dim, and Tail. Alpha defaults to 0.05 and must lie strictly between zero and one. Tail is both (default), right, or left. Unknown options, incomplete pairs, and unsupported values raise an error; later duplicate options replace earlier ones.

[h,p,ci,stats] returns a logical decision h (p < Alpha), the selected Student-t tail probability, the confidence interval for the original population mean or paired mean difference, and a scalar structure with tstat, df, and sd arrays. The one-sided interval has an infinite bound on its untested side. Numeric outputs use host binary64, including single-input tests; this is not a claim of MATLAB single-output-class parity.

Execution and resource limits

Computation runs on the host. Only authenticated automatic residency may use the context-owned host gather fallback, for samples and numeric controls alike. Explicit gpuArray or unproven device intent is rejected before any argument transfer; call gather explicitly to request host analysis. There is no provider-native test kernel, fusion producer, distributed implementation, or separately enabled explicit-host-fallback extension. Gather errors and typed cancellation propagate without retry or relabeling.

Input scans and lane statistics cooperate with the owning execution context. Finite host-memory requests are rejected before gather and workspace allocation because this implementation has no complete lane/result allocation certificate; it does not fabricate a finite-memory grant.

Examples

Test a population mean

[h,p,ci,s] = ttest([1;2],0);

Test paired differences

x = [2;4;6]; y = [1;2;3]; [h,p,ci,s] = ttest(x,y,'Tail','right');

Using ttest with coding agents

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

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

Related Stats functions

Summary

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

Ml

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

Random

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

Hist

histc · histcounts · histcounts2

Options

statget · statset

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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
  • Samples and hypotheses
  • Options and results
  • Execution and resource limits
  • Examples
  • Test a population mean
  • Test paired differences
  • Using ttest with coding agents
  • Related Stats functions
  • Summary
  • Ml
  • Random
  • Hist
  • Options
  • About RunMat