Skip to main content

Module fit

Module fit 

Source
Expand description

Fitting a simulation to a flight’s log by least squares (M7.3b, ADR-257 §1, ADR-316).

What it is for. A flyer who has a log and a design wants to know what the flight says about the design: was the drag what the simulator took, did the motor deliver its rated impulse, what wind did the rocket feel? This module changes those inputs until the simulated flight, read as the log’s sensor reads it, passes through the log’s samples, and says how far each could still be off.

The method. Levenberg–Marquardt (K. Levenberg, Q. Appl. Math. 2, 1944; D. W. Marquardt, J. SIAM 11, 1963; the damped normal equations as in Press et al., Numerical Recipes, §15.5) minimizes

χ²(x) = Σ (yᵢ − g h(tᵢ − τ; x) − h₀ − d tᵢ − c p(tᵢ − τ; x))² / σ²
      + Σ (rₖ − r(tₖ − τ; x))² / σ_r² + Σ (xⱼ − μⱼ)² / sⱼ²

over x: the drag scale, impulse scale, burn time’s scale, a constant wind vector and the mass on the weighed mass, with what the log can’t state as further unknowns: the clock offset τ, the height offset h₀, the height’s drift d, and for a barometer its gain g and port coefficient c on the port’s dynamic-pressure height p (each sized as crate::residuals sizes it). Left out, these went into the drag scale. The second sum is the track r, where a log holds one. The third holds each parameter to what is stated of it (Stated). That sum is what “mass within its weighed uncertainty” means, and it is why a log with no word on the wind gives back the wind’s stated range. σ is the fit’s own residual, floored at FLOOR_M, and σ_r likewise at FLOOR_HORIZONTAL_M, re-estimated once after a first pass. A barometer’s bins at or past Mach 0.8 are left out, as its port’s pressure there follows no one coefficient.

Each parameter’s standard error is the square root of the diagonal of σ² (JᵀJ)⁻¹, J the Jacobian of the weighted residuals at the solution, and its 90% interval is that error times the shares fitted on other flights (crate::synthetic::fits). The samples are taken as a median every BIN_S, since the barometer’s noise is correlated from one sample to the next.

What it reads. The height track the readings take, from a second before the reader’s liftoff to its apogee, on the reader’s pad; before an ejection charge’s pressure spike. Where the log holds latitude and longitude, it reads the rocket’s drift too, which is what speaks to the wind.

The Bayesian option. bayesian fits as fit does, then draws the posterior of the same unknowns about its answer, each draw a flight flown (ADR-317, ADR-320): the wind first, then the rest about where a Gauss–Newton step puts them in that wind, the sensor’s linear unknowns integrated out in closed form, and on a log of height alone the wind’s shear exponent drawn too. Its 90% intervals are the posterior’s 5% and 95% points, with no shares.

How far to trust it. The errors are linearized about the solution, so they say nothing of a second solution elsewhere. The 90% intervals hold on synthetic flights (crate::synthetic::fits and the committed report), where the fit knows the design, rail, site and day’s air: on a real flight its model’s errors go into the scales with nothing to say so. A scale is the factor that best fits one flight, not the rocket’s drag at every Mach.

Structs§

Bayesian
The Bayesian option’s answer: the least-squares fit it starts from, and the posterior of the flown parameters drawn around that fit’s answer.
Fit
A fit’s answer.
Observations
What a fit reads.
Parameters
What a fit may change in a flight.
Prior
What is stated of a parameter before the log: normal, mean ± sd.
Sampling
How the Bayesian option draws its posterior (bayesian).

Enums§

Noise
How a fit takes its residuals’ noise.

Constants§

BIN_S
The width of a bin of samples, s.
FLOOR_HORIZONTAL_M
The least noise a horizontal position’s residual is taken to have, m: a receiver’s lag in the boost, which the bins’ median doesn’t remove (crate::synthetic::logger’s loop).
FLOOR_M
The least noise a height’s residual is taken to have, m: readings::NOISE_M, what the barometer’s noise adds to a reading.
FLOWN
How many parameters a fit flies.
MISFIT_SHARE
How far a fit’s residual may stand from its log, a share of the spread of the heights it read: past it, the simulation explains too little of them for this to be the log of this flight, and the log says nothing, whatever the errors come to. On a log of noise, nothing is explained and the share stands near one; every synthetic flight fits far under it (the report’s margin, ADR-316).
SHEAR_EXPONENT
The wind’s shear a fit of heights alone carries: the power-law exponent of IEC 61400-1’s normal wind profile (IEC 61400-1:2019, §6.3.2.2, α = 0.2), above the 1/7 law’s neutral 0.14. The fit’s wind is constant with height, and a real one grows.

Traits§

Forward
Flies a flight for a fit.

Functions§

bayesian
The Bayesian option (ADR-317, ADR-320): fit, then the posterior of its unknowns drawn around its answer by posterior::sample_in_two, each draw a flight flown.
fit
Fits forward to observed, each parameter held to stated. A log that says nothing, or a flight that won’t fly on what was stated, gives Fit::of_nothing.
observations
A log’s height and any horizontal track, on read’s pad, from read’s liftoff to its apogee; None where the reader withheld the apogee, the pad, or too few bins hold a sample to fit, so the log can say nothing.

Type Aliases§

Stated
What is stated of every parameter.