Balancing FRR and FAR for Your Business
Every authentication system faces the same trade-off. Raise the threshold and you block more impostors, but you also lock out more legitimate users. Lower it and users are happy, but attackers slip through. The right balance depends on what a wrong decision costs your business.
In this article we simulate keystroke-dynamics authentication, train three candidate models, and choose a different operating threshold for each of three business scenarios.
1. Problem Setting
For a decision threshold $t$ on the authentication score $s$ (higher means more likely genuine), the two error rates are:
$$
\mathrm{FRR}(t) = \frac{\left|{ s_g < t }\right|}{N_g}, \qquad
\mathrm{FAR}(t) = \frac{\left|{ s_i \ge t }\right|}{N_i}
$$
Here $s_g$ are genuine scores and $s_i$ are impostor scores. The Equal Error Rate (EER) is the point where the two curves cross:
$$
t_{\mathrm{EER}} = \arg\min_t \left| \mathrm{FAR}(t) - \mathrm{FRR}(t) \right|
$$
The EER is a useful benchmark, but a business does not care about equal errors. It cares about expected cost per login attempt. If a fraction $\pi$ of attempts are impostor attempts, then:

The optimal threshold is:

We use $\pi = 0.01$ and three scenarios:
| Scenario | $C_{\mathrm{FAR}}$ | $C_{\mathrm{FRR}}$ |
|---|---|---|
| Online banking | 2000 | 5 |
| Corporate VPN | 300 | 10 |
| Smartphone unlock | 60 | 20 |
Thresholds are chosen on a validation set and evaluated on a separate test set, with impostor users split so that no impostor appears in more than one set.
2. Source Code
1 | import numpy as np |
3. Code Walkthrough
Synthetic data
Each person has a mean typing profile in a 12-dimensional space (think dwell times and flight times between keys). A single user’s samples scatter around their own mean with standard deviation SIGMA_WITHIN, while different people’s means are spread more widely with SIGMA_BETWEEN. The random matrix mix correlates the features, as real timing features are correlated.
The target user’s genuine samples come from the origin. Impostor samples come from many other users. Training, validation, and test sets use different impostor users, so the model never sees a test impostor during training or threshold selection.
Candidate models
We compare three classifiers, all mapped to a score in $[0,1]$. Quadratic Discriminant Analysis suits Gaussian-like behavior, the Random Forest is a flexible baseline, and the RBF SVM is a non-linear margin classifier. The SVM’s raw decision value is passed through a sigmoid so that all models share the same threshold axis.
Fast FAR and FRR computation
The far_frr function is the performance-critical part. A naive implementation would compare every score against every one of the 1001 thresholds, costing $O(N \cdot T)$. Instead we sort the scores once and use np.searchsorted, which gives the count of scores below each threshold in $O(T \log N)$:
$$
\mathrm{FRR}(t) = \frac{\operatorname{rank}_g(t)}{N_g}, \qquad
\mathrm{FAR}(t) = 1 - \frac{\operatorname{rank}_i(t)}{N_i}
$$
The entire script runs in a few seconds, so no further acceleration is needed.
Model selection and threshold optimization
Models are ranked by validation EER. Then, for each business scenario, the expected cost curve is computed on the validation set and its minimum gives the threshold $t^{*}$. We report FAR, FRR, and cost on the untouched test set. As a baseline, we also compute the cost if we had simply used the EER threshold everywhere.
Plots
The figure has two rows and three columns. Panels 5 and 6 are 3D. Panel 5 shows the log expected cost as a surface over the threshold and the cost ratio, with the optimal threshold path drawn in red. Panel 6 shows the full operating trajectory in (FAR, FRR, threshold) space, with each scenario’s optimum marked.
4. Execution Results
Graphs

Console Output
=== Model comparison (equal error rate) ===
Model EER threshold EER val (%) EER test (%)
Quadratic Discriminant 0.805 3.300 3.450
Random Forest 0.281 11.800 11.450
SVM (RBF) 0.497 5.425 5.725
Selected model: Quadratic Discriminant
=== Optimal operating point per business scenario (test data) ===
Scenario C_FAR C_FRR Opt. threshold FAR test (%) FRR test (%) Cost @EER thr. Cost @Opt thr. Cost reduction (%)
Online banking 2000.0 5.0 0.874 3.00 5.05 1.019 0.850 16.571
Corporate VPN 300.0 10.0 0.653 7.30 0.65 0.373 0.283 23.953
Smartphone unlock 60.0 20.0 0.224 15.05 0.05 0.502 0.100 80.048
5. Reading the Results
Model comparison
The Quadratic Discriminant model reached a test EER of about 3.5%, the RBF SVM about 5.7%, and the Random Forest about 11.9%. This makes sense for the data: the genuine class is a compact Gaussian cloud surrounded by impostors, a shape that a quadratic boundary captures almost perfectly. The Random Forest has to approximate that curved boundary with axis-aligned splits and pays for it in accuracy. Model choice matters, but as we see next, threshold choice matters just as much.
Panels 1 and 2: distributions and error curves
The score histogram shows two well-separated groups, genuine scores piled up near 1 and impostor scores near 0, with a thin overlap in between. The FAR curve falls and the FRR curve rises as the threshold increases, crossing at an EER of roughly 3.7% on the test set. That crossing is the point where the two errors are equal, which is rarely where a business wants to operate.
Panel 3: DET-style curves
On the log-log plot, a curve closer to the bottom-left corner is better. The Quadratic Discriminant curve dominates, followed by the SVM and then the Random Forest. The three colored dots show where each business scenario sits on the best curve, and they are spread far apart along it, which is the whole point of tuning.
Panel 4: expected cost
Each scenario has a different cost curve and therefore a different minimum. The cost-optimal thresholds were:
| Scenario | Optimal threshold | FAR (test) | FRR (test) | Cost at EER threshold | Cost at optimal threshold | Reduction |
|---|---|---|---|---|---|---|
| Online banking | 0.873 | 3.00% | 5.10% | 1.019 | 0.852 | 16.3% |
| Corporate VPN | 0.649 | 7.30% | 0.65% | 0.373 | 0.283 | 24.0% |
| Smartphone unlock | 0.222 | 15.05% | 0.05% | 0.502 | 0.100 | 80.0% |
Online banking pushes the threshold high, because a single successful fraud is far more expensive than asking a genuine user to retry. Smartphone unlock goes the other way: a low threshold keeps the genuine user’s rejection rate almost at zero, and the occasional false accept is cheap relative to constant friction. Corporate VPN sits in between.
Panel 5: 3D cost surface
The surface shows how the expected cost depends on both the threshold and the ratio $C_{\mathrm{FAR}} / C_{\mathrm{FRR}}$. The red ridge-line traces the cheapest threshold for each ratio. As the cost of accepting an impostor grows relative to the cost of rejecting a genuine user, the optimal threshold climbs steadily toward 1. The valley floor is also fairly flat for small ratios, meaning that when false rejects dominate the cost, the exact threshold matters little.
Panel 6: 3D operating trajectory
Sweeping the threshold from 0 to 1 traces a curve through (FAR, FRR, threshold) space. Low thresholds sit in the high-FAR corner and high thresholds in the high-FRR corner. The three scenario points sit at clearly different heights along the curve, which makes the trade-off visible at a glance: moving up the threshold axis buys lower FAR at the price of higher FRR.
6. Conclusion
Three takeaways from this experiment:
- The EER is a benchmark, not a target. Operating at the EER threshold in every scenario cost between 16% and 80% more than the cost-optimal threshold.
- Cost-aware thresholds are cheap to compute. With sorted scores and
np.searchsorted, evaluating every threshold takes milliseconds. - Model quality and threshold choice compound. A better model shifts the whole DET curve toward the origin, and a well-chosen threshold then picks the best point on that curve for your business.
In production, replace the assumed costs and the impostor rate $\pi$ with real figures from fraud losses, helpdesk tickets, and login statistics, and re-tune periodically as user behavior drifts.















