System identification¶
Fit a model's physical parameters (Fit) or its noise model (NoiseFit)
to recorded data. See Fit parameters from a log
for a worked recipe.
Parameter fit¶
manta.Fit ¶
MAP parameter fit over recorded windows (see module docstring).
Args:
world — the model. Finalized by the internal Sim; the
fit never mutates it (until result.apply()).
parameters — {name: Prior | Tied | Free | None}. Prior/None
keys resolve against the model's promotable
Parameters (<craft>.<part>.<param>); None =
flat prior (only safe for parameters the data
fully observes). A Tied key is promoted but
derives from another entry's decision variable; a
Free key is a fresh auxiliary name (not a model
parameter) that exists to source ties.
Source code in manta/fit/_map.py
870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 | |
solve ¶
solve(windows, *, weights=None, state_weights=None, window_weights=None, state_robust_delta=None, initial_values=None, compute_posterior=True, solver='ipopt', least_squares_options=None, verbose=False, progress=None, posterior_progress=None, ipopt_options=None)
Build the windowed prediction-error + prior NLP and solve it.
Args:
windows — the recorded data (≥ 1 Window).
weights — optional per-sensor scalar weights on the squared
residuals ({sensor name/suffix: w}); use
1/σ_meas² to whiten mixed-unit sensors. Default 1.
state_weights — optional per-state-slot weights on tangent-space
trajectory residuals. Default 1 for every recorded slot.
window_weights — optional positive scalar per window. This is the
dataset-composition boundary for independently normalized
real and synthetic groups; default 1 for every window.
state_robust_delta — optional positive pseudo-Huber transition in
normalized trajectory-RMS units. It applies to state
slots carrying Window.x_scale and limits the
influence of one structurally unrepresentable rollout
without introducing a non-differentiable clipping point.
initial_values — optional warm start for decision parameters in
ambient units. Keys use the same exact-or-unique-suffix
resolution as parameter declarations. Priors and bounds
are unchanged; only IPOPT's starting iterate moves.
compute_posterior — build the full residual Jacobian used only for
identifiability diagnostics. Disable on large production
fits to save peak memory; fitted values are unchanged.
solver — "ipopt" or "gauss-newton". The latter exploits
the residual structure without constructing symbolic
second derivatives and is preferred for large unrolled
plant fits.
least_squares_options — damped Gauss-Newton tolerances, iteration
limit, and damping options. Used only by that solver.
verbose — IPOPT iteration output.
progress — optional callback after every accepted IPOPT iteration.
It receives the current and retained-best objectives plus
checkpoint-safe ambient parameter values. Return False
to stop cleanly at that boundary. This is independent of
verbose and cannot be combined with a raw CasADi
iteration_callback option.
posterior_progress — optional callback after each residual block
contributes to the posterior normal matrix.
ipopt_options — extra nlpsol options, merged last.
Source code in manta/fit/_map.py
1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 | |
sensor_residuals ¶
Replay fitted mean predictions and return raw sensor residuals.
This is the conditional residual boundary used by inexpensive sensor
noise characterization after a mean fit. It reuses the same compiled
step/mapaccum functions and window conventions as :meth:solve;
callers do not need to reconstruct simulation ordering themselves.
Source code in manta/fit/_map.py
1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 | |
manta.FitResult ¶
FitResult(blocks, fields, tie_sources, v_opt, p_opt, JtJ, objective, stats, world, source_model_id, source_artifact_id, source_derivation, *, posterior_computed, initial_objective, tangent_prior_information=None, latent_blocks=())
Fitted values + Gauss-Newton posterior diagnostics.
Attributes:
values — {name: fitted value} (float for scalars,
ndarray for vectors) — every promoted
parameter (tied ones derived through their
affine map) plus every Free variable.
labels — one entry per fitted scalar component of the
DECISION vector (tied parameters don't appear;
their source does).
log_scale — per-component bool; True ⇒ the sigmas below
are RELATIVE (log-space).
prior_sigma — per-component prior σ (inf = no prior).
posterior_sigma — per-component Gauss-Newton posterior σ from
(JᵀJ + Σ₀⁻¹)⁻¹. ≈ prior σ ⇒ the data did
not inform this component.
JtJ — data-only Gauss-Newton information matrix in
decision space; its small eigenvalues are the
unidentifiable directions.
objective — final loss value.
stats — IPOPT return stats.
converged — IPOPT's success flag; False ⇒ the values below
are the failed solve's final iterate (a
RuntimeWarning was emitted), not an optimum.
expanded — True when the NLP ran SX-expanded; False means
the loss graph kept a Linsol node and IPOPT
evaluated the (order-of-magnitude slower)
interpreted MX graph (a RuntimeWarning said
so at solve time).
Source code in manta/fit/_map.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 | |
weak_directions ¶
The k least-informed directions of the DATA alone: list of
(eigenvalue, {label: component}) for the smallest eigenvalues
of JᵀJ. A near-zero eigenvalue is an unidentifiable parameter
combination (e.g. the thrust/mass scale).
Source code in manta/fit/_map.py
linear_contrast_posterior_sigma ¶
Posterior sigma of a local linear parameter combination.
coefficients names decision-space component labels from
parameter_labels. The covariance is marginalized over window-local
initial states, so this can distinguish a well-constrained relative
quantity (for example one mount offset minus another) from two weak
absolute parameters. A contrast touching an information-null
direction reports infinity rather than false confidence.
This is a local tangent-space diagnostic. SO(3) labels therefore use
the .delta[i] components shown by :meth:summary.
Source code in manta/fit/_map.py
parameter_posterior_covariance ¶
Marginal posterior covariance for selected parameter tangents.
The returned block is taken from the inverse joint information over all fitted parameters and window-local initial states, so nuisance variables are marginalized rather than held fixed. A requested coordinate touching an information-null direction is refused instead of receiving a spuriously finite pseudoinverse covariance.
Source code in manta/fit/_map.py
apply ¶
Write the fitted values — tied parameters derived through
their affine maps — back onto the world's Part instances. A
transform built afterwards (Sim(world), EKF(world), a C++
deploy) bakes them in as constants.
Source code in manta/fit/_map.py
fitted_world ¶
An editable copy of the authoring world with the fitted values
(tied parameters derived) written in — what derive() freezes and
evidence() predicts with. Refuses an unconverged solve.
Source code in manta/fit/_map.py
evidence ¶
evidence(held_out, *, sensor, criteria=None, lag_count=20, selection=(), configuration_id=None, channel_contract_id=None)
Held-out evidence for the fitted model (see held_out_evidence).
held_out must be untouched by the fit: any window whose content
matches a training window is refused. The result is what
derive(evidence=...) attaches and what a ModelForce consumes.
Source code in manta/fit/_map.py
derive ¶
Return a new validated model revision carrying fit provenance.
evidence is the typed held-out artifact from evidence(); its
criteria-derived accepted decision travels with the revision.
Omitting it preserves exploratory fitting while making the
resulting artifact visibly unaccepted — a model-aided estimator
refuses it.
Source code in manta/fit/_map.py
summary ¶
Per-component table: fitted value, prior σ vs posterior σ.
post/prior ≈ 1 flags a component the data did not inform —
its fitted value is your prior talking, not the flight. Tied
parameters follow, showing their derived values and source.
Source code in manta/fit/_map.py
manta.FitProgress
dataclass
¶
One accepted IPOPT iteration exposed at the fitting boundary.
values contains ambient model parameter values with structural ties
already resolved, plus any decision-only :class:Free values. It is the
retained best iterate, not necessarily IPOPT's current trial point, so a
caller can safely checkpoint it. Return False from a progress callback
to request an orderly early stop; None or True continues.
FitResult.evidence(held_out, sensor=...) computes the typed held-out
evidence (below) on windows the fit never saw; FitResult.derive(evidence=...)
returns an immutable ModelArtifact with the source revision, objective,
fitted values, and that evidence. apply() remains the mutable alternative
for iterative authoring.
Noise fit¶
manta.NoiseFit ¶
Innovation-NLL fit of noise σ values (see module docstring).
Args:
world — the model (dynamics/geometry at their — ideally
already fitted — declared values).
noise — {channel name/suffix: Prior | None}. Channel names
are the declaration names (drone.imu.gyro_noise,
drone.imu.gyro_bias); priors are relative
(log-space), None = flat.
sensors — measurement outputs the filter consumes (default: all
with traces required in every window).
estimator — optional model-derived estimator transform. Supplying an
INS reuses its strapdown transition, selected sensor set,
IMU prediction inputs, and measurement-source mapping.
Source code in manta/fit/_nll.py
solve ¶
solve(windows, *, P0=1e-06, solver='ipopt', verbose=False, progress=None, batched_options=None, ipopt_options=None, hessian_diagnostics='finite-difference')
Minimize the windows' total innovation NLL + prior over log-σ.
Args:
windows — recorded data; every chosen sensor needs a trace
in every window.
P0 — initial tangent covariance per window, P0 · I.
Keep small when x0 is trusted (synthetic truth);
grow it for estimator-seeded initial states.
Source code in manta/fit/_nll.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 | |
manta.NoiseFitResult ¶
NoiseFitResult(channels, s_opt, hessian, objective, stats, world, source_model_id, source_artifact_id, source_derivation)
Fitted σ per channel + Laplace posterior diagnostics.
prior_sigma / posterior_sigma are RELATIVE (log-space) widths;
posterior ≈ prior means the data didn't inform that σ. converged
is IPOPT's success flag — False ⇒ the values are the failed solve's
final iterate (a RuntimeWarning was emitted), not an optimum.
expanded records whether the NLL ran SX-expanded (False = a Linsol
node kept it on the slower interpreted MX path; a RuntimeWarning
said so at solve time).
Source code in manta/fit/_nll.py
apply ¶
Write the fitted σ back onto the owning parts
(<channel>_sigma attributes); transforms built afterwards
(an EKF(world)'s auto-Q/R, a NoiseDriverd truth sim) use
them.
Source code in manta/fit/_nll.py
fitted_world ¶
An editable copy of the authoring world with the fitted σ values
written in — what derive() freezes and evidence() predicts
with. Refuses an unconverged solve.
Source code in manta/fit/_nll.py
evidence ¶
evidence(held_out, *, sensor, criteria=None, lag_count=20, selection=(), configuration_id=None, channel_contract_id=None)
Held-out evidence for the fitted model (see held_out_evidence);
windows that entered the fit are refused.
Source code in manta/fit/_nll.py
derive ¶
Return a structurally validated model revision carrying the typed held-out evidence (or none — visibly unaccepted).
Source code in manta/fit/_nll.py
Noise fits support the same derive() / apply() split.
manta.FitDerivationReport
dataclass
¶
FitDerivationReport(method, source_artifact_id, objective, values, evidence, default_fill_policy_id=DEFAULT_FILL_POLICY_ID, default_fills=())
Provenance of one derived model revision.
evidence is the typed held-out artifact (FitEvidence) or None
for an exploratory derivation that computed none; there is no untyped
form. accepted is the evidence's own criteria-derived decision and
is never set by a caller — a report without evidence is not accepted.
default_fills records every model initial-state/control value used for
omitted window data; exploratory reports retain their training fills too.
Held-out evidence¶
The doctrine's artifact channel: a fitted model's held-out residual bias and
its time-correlated process covariance are typed evidence that model-aided
estimators consume explicitly — never an implicit zero. hold_out splits the
log, held_out_evidence (or FitResult.evidence / NoiseFitResult.evidence)
computes the artifact, FitAcceptanceCriteria declares the thresholds that
decide FitEvidence.accepted, and ModelForce(evidence=...) consumes it.
FitEvidence.binding scopes that decision to the exact evaluated fitted model
and artifact, pre-fit source model and artifact, opaque configuration and
profile IDs, disjoint training/selection/acceptance dataset digests, and the
qualified Manta channel shape/cadence contract. An integration layer can also
provide channel_contract_id for its schema/frame/unit contract.
FitResult.derive() and NoiseFitResult.derive() reject evidence issued for
another result; model-aided INS rejects unbound evidence when consuming it.
Manta deliberately remains permissive when a window omits initial-state or
control fields: it fills them from the model. Every such substitution is a
typed FitDefaultFill in the derivation report and evidence, including its
training/selection/acceptance role, window digest, source, field name, shape,
and exact finite numeric value. These records are canonical artifact identity
and never acceptance checks; FitEvidence.accepted still depends only on the
declared residual criteria. dt and t0 are not substitutions: every Window
already has concrete values for both and window_digest binds them exactly.
manta.FitDefaultFill
dataclass
¶
One model value substituted for missing fit-window data.
The record is deliberately numeric and shape-explicit so model artifact
provenance has one deterministic JSON representation. dataset_role
is one of training, selection, or acceptance; source is
model_initial_state or model_control_default.
manta.fit.hold_out ¶
Deterministic training / held-out split: the last
ceil(fraction · n) windows (in the order given) are held out and
must never enter the fit. Both sides must be non-empty.
Source code in manta/fit/_evidence.py
manta.fit.held_out_evidence ¶
held_out_evidence(model, windows, *, sensor, criteria=None, lag_count=20, correlation_confidence=0.99, training=(), selection=(), source_model_id=None, source_artifact_id=None, configuration_id=None, profile_id='manta.held_out_replay.v1', channel_contract_id=None, training_default_fills=(), selection_default_fills=())
Compute :class:FitEvidence for sensor on untouched held-out
windows.
Args:
model — the fitted model: a World or ModelArtifact. Its
mean prediction (noise zeroed) is folded from each
window's x0 over the recorded controls.
windows — the held-out windows; each needs a z trace for
sensor with more than lag_count observed samples
and all must share dt. A regular z_mask cadence is
supported; irregular masks are refused because the
autocorrelation model assumes a fixed sample interval.
sensor — the measured output whose residual z − h is the
model error (full name or unique suffix).
criteria — acceptance thresholds (default
:class:FitAcceptanceCriteria).
lag_count — autocorrelation lags used for the τ/σ² fit (default
20; cover a few correlation times at the sample rate).
correlation_confidence — the χ²(2) confidence a Gauss–Markov
component must reach over the white model to be kept
(default 0.99, a limit of 9.21); below it the axis
records the white fallback with this number in its
reason.
training — content digests (window_digest) of the windows the
fit was solved on; a held-out window among them is
refused (the acceptance set must be untouched).
selection — content digests used to choose the model/profile. They
must be disjoint from both training and acceptance.
source_model_id/source_artifact_id — identity of the pre-fit source;
defaults to the evaluated model for direct replay.
configuration_id/profile_id — opaque identities supplied by the
integration layer. Manta binds but does not interpret
their policy.
channel_contract_id — optional external schema/frame/unit digest.
The Manta channel name, shape, and cadence are always
bound separately.
Source code in manta/fit/_evidence.py
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 | |
manta.FitEvidence
dataclass
¶
FitEvidence(channel, held_out, axes, criteria, checks, accepted, binding=None, default_fill_policy_id=DEFAULT_FILL_POLICY_ID, default_fills=())
The typed held-out fit-evidence artifact.
Construct through :meth:evaluate; checks and accepted are a
pure function of axes and criteria and construction refuses any
other value. The artifact is a frozen dataclass of scalars, strings and
tuples, so ModelArtifact's canonical derivation hashing covers it
field by field. Missing-window substitutions are carried separately as
default_fills and never participate in acceptance checks.
evaluate
classmethod
¶
Build the artifact, deciding accepted from criteria
(default :class:FitAcceptanceCriteria).
Source code in manta/fit/_evidence.py
manta.FitEvidenceBinding
dataclass
¶
FitEvidenceBinding(fitted_model_id, fitted_artifact_id, source_model_id, source_artifact_id, configuration_id, profile_id, training_window_digests, selection_window_digests, acceptance_window_digests, channel_shape, channel_rate_hz, channel_contract_id)
Exact identity scope in which held-out evidence is valid.
The opaque configuration/profile identifiers are deliberately generic: Manta binds them but does not interpret vehicle or release policy. Dataset identities are content digests, and the channel contract is the qualified Manta port name, shape, cadence, and caller's optional external schema digest.
manta.AxisFitEvidence
dataclass
¶
AxisFitEvidence(axis, sample_count, residual_bias, residual_bias_stderr, residual_rms, lag_one_autocorrelation, lag_count, fitted_tau, fitted_correlated_fraction, correlation_chi2, correlation_chi2_limit, white_floor_fraction, noise_model, white_sigma, autocorrelation_rmse, white_fallback, white_fallback_reason)
Held-out evidence for one residual axis.
residual_bias is the held-out mean residual mean(z − h) with
its standard error (effective sample count corrected for lag-one
autocorrelation); residual_rms the raw root-mean-square residual.
The autocorrelation fit ρ(l) ≈ a·exp(−l·dt/τ) over lag_count
lags yields fitted_tau and fitted_correlated_fraction (a).
correlation_chi2 is the fit's significance statistic
n·(SS_white − SS_fit) — the reduction in squared autocorrelation
misfit the two-parameter model buys over the white model, which is
χ²(2)-distributed for white residuals — and correlation_chi2_limit
the declared quantile it had to exceed. The decision that followed is
explicit: noise_model is the Gauss–Markov model when the correlated
component is significant and the fitted τ is at or above the sample
interval, otherwise the white model with white_fallback set and
white_fallback_reason naming why. white_sigma is the
uncorrelated per-sample floor (equal to noise_model.sigma for a
white model). For a Gauss–Markov model the white fraction of the
variance is max(1 − a, white_floor_fraction) with
white_floor_fraction = 1/√n: a sample autocorrelation over n
points scatters by about 1/√n, so it cannot resolve a white
component smaller than that — the floor is the data's resolving power
(recorded here), never a default, and it keeps the pseudo-measurement
covariance away from the singular R = 0 a saturated fit would
imply. autocorrelation_rmse is the RMS misfit between the
empirical autocorrelation and the chosen model's.
manta.ProcessNoiseModel
dataclass
¶
One axis' fitted process-noise model.
Args:
kind — "white" (per-sample σ), "gauss_markov" (stationary σ
with correlation time tau seconds), or
"random_walk" (σ/√Hz drift density).
sigma — 1-σ magnitude in the residual's units (≥ 0).
tau — correlation time in seconds; required (finite, > 0) for
"gauss_markov" and forbidden otherwise.
manta.HeldOutWindow
dataclass
¶
Definition of the held-out (acceptance) set the evidence was computed on: how many windows, how many samples, at which step, and the content digest of every window (the identity a consumer can check against its training set).
manta.FitAcceptanceCriteria
dataclass
¶
FitAcceptanceCriteria(max_bias_ratio=0.5, max_autocorrelation_rmse=0.15, min_samples=200, max_residual_rms=None)
The numeric thresholds that decide FitEvidence.accepted.
Every criterion applies per axis; the artifact records each check's value, limit, and outcome. Defaults:
max_bias_ratio = 0.5— |held-out bias| ≤ 0.5 × the modelled residual σ. A bias larger than that is systematic model error, not noise the filter can absorb.max_autocorrelation_rmse = 0.15— the empirical autocorrelation over the fitted lags must match the chosen noise model to within 0.15 RMS (white noise over N ≥ 200 samples scatters at ≈ 1/√N ≈ 0.07, so this accepts sampling scatter and rejects a mis-modelled spectrum).min_samples = 200— held-out samples per axis; fewer cannot support the autocorrelation fit.max_residual_rms = None— optional absolute ceiling on the raw held-out residual RMS in the channel's units (None= no ceiling; set it from the vehicle's risk policy).
manta.fit.AcceptanceCheck
dataclass
¶
One criterion evaluated on one axis.
manta.fit.window_digest ¶
Content identity of a Window (sha256 over every trace, dt,
t0) — what HeldOutWindow.window_digests records and what the
untouched-acceptance-set check compares.
Source code in manta/fit/_evidence.py
Residual covariance¶
bartlett_hac_residual_statistics is the dimension-generic mathematical
boundary used by fitting and reduction pipelines after they produce residual
sequences. It keeps independent windows separate, reports bias explicitly, and
returns both instantaneous sample covariance and a positive-semidefinite
Bartlett/Newey–West long-run covariance suitable as white-equivalent process
noise. Vehicle replay, acceptance thresholds, and release policy remain with
the caller.
manta.bartlett_hac_residual_statistics ¶
Estimate bias, sample covariance, and Bartlett-HAC covariance.
Each input is one independent (samples, dimension) sequence. Lagged
products never cross sequence boundaries, so unrelated fitting windows do
not acquire artificial adjacency. All sequences must share a dimension;
the calculation is otherwise dimension-agnostic.
Source code in manta/fit/_residuals.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
manta.ResidualStatistics
dataclass
¶
ResidualStatistics(bias, instantaneous_covariance, white_equivalent_covariance, reference_dt_s, correlation_lag_steps, correlation_horizon_s, samples, windows, effective_sample_size, effective_sample_size_unclipped, instantaneous_raw_min_eigenvalue, instantaneous_psd_correction_norm, instantaneous_psd_correction_count, white_equivalent_raw_min_eigenvalue, white_equivalent_psd_correction_norm, white_equivalent_psd_correction_count)
Bias and covariance evidence from independent residual sequences.
instantaneous_covariance describes individual residual samples.
white_equivalent_covariance is the Bartlett/Newey–West long-run
covariance: using it as independent per-step noise reproduces the
asymptotic integrated-error growth of the observed correlated sequence.
Bias remains separate and is never folded into zero-mean covariance.
Raw minimum eigenvalues and correction norm/count fields expose any
roundoff-scale PSD projection. Materially indefinite estimates are
refused. effective_sample_size_unclipped preserves the estimate before
the public effective sample size is bounded to [1, samples].
Inputs¶
manta.Window
dataclass
¶
Window(x0, x0_sigma=dict(), u=dict(), x=dict(), x_scale=dict(), z=dict(), z_mask=dict(), dt=0.01, t0=0.0)
One fitting window: a short recorded rollout.
Args:
x0 — nested initial state dict (the sim.state shape:
{craft: {slot: value}}). Slots omitted fall back to the
world's initial state and are recorded as FitDefaultFill
provenance.
x0_sigma — optional per-slot tangent-space standard deviations for
multiple shooting. A named slot must be explicitly present in
x0; its value is the prior mean and the fitter optimizes a
manifold-aware initial perturbation for that window. Scalars are
broadcast across the slot tangent dimension. An SO(3) value is
therefore a three-component rotation-vector sigma, never a
four-component quaternion sigma.
u — recorded controls: {input name/suffix: scalar | (K,)}.
A scalar is held for the whole window; inputs omitted hold
their model default and are recorded as FitDefaultFill
provenance.
x — recorded state trajectories: nested or flat mapping from state
slot name to (K, ambient_dim) values. Row k is the state after
step k. Only named slots enter Fit; quaternion slots are
compared on their SO(3) tangent manifold, not componentwise.
x_scale — optional positive physical scale per recorded state slot.
When present, Fit scores that slot as a trajectory mean-square
sum(error²) / (K · scale²) instead of a raw sample sum.
This is the explicit mixed-unit normalization boundary: callers
choose meaningful floors/tolerances in each slot's native units.
z — recorded sensor readings: {sensor name/suffix:
(K, dim) | (K,)}. Row k is the reading produced by step k
(the step taken FROM state k). For Fit, only sensors
present here enter the loss; for NoiseFit, every chosen
sensor needs a trace.
z_mask — optional explicit availability masks for multi-rate
observations. Each key names a trace in z and carries a
boolean (K,) array; only true rows enter the fit. Values at
false rows are storage placeholders and are never observations.
dt — fixed step, seconds.
t0 — world-clock time of x0.
dt and t0 are always concrete values and are part of
:func:window_digest; FitDefaultFill records only actual model-value
substitutions for omitted x0 and u fields.
manta.Prior
dataclass
¶
Gaussian prior on one fitted parameter.
Args:
sigma — 1-σ width. Scalar (isotropic across the parameter's
components) or a per-component sequence. With log=True
it is RELATIVE (log-space): sigma=0.3 ≈ ±30%.
mean — prior mean. None (default) → the model's declared
value.
log — fit log(p) instead of p, elementwise. Strictly-
positive parameters only (mass, moi, a thrust magnitude
along one axis). Keeps every component positive with no
constraint and makes pure scale ambiguities linear.
NoiseFit ignores this flag — noise σ is ALWAYS fit in
log-space, and sigma there is always relative.
lower — hard lower bound, AMBIENT space (a value, not a log).
upper — hard upper bound, ambient. Scalar or per-component.
Enforced as IPOPT box constraints — the sanity rails
that keep a physically absurd optimum off the table
(a thruster gain that can't exceed the motor's rating,
a mount that must stay inside the hull). The prior pulls
softly; bounds are walls. In NoiseFit they bound σ
itself. The declared/starting value must satisfy them.
Structure¶
Symmetry and sanity are declared, not hoped for: tie identical or
mirrored parameters to one decision variable (Tied), introduce shared
geometry as an auxiliary variable (Free), and wall off absurd values
with Prior(lower=, upper=) box bounds.
manta.Tied
dataclass
¶
Structural tie: this promoted parameter is a fixed affine function
of another fitted parameter (or a Free variable), not a decision
variable of its own — p = scale · p_source + offset, in AMBIENT
space (after any log-reparam of the source).
This is how symmetry is enforced rather than hoped for: identical actuators share one gain, mirrored mounts share one geometry. Fewer decision variables ⇒ better-conditioned fits, and every data point that touches any tied copy informs the shared source.
Args:
source — name/suffix of the fitted parameter (or Free name)
this one derives from. Must itself be a decision
variable — chains of ties are not supported; tie all
copies to the same source.
scale — None (identity — identical copies), a scalar, a
per-component sequence (elementwise, e.g. a mirror's
sign flips (-1, 1, 1)), or a full
(target_dim, source_dim) matrix (e.g. a scalar arm
length mapped to a 3-vector mount position).
offset — additive constant: None (zero), scalar, or
length-target_dim.
Examples::
# four identical motors — one fitted gain
"t1.force_quad": Prior(sigma=3.0),
"t2.force_quad": Tied("t1.force_quad"),
# mirrored mount across the y-z plane
"t2.mount_offset": Tied("t1.mount_offset", scale=(-1, 1, 1)),
# scalar arm length -> the four X-frame mount positions
"arm": Free(0.12, prior=Prior(sigma=0.02, lower=0.0)),
"t1.mount_offset": Tied("arm", scale=[[1], [1], [0]]),
"t2.mount_offset": Tied("arm", scale=[[-1], [1], [0]]),
manta.Free
dataclass
¶
Auxiliary decision variable that is NOT a promoted parameter of
the model — it exists to be the source of Tied entries (a shared
arm length, a common incidence angle). Its key in Fit(parameters=)
is a fresh name, not a part parameter.
Args:
init — starting value (scalar or vector); also the prior mean
unless the prior says otherwise.
prior — optional Prior (sigma/mean/log/bounds), same semantics
as for a promoted parameter.