# Calculating EVs needed to raise a stat in Pokémon

As a result of working on upgrades for this Pokémon Effort Value Calculator, math has been a pretty big part of my life for the past few months, as I’ve been rearranging the games’ formulas for stat and damage calculation to make my own that fit my needs.

One such formula was the EVs needed one, which gives you the amount of EVs you need to invest to raise a stat by n points. Everyone knows that at Level 100, you get 1 stat point for every 4 EV points you invest; but what happens when you’re not at Level 100, or when you factor in stat modifiers like Nature, or item and ability boosts?

## The stat formula

A good starting point for this would be the stat formulas below — they determine a Pokémon’s stat at any given time. The formula for determining the HP stat is slightly different from the other stats.

$\mathrm{Stat}=⌊\left(⌊\frac{\mathrm{\left(2 × Base + IV +⌊\frac{\mathrm{EV}}{4}⌋\right) × Level}}{\mathrm{100}}⌋+5\right)×\mathrm{Nature}⌋$ $\mathrm{HP}=⌊\frac{\mathrm{\left(2 × Base + IV +⌊\frac{\mathrm{EV}}{4}⌋\right) × Level}}{\mathrm{100}}⌋+\mathrm{Level}+\mathrm{10}$

As an aside, it’s interesting to note that the HP stat formula can be simplified into this:

$\mathrm{HP}=⌊\frac{\mathrm{\left(2 × Base + IV +⌊\frac{\mathrm{EV}}{4}⌋\mathrm{+ 100}\right) × Level}}{\mathrm{100}}⌋\overline{)+\mathrm{Level}}+\mathrm{10}$

This reorganisation makes the formula harder to read, but can actually allow your code to be more concise, because this makes it possible to combine both stat formulas:

$\mathrm{Stat}=⌊\left(⌊\frac{\mathrm{\left(2 × Base + IV +⌊\frac{\mathrm{EV}}{4}⌋\mathrm{+ A}\right) × Level}}{\mathrm{100}}⌋\mathrm{+ B}\right)×\mathrm{Nature}⌋$ $\mathit{where A = 100, B = 10 for HP stat;}$ $\mathit{and A = 0, B = 5 for all other stats}$

## Pulling out the EV portion

The math that we were doing above actually have nothing to do with calculating needed EVs to raise a stat — it was just some interesting trivia. Let’s get to what you came here for.

First, let’s reorganise the fractional part of the stat formulas, so it becomes clear how the Base, IVs and EVs affect the stat:

$\frac{\mathrm{\left(2 × Base + IV +⌊\frac{\mathrm{EV}}{4}⌋\right) × Level}}{\mathrm{100}}=\mathrm{\left(2 × Base + IV +⌊\frac{\mathrm{EV}}{4}⌋\right) ×}\frac{\mathrm{Level}}{\mathrm{100}}$ $=\left(2×\mathrm{Base}×\frac{\mathrm{Level}}{\mathrm{100}}\right)+\left(\mathrm{IV}×\frac{\mathrm{Level}}{\mathrm{100}}\right)+\left(⌊\frac{\mathrm{EV}}{4}⌋×\frac{\mathrm{Level}}{\mathrm{100}}\right)$

Since we are most concerned about the EVs, let’s examine that portion first and add in the rest of the formula as we go along:

$Stat=⌊\frac{\mathrm{EV}}{4}⌋×\frac{\mathrm{Level}}{\mathrm{100}}$

We have to reorganise the formula so that EV alone ends up on one side.

$Stat÷\frac{\mathrm{Level}}{\mathrm{100}}=⌊\frac{\mathrm{EV}}{4}⌋$ $Stat×\frac{\mathrm{100}}{\mathrm{Level}}=⌊\frac{\mathrm{EV}}{4}⌋$

We need to break the floor operation to isolate EV on the right-hand side, which is tricky. Let’s ignore the floor operation for a moment:

$\mathrm{Stat}×\frac{\mathrm{100}}{\mathrm{Level}}×4=\mathrm{EV}$

The floor operation basically makes it so that any remainder of the EV value after being divided by 4 is discarded. This means that, to move the floor operation to the other side, we have to round the result up to the nearest multiple of 4:

$⌈\left(\mathrm{Stat}×\frac{\mathrm{100}}{\mathrm{Level}}×4\right)÷4⌉×4=\mathrm{EV}$

Cleaning up our formula and making it more presentable:

$\mathrm{EVs needed}=⌈\left(\frac{\mathrm{Stat × 400}}{\mathrm{Level}}\right)÷4⌉×4$

## Factoring in IV contributions

If you’re a competitive Pokémon player, you might be aware of this little quirk when it comes to EV-ing Level 50 Pokémon (all Pokémon have their Levels set to 50 in a competitive match). If a stat has 31 IVs, it takes 4 EVs to raise the stat by 1 point, then 8 EVs for every subusequent point.

IV stands for Individual Values. You can find out more about what they are in this Bulbapedia article.

This quirk exists because IVs affect how many EVs you need to raise a stat, as we see when we reorganise the stat formula above.

$\mathrm{IV stat contribution}=\mathrm{IV}×\frac{\mathrm{Level}}{\mathrm{100}}$

At Level 50, with 31 IVs, you will get the following stat contribution:

$\mathrm{IV stat contribution}=\mathrm{31}×\frac{\mathrm{50}}{\mathrm{100}}=\mathrm{15.5}$

If you refer to the stat formula again, you’ll see that the stat total is not rounded down until the base stat, IVs and EVs are totalled. That means that the decimal portion of the IV reduces the amount of EVs you’ll normally need to raise the stat.

$\mathrm{IV and EV stat contribution}=\frac{\mathrm{\left( IV +⌊\frac{\mathrm{EV}}{4}⌋\right) × Level}}{\mathrm{100}}$

Let’s rewrite this so that we can see their stat contributions more clearly:

$\mathrm{IV and EV stat contribution}=\mathrm{\left( IV +⌊\frac{\mathrm{EV}}{4}⌋\right)}×\frac{\mathrm{Level}}{\mathrm{100}}$

At Level 50, with 31 IVs and (for example) 12 EVs invested, we will get the following:

$\mathrm{\left( 31 +⌊\frac{\mathrm{12}}{4}⌋\right)}×\frac{\mathrm{50}}{\mathrm{100}}=\mathrm{15.5}+\mathrm{1.5}$

Essentially, 12 EVs give us 1.5 points of stats, which total up with the stats from 31 IVs (15.5) to give us 17 points of stats. If we don’t fill up the .5 stat from the 31 IVs with EVs, it will be rounded down and wasted. This is why the calculator often recommends a spread of 244 HP / 4 Def / 4 SpD instead of 252 HP — you are essentially getting your first stat point at half the EV cost.

How do we factor this into our EVs needed formula? Remember that we only care about the fractional part of the IV contribution (i.e. the part after the decimal point).

$\mathrm{EVs needed}=⌈\left(\frac{\mathrm{\left( Stat – \left\{ IV ×\frac{\mathrm{Level}}{\mathrm{100}}\right\} \right) × 400}}{\mathrm{Level}}\right)÷4⌉×4$

Note: { and } in the formula mean we only take the fractional part. For e.g. { 4.5 } = 0.5.

## Factoring in base stat contribution

Your Pokémon species’ base stat actually affects your EV cost too, similar to how IVs do. It’s just that at Level 50, the formula always works out in such a way that base stats always end up without any fractional part.

$\mathrm{Base stat contribution}=2×\mathrm{Base}×\frac{\mathrm{Level}}{\mathrm{100}}$ $\mathrm{Base stat contribution \left(LV50\right)}=2×\mathrm{Base}×\frac{\mathrm{50}}{\mathrm{100}}=\mathrm{Base}$

At Levels outside of 50 and 100, however, the base stat contribution can create a fractional part. For example, at Level 32 with a base stat of 70:

$\mathrm{Base stat contribution \left(LV32\right)}=2×\mathrm{70}×\frac{\mathrm{32}}{\mathrm{100}}=\mathrm{44.8}$

Which means we have to factor this into our formula too.

$\mathrm{EVs needed}=⌈\left(\frac{\left( Stat – \left\{ 2 × Base ×\frac{\mathrm{Level}}{\mathrm{100}}+ IV ×\frac{\mathrm{Level}}{\mathrm{100}}\right\} \right) × 400}{\mathrm{Level}}\right)÷4⌉×4$

Fun fact: There have been official online Pokémon tournaments that were held with Pokémon set to Levels outside of 50 and 100; but it was a long time ago.

## Factoring in existing EV contribution

If you’ve already got existing EV investment in a stat, you’ve got to factor that in too. You should know the drill by now.

$\mathrm{EVs needed}=⌈\left(\frac{\left( Stat – \left\{ 2 × Base ×\frac{\mathrm{Level}}{\mathrm{100}}+ IV ×\frac{\mathrm{Level}}{\mathrm{100}}+ ⌊\frac{\mathrm{EV}}{4}⌋ ×\frac{\mathrm{Level}}{\mathrm{100}}\right\} \right) × 400}{\mathrm{Level}}\right)÷4⌉×4$

Since the formula is getting a little unwieldy, let’s also reorganise and simplify it:

$\mathrm{EVs needed}=⌈\left(\frac{\left( Stat – \left\{ D \right\} \right) × 400}{\mathrm{Level}}\right)÷4⌉×4$ $\mathrm{Where D = \left\{ 2 × Base ×\frac{\mathrm{Level}}{\mathrm{100}}+ IV ×\frac{\mathrm{Level}}{\mathrm{100}}+ ⌊\frac{\mathrm{EV}}{4}⌋ ×\frac{\mathrm{Level}}{\mathrm{100}}\right\}}$ $\mathrm{= \left\{ \left(2 × Base + IV + ⌊\frac{\mathrm{EV}}{4}⌋ \right) ×\frac{\mathrm{Level}}{\mathrm{100}}\right\}}$

## Factoring in nature and other modifiers

If a stat is affected by Nature or other modifiers, you are going to have work that into the formula too. It may sound complicated, but since stat modifiers multiply into the stat, we just have to divide them from the stat in the formula.

We also have to round the result of the division up, since stats are normally rounded down after modifiers are applied.

$\mathrm{EVs needed}=⌈\left(\frac{\left( ⌈ Stat ÷ Modifiers ⌉ – \left\{ D \right\} \right) × 400}{\mathrm{Level}}\right)÷4⌉×4$ $\mathrm{Where Modifiers = Product of all stat modifiers}$

## The final formula

Here is the final formula for calculating how many EVs you need to raise a stat by a specific number of points.

$\mathrm{EVs needed}=⌈\left(\frac{\left( ⌈ Stat ÷ Modifiers ⌉ – \left\{ D \right\} \right) × 400}{\mathrm{Level}}\right)÷4⌉×4$ $\mathrm{Where Stat = Desired increase in stat;}$ $\mathrm{and Modifiers = Product of all stat modifiers;}$ $\mathrm{and D = \left\{ \left(2 × Base + IV + ⌊\frac{\mathrm{EV}}{4}⌋ \right) ×\frac{\mathrm{Level}}{\mathrm{100}}\right\}}$

Gotta say, I’m pretty proud of working this out on my own. Nonetheless, please feel free to point out any errors or mistakes in the comments section!

## There is one comment:

1. Austyn M. says:

Thank you for this, incredible work! I’m making a Speed calculator spreadsheet, and was always just a few EVs off—your write-up helped me realize I have to round up instead of truncating :)

This site uses Akismet to reduce spam. Learn how your comment data is processed.