<a id="goodness-of-fit"></a>

# Goodness of Fit

Not every set of region sizes can be drawn exactly, so eunoia reports a few scalars that summarize how faithfully the fitted geometry reproduces the requested set relationships. These appear under *Goodness of fit* in the [App](/app/), and are returned on the layout for programmatic callers. 

<a id="metrics"></a>

## Metrics

- **stress:** a scale-invariant measure due to *Wilkinson (2012)*, popularized by `venneuler`. Lower is better.
- **diagError:** the largest absolute discrepancy between a fitted region's share of the total area and its requested share. Defined by *Micallef & Rodgers (2014)*; values below `0.01` generally indicate a faithful diagram.
- **regionError:** the same quantity as `diagError`, but reported per region rather than as the maximum across all of them.

<a id="when-a-diagram-can-t-be-drawn-exactly"></a>

<a id="when-a-diagram-cant-be-drawn-exactly"></a>

## When a Diagram Can't Be Drawn Exactly

Not every set of region areas can be represented faithfully with circles, or even with ellipses. A classic example: 

```
A=5, B=3, C=1, A&B=2, A&B&C=2
```

No two-dimensional Euler diagram with circles can satisfy these constraints exactly. In such cases `diagError` will be large, and the geometry eunoia returns is the best compromise the optimizer found. The metrics above are how you tell a faithful diagram apart from a forced one; always check them before trusting a layout. 

<a id="references"></a>

## References

- Wilkinson, L. (2012). Exact and approximate area-proportional circular Venn and Euler diagrams. *IEEE Transactions on Visualization and Computer Graphics*, 18(2), 321–331.
- Micallef, L., & Rodgers, P. (2014). eulerAPE: drawing area-proportional 3-Venn diagrams using ellipses. *PLOS ONE*, 9(7), e101717.
