68
Canonical Grid model
Physics starter - Inference
Fit a synthetic ringdown envelope; inspect parameter identifiability, residuals and conditional local uncertainty.
- Scale
- Small
- Source
- physics-inference.grid
- Length
- 52 lines
- Collection
- Advanced language
- Level
- Intermediate
- Runtime
- Portable
- Version
- 1.0.0
MODEL "Physics starter - Inference"
DESCRIPTION "Fit a synthetic ringdown envelope; inspect parameter identifiability, residuals and conditional local uncertainty."
VERSION "1.0.0"
AUTHOR "Grid Team"
TAGS "physics", "starter", "inference"
# Fixed synthetic equal variance observations. Local intervals are conditional on this model.
Times = [0.0, 0.4, 0.8, 1.2000000000000002, 1.6, 2.0, 2.4000000000000004, 2.8000000000000003, 3.2, 3.6, 4.0, 4.4, 4.800000000000001, 5.2, 5.6000000000000005, 6.0]
BaseObserved = [2.718, 2.361395588497015, 2.0964593536393137, 1.821617049537642, 1.643022659622037, 1.4454632594785237, 1.2662763085726991, 1.1572777471284987, 1.0066994865575989, 0.920135066249426, 0.7994924098540163, 0.7419527535674448, 0.6779349400985248, 0.597064377334702, 0.5551460523026125, 0.49214107063245494]
input NoiseScale = 1
VALIDATE BETWEEN 0.5 AND 2 MESSAGE "Use a noise multiplier from 0.5 to 2; observations remain synthetic."
Observed = MAKEARRAY(1, 16, (row, col) => 2.5 * EXP(-0.35 * INDEX(Times, 1, col)) + 0.2 + NoiseScale * (INDEX(BaseObserved, 1, col) - (2.5 * EXP(-0.35 * INDEX(Times, 1, col)) + 0.2)))
output Fit = CURVE_FIT.REPORT((time,amplitude,rate,baseline) => amplitude*EXP(-rate*time)+baseline,Times,Observed,[2,0.5,0.1],1e-12,1000,{uncertainty:"local_iid",confidence:0.95})
output Parameters = Fit.parameters
output ResidualSumSquares = Fit.ssr
output Rank = Fit.jacobian.rank
# Scientific checks and interpretation
output FitData = MAKEARRAY(16, 3, (row, col) => col = 1 THEN INDEX(Times, 1, row)
ELSE col = 2 THEN INDEX(Observed, 1, row)
ELSE INDEX(Fit.parameters, 1, 1) * EXP(-INDEX(Fit.parameters, 1, 2) * INDEX(Times, 1, row)) + INDEX(Fit.parameters, 1, 3))
output Assumptions = "Fit a synthetic ringdown envelope; inspect parameter identifiability, residuals and conditional local uncertainty. Solver completion alone does not establish global accuracy or physical validity."
output ScenarioGuide = "Save a Baseline input scenario, change an admitted input, inspect numerical checks and the unsmoothed plot, then restore Baseline. Save and reopen a .gridoc archive. Plot selection also accepts the FitData numeric array; choose its X and Y columns in the chart dialog."
Charts_1!type = "charts"
Charts_1!config = <toml>
version = 1
kind = "charts"
title = "Inference"
[layout]
x_axis = "Time"
y_axis = "Signal"
[[charts]]
type = "line"
smooth = false
bind = "FitData"
x = "0"
y = "1"
label = "Synthetic observations"
color = "#2563eb"
[[charts]]
type = "line"
smooth = false
bind = "FitData"
x = "0"
y = "2"
label = "Fitted envelope"
color = "#d97706"
</toml>
END MODEL