How Should You Split Your Budget Between Email Filters and User Training?
Every security team eventually faces the same budget question. Do we buy a better email filter, or do we run more awareness training and phishing simulations? Technical controls scale silently but never reach 100% detection. Human controls are adaptive but suffer from diminishing returns and training fatigue. This article builds a small quantitative model of that trade-off and solves it as a constrained nonlinear optimization problem in Python.
1. The Problem
A company wants to spend a fixed annual security budget on two kinds of controls.
- Technical control: an email filtering stack (gateway, sandboxing, URL rewriting). Spending $x$ (in thousand USD per year) reduces the fraction of phishing emails that slip through.
- Human control: security awareness training (sessions per year $f$) and simulated phishing campaigns (campaigns per year $s$). Both reduce the probability that an employee clicks a malicious link that reaches the inbox.
Example scenario
| Parameter | Symbol | Value |
|---|---|---|
| Annual budget | $B$ | 200 k USD |
| Phishing emails targeted at the organization per year | $E$ | 3000 |
| Average loss per successful compromise | $L$ | 4 k USD |
| Cost per training session | $c_T$ | 8 k USD |
| Cost per simulation campaign | $c_S$ | 5 k USD |
| Maximum training sessions per year | $f_{\max}$ | 12 |
| Maximum simulation campaigns per year | $s_{\max}$ | 24 |
2. Mathematical Model
Filter miss rate. Filter performance saturates: there is always a residual miss rate $m_\infty$ that no budget can remove.
$$
m(x) = m_\infty + (m_0 - m_\infty),e^{-x/a}
$$
Click probability. Training and simulation reinforce each other through the interaction term $\gamma f s$. Too many touches cause fatigue, which is modeled by the quadratic penalty with coefficient $\kappa$.
$$
c(f,s) = c_\infty + (c_0 - c_\infty)\exp!\big[-(\alpha f + \beta s + \gamma f s)\big] + \kappa,(f+s)^2
$$
Expected annual loss. Compromises require both a filter miss and a click:
$$
\mathcal{L}(x,f,s) = E,L;m(x);c(f,s)
$$
Optimization problem.
$$
\min_{x,f,s}\ \mathcal{L}(x,f,s)
\quad \text{s.t.} \quad
x + c_T f + c_S s \le B,\quad
x \ge 0,\ \ 0 \le f \le f_{\max},\ \ 0 \le s \le s_{\max}
$$
Optimality condition. Because $\log\mathcal{L} = \log(EL) + \log m(x) + \log c(f,s)$, the technical and human layers contribute multiplicatively. At an interior optimum the marginal loss reduction per extra dollar must be equal across all three instruments, with $\lambda$ the shadow price of the budget:
$$
-\frac{\partial \mathcal{L}}{\partial x}
= -\frac{1}{c_T}\frac{\partial \mathcal{L}}{\partial f}
= -\frac{1}{c_S}\frac{\partial \mathcal{L}}{\partial s}
= \lambda
$$
Any variable sitting at a bound (for example $f = f_{\max}$) has a marginal value that differs from $\lambda$.
3. Solution Strategy
- Solve the problem with SLSQP from many random feasible starting points (multi-start) to avoid poor local solutions.
- Cross-check the answer with a fully vectorized brute-force grid over the technical share $\theta = x/B$ and the training fraction $\phi$ of the human budget.
- Compare the optimum against five naive strategies.
- Re-solve the problem for a range of budgets to see how the optimal mix shifts.
All grid evaluations use NumPy broadcasting with no Python loops, so the whole script runs in a few seconds.
4. Source Code
1 | import time |
5. Code Walkthrough
Parameters and model functions. The constants at the top define the scenario from Section 1 plus the shape parameters of the two response curves. miss_rate, click_rate, and expected_loss implement the equations of Section 2 directly. They are written with NumPy operations only, so the same function evaluates a single point, a whole grid, or an array of budgets without modification. This is the main speed-up: the 81 × 81 allocation grid and the 61 × 61 surface for the 3D plots are each evaluated in a single vectorized call.
solve: multi-start SLSQP. The objective is non-convex because of the interaction term $\gamma f s$ and the fatigue penalty, so a single starting point could end in a local minimum. The function draws random Dirichlet weights, converts them into a feasible starting allocation (technical spend, sessions, campaigns), clips it into the bounds, and runs SLSQP with the budget as an inequality constraint. Each result is clipped back into the bounds, rejected if it overspends, and the best objective value across all starts wins. A fixed random seed makes the run reproducible. If every start failed, a safe fallback allocation is returned, so the script cannot crash on a bad solve.
Optimal solution and marginal values. After solving, the script prints the allocation, the resulting filter miss rate and click rate, and the expected loss against the no-investment baseline. marginal_gains uses central finite differences to compute the loss reduction per additional thousand dollars on each instrument. This verifies the optimality condition: variables strictly inside their bounds should show nearly identical marginal values, while a variable pinned at a bound can differ.
Grid cross-check. alloc_from_shares reparametrizes the problem with two intuitive numbers: the technical share $\theta$ and the fraction $\phi$ of the human budget given to training. The remainder of the human budget goes to simulations, and the caps $f_{\max}$ and $s_{\max}$ are applied with np.minimum. Evaluating the loss on the full $(\theta,\phi)$ grid gives an independent brute-force estimate of the optimum. The printed difference between solver and grid losses confirms that the solver is at least as good as the best grid point.
Strategy comparison. The optimum is compared against a no-investment baseline, spending everything on filters, spending everything on humans (solved with the technical spend pinned to practically zero), an even split, and an 80/20 technical-heavy split. These are the plans a team might choose by intuition or habit, so the gap to the optimized plan is the value of doing the analysis.
Budget sensitivity. The solver is re-run for budgets from 50 to 400 k USD. This shows how both the achievable loss and the optimal technical share of spending move as the budget changes, which is useful for budget negotiations.
Visualization. All six panels share one figure with a dark theme. Panel (a) is a 3D surface of $\log_{10}\mathcal{L}$ over the allocation shares with the optimum marked. Panel (b) is a 3D triangulated surface over training sessions and simulation campaigns, where the remaining budget automatically goes to the filter. Only the feasible, convex region is triangulated, which avoids gaps and rendering errors. Panel (c) is the contour view of panel (a), with the solver optimum (star) and the grid optimum (circle). Panel (d) is the loss profile along the technical share. Panel (e) is a stacked bar chart of how each strategy spends the budget, with its loss written above each bar. Panel (f) is the budget sensitivity curve with a twin axis for the technical share.
6. Execution Results
==========================================================================
PHISHING DEFENSE: BUDGET ALLOCATION OPTIMIZATION
==========================================================================
Budget B = 200 k USD | emails E = 3000 | loss per compromise L = 4.0 k USD
--------------------------------------------------------------------------
OPTIMAL ALLOCATION (SLSQP, multi-start)
Email filter spend x : 147.32 k USD ( 73.7% of budget)
Training sessions f : 4.786 per year -> 38.29 k USD
Simulation campaigns s : 2.877 per year -> 14.39 k USD
Total spend : 200.00 k USD
Filter miss rate m(x) : 3.545 %
Employee click rate c(f,s) : 5.457 %
Expected annual loss : 23.21 k USD
Loss with no investment : 720.00 k USD
--------------------------------------------------------------------------
MARGINAL LOSS REDUCTION PER EXTRA 1 k USD (equal for interior variables)
Email filter : 0.1686
Training sessions : 0.1686
Simulation campaigns : 0.1686
--------------------------------------------------------------------------
GRID CROSS-CHECK (81 x 81 allocations, vectorized)
Best grid loss : 23.21 k USD (theta = 0.738, phi = 0.725)
Solver loss : 23.21 k USD
Solver minus grid : -0.0004 k USD (<= 0 means solver is at least as good)
--------------------------------------------------------------------------
STRATEGY COMPARISON
Strategy Tech Train Sim Loss Reduction
No investment 0.0 0.0 0.0 720.00 0.0%
Tech only 200.0 0.0 0.0 95.12 86.8%
Human only 0.0 54.7 9.2 126.34 82.5%
Even split 100.0 50.0 50.0 53.84 92.5%
Tech-heavy 80/20 160.0 20.0 20.0 25.56 96.5%
Optimized 147.3 38.3 14.4 23.21 96.8%
--------------------------------------------------------------------------
BUDGET SENSITIVITY
Budget Tech share % Training f Simulation s Loss
50 9.4 3.70 3.15 132.31
75 38.7 3.78 3.14 92.04
100 53.2 3.90 3.12 65.44
125 61.6 4.06 3.10 47.84
150 67.1 4.26 3.05 36.17
175 70.9 4.51 2.98 28.40
200 73.7 4.79 2.88 23.21
225 75.8 5.09 2.75 19.74
250 77.5 5.40 2.61 17.40
275 78.9 5.70 2.46 15.83
300 80.2 5.97 2.32 14.77
325 81.4 6.20 2.20 14.06
350 82.4 6.38 2.10 13.58
375 83.4 6.51 2.02 13.26
400 84.3 6.61 1.96 13.05
--------------------------------------------------------------------------
Total runtime: 6.16 s

7. Reading the Graphs
(a) 3D loss surface over allocation shares. The horizontal axes are the share of the budget given to the email filter and the fraction of the remaining human budget given to training rather than simulation. The vertical axis is $\log_{10}$ of the expected annual loss, so each unit of height is a tenfold change. The surface is high where the technical share is near zero, because the filter then misses a fifth of all phishing mail, and it is also raised on the all-technical edge, where the human layer is missing completely. The valley between them is where both layers work together, and the red marker sits at the bottom of that valley.
(b) 3D loss over the human program. Here the axes are the number of training sessions and simulation campaigns per year, and every point implicitly gives whatever budget is left over to the filter. This panel shows two effects. Spending more on the human program lowers the click rate with diminishing returns, because of the exponential learning term. It also takes money away from the filter, and at high intensity the fatigue penalty pushes the click rate back up. The surface therefore has a basin rather than a slope running to the corner, and the cyan marker shows where the optimum lies in it.
(c) Contour map. The same surface from above. The closed contours around the optimum show how flat or steep the neighborhood is. A long, narrow valley means that several nearby allocations are almost equally good, so a team can shift a little between training and simulation without losing much protection. The star (solver) and the circle (brute-force grid) should land on top of each other.
(d) Loss profile along the technical share. For every technical share, the solid line uses the best possible training fraction, while the dashed line fixes it at 50%. The curve is U-shaped on a log scale: spending nothing on filters and spending everything on filters are both clearly worse than a balanced mix. The gap between the solid and dashed lines shows how much is gained by choosing the training/simulation split deliberately instead of defaulting to half and half.
(e) Strategy comparison. The stacked bars show how each plan divides the budget among filter, training, and simulation, with the expected loss above each bar. The no-investment bar sets the baseline. The tech-only bar shows the limit of a purely technical approach, since the filter can never remove the residual miss rate, and the human-only bar shows the limit of relying on people alone. The optimized bar sits below every intuitive alternative.
(f) Budget sensitivity. The red line is the best achievable loss at each budget, and the blue dashed line is the share of spending that goes to the filter. The red curve falls as the budget grows, with diminishing returns once both layers are strong. The blue curve shows whether the optimal mix shifts toward technology or toward people as the budget gets larger, which is the practical answer to the question “if we get more money next year, where should it go?”
8. Conclusion
Phishing defense is a multiplicative problem. A compromise needs a filter miss and a human click, so reducing either factor shrinks the expected loss proportionally. Because both layers show diminishing returns, the best plan is almost never a single-layer plan. The optimum equalizes the marginal loss reduction per dollar across filter spending, training sessions, and simulation campaigns, subject to the practical caps on program intensity. A multi-start SLSQP solver finds that point quickly, and a vectorized grid confirms it independently.
The same framework extends naturally to richer settings, such as role-based risk weights for high-value targets, adaptive attackers whose success rate rises when filters improve, or time-varying budgets across quarters. All of these can be added by modifying the model functions while the solver and plotting code stay unchanged.











