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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
statfun | StringScalar | Yes | — | Statistics function name. |
name | StringScalar | Yes | — | Option field name. |
value | Any | Variadic | — | Option value and additional name-value pairs. |
oldopts | Any | Yes | — | Existing statistics options structure. |
newopts | Any | Yes | — | Replacement statistics options structure. Nonempty fields override oldopts. |
name | StringScalar | No | — | Option field name or replacement options structure. |
Returns
| Name | Type | Description |
|---|---|---|
options | Any | Statistics options structure. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:statset:InvalidArgument | Argument grammar does not match supported statset forms. | statset: invalid argument |
RunMat:statset:InvalidOption | An option name or value is malformed. | statset: invalid option |
RunMat:statset:InvalidStatfun | The 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 fromnewoptsintooldopts, 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, andOutputFcn. - Numeric tolerance fields must be finite positive scalars, iteration fields must be positive integers, and enum fields such as
Display,TolTypeFun, andFunValCheckare 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.
Related Stats functions
Options
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
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
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how statset is executed, line by line, in Rust.
- View the source for statset 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.