> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.conductorquantum.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.conductorquantum.com/_mcp/server.

# stanza.analysis.criterion

Fit quality assessment criteria for curve fitting.

This module provides functions to evaluate the quality of nonlinear curve fits
using statistically robust metrics like R² and NRMSE.

## Module Contents

### Functions

| Name | Description |
|------|-------------|
| [`fit_quality_criterion`](#stanzaanalysiscriterionfit_quality_criterion) | Evaluate fit quality using R² and NRMSE metrics. |

### API

```python
stanza.analysis.criterion.fit_quality_criterion(
    x_data: numpy.ndarray,
    y_data: numpy.ndarray,
    y_pred: numpy.ndarray,
    r_squared_threshold: float = 0.7,
    nrmse_threshold: float = 0.2
) -> bool
```

Evaluate fit quality using R² and NRMSE metrics.

This criterion evaluates both how well the model explains variance (R²) and how
small the errors are relative to the data range (NRMSE).

**Parameters:**

<ParamField path="x_data" type="numpy.ndarray">
  Input x values (used for context, not in calculation)
</ParamField>

<ParamField path="y_data" type="numpy.ndarray">
  Observed y values
</ParamField>

<ParamField path="y_pred" type="numpy.ndarray">
  Predicted y values from the fitted model
</ParamField>

<ParamField path="r_squared_threshold" type="float" default="0.7">
  Minimum R² value for acceptable fit. Default 0.7
</ParamField>

<ParamField path="nrmse_threshold" type="float" default="0.2">
  Maximum NRMSE (normalized RMSE) for acceptable fit.
</ParamField>

**Returns:**

True if fit quality is GOOD (passes both criteria), False if POOR
Notes:
- R² (coefficient of determination) measures the proportion of variance
in the data explained by the model. Range: [0, 1], higher is better.
- NRMSE (normalized root mean square error) measures prediction error
relative to data range. Range: [0, ∞), lower is better.
- These metrics are appropriate for nonlinear models, unlike reduced
chi-squared which requires known degrees of freedom.