statset — Create or update statistics options structures.

statset builds MATLAB-style statistics options structs for functions such as kmeans, tsne, bootstrp, lasso, and distribution fitting routines.

Syntax

options = statset()
options = statset(statfun)
options = statset(name, value, ...)
options = statset(oldopts, newopts)
options = statset(oldopts, name, value, ...)

Inputs

NameTypeRequiredDefaultDescription
statfunStringScalarYesStatistics function name.
nameStringScalarYesOption field name.
valueAnyVariadicOption value and additional name-value pairs.
oldoptsAnyYesExisting statistics options structure.
newoptsAnyYesReplacement statistics options structure. Nonempty fields override oldopts.
nameStringScalarNoOption field name or replacement options structure.

Returns

NameTypeDescription
optionsAnyStatistics options structure.

Errors

IdentifierWhenMessage
RunMat:statset:InvalidArgumentArgument grammar does not match supported statset forms.statset: invalid argument
RunMat:statset:InvalidOptionAn option name or value is malformed.statset: invalid option
RunMat:statset:InvalidStatfunThe statfun argument is not a supported statistics function name.statset: invalid statistics function

How statset works

  • statset() returns a struct with canonical statistics option fields initialized to empty values.
  • statset(statfun) returns common defaults for recognized statistics functions. RunMat includes defaults for widely used fitting, clustering, resampling, and parallel-capable routines.
  • statset(name,value,...) creates an options struct from name-value pairs. statset(oldopts,name,value,...) copies an existing options struct and applies overrides.
  • statset(oldopts,newopts) merges nonempty fields from newopts into oldopts, preserving old values where the replacement field is empty.
  • Option names are case-insensitive and support unique leading prefixes, matching MATLAB-style option lookup.
  • Recognized fields include Display, MaxFunEvals, MaxIter, TolBnd, TolFun, TolTypeFun, TolX, TolTypeX, GradObj, Jacobian, DerivStep, FunValCheck, Robust, RobustWgtFun, WgtFun, Tune, UseParallel, UseSubstreams, Streams, and OutputFcn.
  • Numeric tolerance fields must be finite positive scalars, iteration fields must be positive integers, and enum fields such as Display, TolTypeFun, and FunValCheck are validated.
  • Callback, stream, and robust-weight payload fields preserve function handles and metadata values so consuming builtins can interpret them.

Examples

Create custom statistics options

opts = statset('TolX', 1e-8, 'Display', 'off')

Expected output:

`opts` is a struct with canonical statistics option fields.

Start from function defaults and override a value

opts = statset('nbinfit');
opts = statset(opts, 'TolX', 1e-8)

Expected output:

`opts` keeps `nbinfit` defaults such as `MaxIter` and uses the new `TolX`.

Merge two options structures

base = statset('MaxIter', 20);
update = statset('TolFun', 1e-7);
opts = statset(base, update)

Expected output:

`opts` contains both `MaxIter` and `TolFun`.

Using statset with coding agents

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

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

Open-source implementation

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

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.