I see fairly often that guides feature suboptimal defensive EV spreads.

The purpose of defensive EVs is often one of the following three goals, in order of how common they are:

1) Maximize defenses against a chosen type of attack.

2) Maximize defenses against a mixed 'barrage' of attack.

3) Maximize defense against an opponent that picks the most effective type.

In order to understand defensive EVs, let's first consider the attack damage formula. Effectively, this formula says the damage percentage from an attack is 100 * A * P * C * R/ (D * H), where A is the attacking puppet's attack stat, while D is your defense stat. P is the move's power, C is a certain constant, and R varies between 0.85 and 1 randomly. (Both puppets are assumed to be level 100). Since only 'D' and 'H' here is within our control we can observe a simple fact:

EHP = D * H * C

Where EHP is your `effective` health. The higher this number, the more attacks a puppet can withstand. Now EV's raise the 'H' and 'D' statistics by exactly one point per 4 EVs.

Goal <1>

When D > H, it is obvious raising 'H' by one point will provide you with more EHP than raising 'D' by one point, so it is best to spend your EVs in the lower of the two values. There is some 'optimal' amount of EVs to invest in either attack or hp before reaching the cutoff point. Let h be your HP stat, and d be your defense stat. The cutoff point is at d = h + 52.5.

Suppose d < h + 52.5. Then we need more defense. So first invest (h - d) * 8 + 420 EV's into defense, then split equally.

If h < d - 52.5, then we need more HP. First invest (d - h) * 8 - 420 EV's into HP, then split equally.

Let's do an example: We have a puppet with the following stats:

HP: 80

DEF: 140

And we want to maximize physical defense, having 240 EV's available for this in our build. In order to do so, notice how h < d - 52.5. (d - h) * 8 - 420 = 60, so first invest 60 EV's into HP, then split equally. Then you get the following EV spread:

HP: 150

DEF: 90

Because EV's are rounded in multiples of 4, we can optimize for rounding by using this instead:

HP: 152

DEF: 92

Now, suppose we have a +def nature. By using that spread, the actual value ends in a '9' before nature (339 HP, 339 def). So we can win an extra +1 defense point by investing 4 extra EV's into this, which is very much worth the investment. So the final EVs become:

HP: 148

DEF: 96

Remark:

For the more 'complicated' goals mathematically it can be very useful to convert base stats into actual real stats, as we can work with real stat points instead of having to work with base stats, which makes the formulas much more complicated, introducing a lot of extra terms. Convert a base stat into a real stat like this:

HP: H = h * 2 + 141

Others: X = x * 2 + 35

Goal <2>

In order to satisfy goal <2> we want to maximize the following, letting HP = H, Defense = D, Special Defense = S:

H / (1 / D + 1 / S)

Under this condition, we can express H = h0 + Eh, D = d0 + Ed, S = s0 + Es, where h0 = 8 * h + 564, and d0 = 8 * d + 144, similar for s0. The formula becomes:

(h0 + Eh)(d0 + Ed)(s0 + Es) / (d0 + Ed + s0 + Es).

This formula can be solved using the method of Lagrange Multipliers, but this is quite more complicated than strictly necessary. First, observe that if d = s or D=S, we have a simple case. At this point, we want to invest in HP as long as 2 * H < D = S, in other words, the turning point is now at:

d = h / 2 + 17.5

So, when:

d < h / 2 + 17.5

D < H / 2

Invest into defenses until this formula is no longer satisfied, then invest 2 EV's into HP for every 1 EV into defenses.

And, when:

d > h / 2 + 17.5

D > H / 2

Invest into health until this formula is no longer satisfied, then invest 2 EV's into HP for every 1 EV into defenses.

Now we turn to the more complicated case. What if D < S (the opposite case is a mirror, so we may assume that 'defense' is the lower of the two defenses).

Solving for H we get:

H = D*D / S + D

And for D:

D = 0.5 * (-S + sqrt(S^2 + 4 * H * S))

If H > D*D / S + D invest EV's into Defense

If H < D*D / S + D invest EV's into Health.

Note that S here is the special defense 'before' any nature benefits.

At this point, natures do matter. Because the sequence of application of EVs does 'not' matter we want the 'most' EHP (if we pick a defense nature) out of it as possible. We can do so by checking whether the 'low' or the 'high' defense stat is a better pick. This involves solving the formula (1 / (1/(ax) + 1/b)) / (1 / (1/a + 1/(bx))) > 1, for which the conclusion is that the 'high' stat is the better pick (not really a weird conclusion there). However, as for the valuation of the low stat and the distribution of EVs, it stays of course the case that nature should be ignored due to the way it works (as a multiplier) for optimal results, which results in an eventual stat spread of (given enough EVs to work out the kinks in the natural spread) 2:1.1:1, where the 1.1 is in the higher starting def. However, in most cases the natural deviations from the ideal spread are big enough that we can only approach it, and the way most effective to do so as a procedure is best illustrated with examples.

Let's do an example now for case <2>. Suppose we have a 'mon with the following stats:

300 EVs to invest in defenses.

HP: 150

DEF: 100

SDEF: 150

This yields the following 'base real stats':

H: 441

D: 235

S: 335

So we calculate our target HP for the given Defense and Special defense:

H = D^2 / S + D = 235^2/335 + 235 = 400

So we are basically overspent on HP and investing in 'def' is the more efficient choice. So apply the reverse formula:

D = 0.5 * (-S + sqrt(S^2 + 4 * H * S)) = 252

This means the first 68 EV's should be spent in 'Defense'. After this, we have the following stat spread:

H: 441

D: 252

S: 335

Now in order to maximize gains we have to divide EV's between defense and HP in a peculiar way, namely to follow the curve H = D^2 / S + D. At this point we have to solve for both H and D given the constraints. Our constraints are:

S = 335

D = 252 + 1/4x

H = 441 + 1/4v - 1/4x

Subject to:

H = D^2 / S + D

Where v is the total remainder EV we want to invest, and x is the amount of defense ev's. The amount of HP ev's then obviously is x - v. Note that S > D + 63, so we're never going to reach the point where investing in special defense is worthwhile. The solution for the eq. is:

x = 2 sqrt(335) sqrt(v + 4112) - 2348) = 64.666

Rounding down to a multiple of 4 we get 64 extra defense EV's, and 232 - 64 = 168 HP EV's. 64 + 68 = 132, so our final spread is:

HP: 168

DEF: 132

SDEF: 0

Nature: +SDEF

This spread will give you the most effective health against a 50/50 mix of damage given the provided stats.

Remark:

If defense and special defense are 'close together' you will need to see if you have enough EV's that defense = special defense when following the quadratic formula obtained as a solution to the problem. At this point HP will be 2* defense as well (due to the way the formula was derived). If this is true, then we can simply forego any further calculations, and start from that point using the 'simple' solution (for def = sdef).

Remark #2:

It is possible to solve the system directly. In this case, we have:

Maximize:

H*D*S / (D*S)

Under the constraints:

D = D0 + 1/4d

S = S0 + 1/4s

H = H0 + 1/4h

d+s+h = v

d >= 0

s >= 0

h >= 0

0 <= v <= 512

But since we've covered all possible sensible cases, the only reason to bother with lagrange techniques here is as a math curiosity.

Edit: Changed notation. Now using capitals for all final stats and small letters for ev's and base stats.

Case <3>

An observant reader will notice a similarity between this and case <1>. Simply pretend the higher defense stat does not exist and treat it as case <1>. Are the defense stats close enough that investing your allotted EV's will balance them out? Then split the remainder as per the simple case <2>. There is one exception which we will come to later.

Let's do a simple example for this special scenario:

HP: 130

DEF: 80

SDEF: 70

EV to spend: 500

This yields the following stats:

HP: 401

DEF: 195

SDEF: 175

First, we equalize the defenses. so spend 80 to SDEF. Then we need an additional 6 points in both defenses, and 1 in HP to get the 2:1:1 distribution, spending an additional 24 in both defenses, and 4 in HP. This yields:

4 HP

24 DEF

104 SDEF

Total spent: 132.

There are now 368 points left. 368 / 4 = 92, so spend another:

184 in HP

92 in DEF

92 in SDEF

For a total of:

188 HP

116 DEF

196 SDEF

Which means stats of:

448 HP

224 DEF

224 SDEF

Now comes the exception, which is 'natures'. This is rather a bit annoying as you see, we can't simply ignore nature here. If we use a boosting nature, then it makes the most sense to boost the lowest defense if they are far apart (for it is impossible to equate the defenses using EVs). However, once it becomes possible to equate the defenses with EV's there's a certain 'tipping point' where you will want the higher def to be chosen for the nature, and then a second tipping point where it won't matter which one you choose. When there's a boosting nature, equalize the defenses **after** applying the nature.

In order to get 11 defense and 11 special defense, we need to spend 21 points. In other words, we get a 22/21 deal here (22 points for 21). So the ideal distribution 'WITH' a nature for balanced defenses is 21:11:11 if we're behind the second 'tipping point'. Before the first 'tipping point' the ideal distribution is 2:1.1 (the higher def stat doesn't matter).

Finding the first 'tipping point' is quite simple: As soon as the lower defense stat exceeds the higher with both nature and EV's we are in trouble. The same with the second 'tipping point': if we can't equate the lower nature to the higher with a nature applied using EV's, we are in trouble.

Tipping point 1:

1.1 * D + Ed > S

Tipping point 2:

D + Ed' < S * 1.1

Where Ed is obtained using part '1' technique and Ed' is obtained using part '2' technique

In between (when both equations are true), the answer is quite complex.