# Find H $\langle H \rangle=P+\frac{1}{AD} \sum_{i=0}^{D} ( \sum_{j=0}^{A} ((j-i)Step(j-i)))$

Hi all, I was reading a post about how certain stats work in a game. Most expressions where simple, but then there was this one and I am completely stumped on how to do it. After some research I now know how to do the entire expression, Except for the " ( (j-i)STEP(j-i) ))" part! From what i've gathered I believe they are using either the Step (staircase) function or the Heaviside Step function. However even after knowing this I am still unable to get a number close to theirs.
I'm very much so a math "noob." So I understand that possibly this is very simple, this is not even a correct expression or somthing else.
If anyone can help me on this that would be much appreciated! ! !

How it was written in the post:

<H> = P + (1/AD) * SUM(i=0 to D)(SUM(j=0 to A)( (j-i)STEP(j-i) ))

In one example they define A=30 P=5 D=80 with an answer of "~10"
In another they define A=20 P=6 D=75 with an answer of 8.4

My main goal is to get the same outputs he got with the same variable definitions, so I hope thats possible.

• well, parts of this is reproducable but that after giving that formula the OP writes "However, the results are much messy, highly dependent on if A > D or not...not able to solve...". (Side note, the name of the variables [and functions P and H=avg.dam.!] is extremely awkward, and the same letters stand for different things in that formula compared to the other one (for P)...) So I fear that if I accept to answer the question you won't be satisfied.

• Could you please clarify the definition of the step function: Step (x)?

• Do you mean the Heaviside step function?

• I think I have found the explanation which I think might be correct, and I'm now able to reproduce the figures -- not exactly but up to a difference of less than 1 unit. Unfortunately, if you consider my answer only partially correct, then it might even cost me money to answer, therefore I'm a bit reluctant to accept to answer the question ...

Answers can only be viewed under the following conditions:
1. The questioner was satisfied with and accepted the answer, or
2. The answer was evaluated as being 100% correct by the judge.
• Your an absolute genius, thank you so much!

• Thanks a lot!

• Oops! actually I had changed the name of the function H() to avg_dam(), but then changed back to H() in the definition, but not in the subsequent lines. Instead of " avg_dam(...) " it should be " H(...) " (or you can define " avg_dam = H " in the PARI interpreter).

• That had me hung up for a bit, while inputting it on the PARI interpreter site, but I figured it out.