31. Numerical failure statuses
A numerical attempt can fail without producing an accepted result. The functions below report such failures with named return codes. An empty result or an unfitted object must be checked before downstream computation. Invalid input shapes, malformed options and programming exceptions remain errors; these statuses do not replace input validation.
Entry point |
Failed numeric attempt |
Result |
|---|---|---|
|
No usable initial residual candidate |
Empty |
|
Nonfinite/complex computed moments or numerical weights; unmet target |
Empty weights; |
|
Unmet moments or inadequate effective sample fraction |
Empty result; |
|
Polynomial orthogonality check fails |
Empty basis/expansion coefficients; |
Local-projection |
No usable observations or an unidentified horizon design |
Empty result; |
PCE |
Design has enough rows but lacks full column rank |
Unfitted object, cleared coefficients/design; |
|
Initial numeric log target is NaN, infinite or complex |
Empty chain/covariance; optional sixth output |
|
Same unusable initial numeric log target |
Chain result has empty |
For APIs with an optional return-code output, zero denotes acceptance. The
optimizer bee_root retains its existing successful exit-flag convention.
Use utils.error.code('NAME') rather than duplicating integer values.
31.1. Tilting and surrogate fitting
For example:
[weights,info,retcode]=utils.entropic_tilting.core(paths,moments,target);
if retcode
% No accepted weights; inspect info.residual and info.retcode.
return
end
An unmet target never yields accepted weights, even when only one output is
requested. tilt_scenario also returns an empty forecast structure on
failure. The public scenario interface uses the existing moment tolerance
and MinESS; the weighting objective, normalization and solver are
unchanged. Computed nonfinite or complex moments have their own status.
PCE fitting also accepts an optional second output:
[p,retcode]=fit(p,X,y);
if retcode
% p.is_fitted is false; p.diagnostics.retcode gives the same code.
return
end
prediction=predict(p,Xnew);
A failed numeric fit clears a previous successful fit, so stale coefficients cannot be used for prediction. Too few supplied rows, incompatible shapes and nonfinite supplied design values remain input errors. HDMR similarly clears the polynomial and expansion coefficients when its existing numerical orthogonality check fails. The basis algorithms and tolerances are unchanged.
The sensitivity report propagates this outcome in res.hdmr_retcode.
On failure its res.hdmr is empty and the HDMR table column stays NaN;
independently requested Sobol/MCF results remain available. The status is
zero for a successful requested HDMR fit and empty when HDMR was not requested.
31.2. Sampler initialization and callback errors
An initial numeric log-target return of NaN, positive/negative infinity or a
complex number cannot initialize a chain. No draws are accepted, and the
failure records the actual evaluation count with undefined statistics empty.
For the sampler classes, inspect results{chain}.retcode when that field
is present before using pop or best. Ordinary successful chain
structures retain their established fields.
If the target callback throws during initialization, the original exception is rethrown with its identifier and stack. There is no classifier based on exception wording. A wrong callback output type/shape remains an error. Proposal-time exception handling and rejection probabilities retain their existing behavior.
rise_dram has an optional sixth numeric return code; its first five
outputs retain their order. usrsmplr reads the sixth status from this
built-in only. Every other user or built-in callback retains its original
five-output call, irrespective of additional outputs it declares. Thus a
sixth diagnostic object, numeric count or checkpoint is never interpreted
as failure. DSMH’s documented extras remains available through its
direct sixth output exactly as before. On startup callback exceptions,
the original-exception rule also applies through the adapter.