Curve Family Fitting
GX-TXT DEV112 P011-bis
Fit a model to a family of curves and compare parameters, residuals and fit output.
Prepare the triode curves in the Generator
Create a Session Standalone with Generate Session → Triode Curve Fitting and SPICE Validation. Enable Curve Family Fitting in Configuration → Modules. In Analysis → Curve Family Fitting set Input dataset on triode.family.source and Mathematical model on triode.koren_v1. In Parameters… read the order, names and initial values of the model. In this exercise the parameters are mu, Kp, Kvb, Kg1, Ex. Check in Input variable bindings the assignments X=X_V, family=Vg_V and Y=Y_mA. X and family are voltages, Y is the measured current in mA.



Configure scope, constraints, solver and orientation
- Control
- Operation mode
- Use and effect
fitoptimizes the free coordinates by comparing the predictions with Y.evaluatecomputes predictions and residuals for frozen parameters, without minimization.
- Control
- Parameter scopes
- Use and effect
- Use
sharedto share the parameters across all curves. In a list in model order,localassigns one value per family group andfixedlocks the parameter to the initial vector. Separate the entries with semicolons. A model suitable for the fit can be incompatible with the SPICE adapter if the parameters are local.
- Control
- Initial values in expanded parameter order, Lower bounds in expanded parameter order and Upper bounds in expanded parameter order
- Use and effect
- Leave empty for the model values. If you fill them in, use the expanded parameter order: one position per shared or fixed coordinate and one block for the local coordinates of the families. Check that each initial value respects the limits. A mistake in the order changes the meaning of the numbers.
- Control
- Additional fixed slots in expanded order
- Use and effect
- 0/1 mask in the same expanded order. Use 1 on the positions to lock in addition to the scopes already fixed. Check in the parameters CSV which coordinates were applied.
- Control
- Frozen parameter source, Frozen values, Parameter CSV
- Use and effect
- In
evaluatechoosemanualand enter all the frozen values in the required order, or choosecsvand use Browse… for the CSV produced by the fit. Keep the same model and the same shared/local structure to interpret the values correctly.
- Control
- Presentation orientation
- Use and effect
x_by_familyuses the model X value on the horizontal axis and draws one series per family.family_by_xuses the family variable on the horizontal axis and organizes the curves by X. The orientation of the figure leaves the physical roles of the bindings unchanged.
- Control
- Solver, Maximum iterations, Tolerance
- Use and effect
autouses a solver supported in that installation.lsqnonlinrequires the Octave packageoptim. The explicit choice gave the message solver lsqnonlin requires the Octave optim package in the installation used for this guide. Continue withautoorfminsearch.fminsearchuses a derivative-free search. Default limit 2000 iterations and tolerance 10⁻⁸. Availability and stopping information depend on the solver. Reset resets the tolerance field to its initial value.
- Control
- Minimum absolute measured Y for relative error
- Use and effect
- Initial value 10⁻¹² in the unit of Y. The threshold excludes small denominators from the relative metrics. Also keep absolute residuals to read the behavior near zero. Reset restores the initial value.
Run the fit and read results and figures
- For the first exercise use
fit, shared scope, the model’s numerical settings andx_by_family. In Graphs offered by module press Enable all, or enable the individual checkboxes. Disable all turns off image generation. Configure… edits the single plot and Module graphics… opens the common settings. - Tick Run / recalculate now, check the source in Run and start Run enabled analyses. In Results open the predictions table, the parameters, the metrics and the identity. The report
fit_summary.txtcontains the effective interval, the row handling, the solver used and the covariance state. - Compare
fit_parameters.csvwith the model and keepfit_domain.csvfor the chapter SPICE Build and Validation. If you want to keep a copy of the fit before evaluating another configuration, copy the files you intend to reuse out of the module working folder.
The lab used 439 observations, five free parameters and fminsearch in automatic mode. RMSE is 1.08838 mA, MAE 0.86298 mA and R² 0.996468. The report declares the parameter covariance unavailable because a solver stopping outcome recognized for inference is missing. The agreement between measurements and fit describes the training curves and does not prove the stability of the parameters or the accuracy outside the domain.
In Plots select the measured/fit overlay to check the shape of the curves. Fit residuals by family shows absolute residuals by group. Measured vs fitted parity shows the deviation from the diagonal. Relative residuals by family uses the threshold on the denominators. Fit error metric by family compares groups that are otherwise hard to tell apart in the overlay. Open the image with Graph → Open PNG 1:1.
To try the constraints select fminsearch explicitly. Use shared;fixed;fixed;shared;shared, initial values 10.82;77.04;663.25;485.54;1.304, lower limits 1;1;0;1;.5 and upper limits 100;1000;2000;100000;3. The mask 0;0;0;0;1 also locks Ex. With at most 125 iterations, tolerance 10⁻⁵ and relative threshold 0.01 mA, the report gives 437 residual degrees of freedom over 439 observations. Free parameters remaining: mu and Kg1.
To check the local parameters, switch to evaluate with manual. Set the scopes fixed;fixed;fixed;local;fixed and clear the overrides of initial values, limits and mask. The frozen values start with 10.82;77.04;663.25, continue with eleven integer values from 480 to 490 for Kg1 and end with 1.304 for Ex. The eleven families are ordered by grid voltage from −50 to 0 V in 5 V steps. Check the names Kg1@family=-50 to Kg1@family=0 in the CSV. The report of this exercise gives RMSE 1.12471 mA on the 439 observations. The module allows up to 64 families for a local parameter and 128 positions in total. The CSV with locals keeps the map needed to read it back.
To repeat the comparison without rerunning the optimization save a copy of fit_parameters.csv, switch to evaluate, choose csv and use the absolute path to the file. Turn off the plots. In the report look for Parameter source: csv and Parameters optimized: no. The confirmed comparison reproduced RMSE 1.08838 mA on 439 points. For manual use the same five values in the sequence given by the editor. The computation with orientation family_by_x confirmed the same metric and the report gives Vg_V as the horizontal coordinate.

In Configure… sets title and labels. X/Y limits left empty follow the automatic scale. For all figures, adjust the available fields to the domain of the observations. The specific options depend on the figure.
- The overlay offers Show measured points and Show fitted curves, marker size, line width and legend
family_only,measured_and_fittedornone. - The absolute and relative residual plots offer marker size and, respectively, Show zero residual line and Show zero relative-error line. The zero line helps spot bias relative to the family.
- The parity plot offers Distinguish points by family, marker and Use the same numeric range on X and Y. Use equal ranges to read the distance from the diagonal consistently on both axes.
- For Fit error metric by family choose Error metric
rmse,maeormax_abs_error. The first penalizes large residuals more, the second gives the mean of the magnitudes and the third shows the case farthest from the prediction.
Module graphics… lets you override fonts, resolution, grid and legend of the module. Leave inherit where you want to keep the global value.


