signal_stats
Compute scalar summaries like average, RMS, and peak values for a signal from an LTspice simulation. Supports transient, DC, AC, and noise analyses with time windowing for accurate results.
Instructions
Scalar summary of one signal in a .raw result. Use this when you need a single number per metric (average, RMS, peak, etc.) — not a waveform or a trend.
Transient: time-weighted mean, RMS, std, abs-mean, and min/max/pk-pk using trapezoidal integration (RMS = sqrt(∫ y² dt / T)). This is correct on LTspice's adaptive timestep — simple np.mean(y) would overweight densely sampled regions. Optionally restrict to [t_start, t_end]; passing no window averages the whole waveform including any startup transient, which is usually wrong for RMS/mean.
DC: returns min/max/pk-pk and the simple/abs mean over the swept axis, plus sweep_start_used/sweep_end_used/sweep_span. RMS and std are deliberately omitted — they're meaningless on a non-time axis. Use t_start/t_end to restrict the sweep range.
AC: returns magnitude (dB) min/max/mean and phase (deg) min/max. t_start/t_end are rejected for AC — use query_value for a point at a specific frequency.
Noise: returns min/max/pk-pk and the simple/abs mean of the noise spectral density over the frequency axis, plus freq_start_used/freq_end_used. RMS/std/duration are omitted; t_start/t_end are rejected — pass them via query_value at specific frequencies instead.
Related tools: for rise/fall times use edge_metrics; for overshoot/settling use pulse_response; for period/duty use periodic_metrics; to aggregate .MEAS values across a sweep use measurement_stats.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| raw_file | Yes | Path to .raw result file from simulation | |
| signal | Yes | Signal/trace name (e.g., 'V(out)', 'I(R1)'). | |
| step | No | Step index for .step directives | |
| t_start | No | Window start in SPICE notation (e.g. '1m', '100u'). Transient only. Strongly recommended when computing RMS or average — the startup transient otherwise biases the result. Rejected for AC analysis (time-windowing a frequency sweep is an error). | |
| t_end | No | Window end in SPICE notation. Transient only; rejected for AC. | |
| format | No | Response format: 'json' for structured data, 'text' for human-readable |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| signal | No | ||
| analysis_type | No | ||
| min | No | ||
| max | No | ||
| mean | No | ||
| rms | No | ||
| std | No | ||
| abs_mean | No | ||
| peak_to_peak | No | ||
| point_count | No | ||
| t_start_used | No | ||
| t_end_used | No | ||
| duration | No | ||
| sweep_start_used | No | ||
| sweep_end_used | No | ||
| sweep_span | No | ||
| freq_start_used | No | ||
| freq_end_used | No | ||
| min_db | No | ||
| max_db | No | ||
| mean_db | No | ||
| min_phase | No | ||
| max_phase | No |