There is no such general closed form solution available due to the Abel-Ruffini Theorem, since solving for the pseudorandom value C involves a polynomial in degree N, where N > 4 for all P < ~46%.
First, given your proc chance P, determine the PRG value C using one of the methods detalied in the answers to the question Calculating the constant C in Dota 2 pseudo-random distribution.
N = ceil(1/P)
Then, we define a series of functions:
p(n) = min(Cn, 1)
inv(n) = 1 - p(n); inv(0) = 1.
cml(n) = cml(n-1) * inv(n); cml(0) = 1.
nfr(n) = cml(n-1) - cml(n); nfr(0) = 1.
wgn(n) = nfr(n) * n
tf(n) = wgn(n) / SUM(wgn(n in 1..N))
The logic goes as follows:
p(n) is the chance of bashing on the nth successive hit in a chain of non-crits.
inv(n) inverts this, so we have the chance of missing (the bash) on each hit. From this, by using the multiplication rule, obtain
cml(n), the cumulative chance of getting to
n misses. E.g. if
cum(6) = x that means there's a chance of
x that any chain of attacks is 6 or longer. Then by differencing this function obtain
nfr(n) which is the fraction of chains that is n long. Next, weigh this function by the length of the chain to obtain
tf(n), the "fraction of time spent in a chain of length n".
Next, we need to adjust for something: As you observed, with high attack speed, bashes can overlap. Therefore, with a given input attack speed
a, construct the formula
b(n,a) = min(DUR / (100 * BAT / a), n) / n
Which is the fraction of time spent bashed in a chain of attacks where it takes
n attacks until the next bash. Here
BAT is your base attack time. For slardar this is
BAT = 1.7, and
DUR is the stun duration. In the example,
DUR = 1, or one second. Some example figures:
ATK N=1 N=2 N=3
100 58.9% 29.4% 19.6%
200 100% 58.9% 39.2%
300 100% 88.2% 58.9%
600 100% 100% 100%
ws(n,a) = b(n,a) * tf(n).
Which is the time spent bashed in a chain of attacks, weighted by the total spent fraction of time in a chain of such length. Sum over all
SUM(ws(n in 1..N,a)) = sf(a).
Where sf(a) is the fraction of time the target spends stunned, as a function of the attack speed. Figures for slardar are below:
| ATK SPD | STUN% |
| 100 | 14.7% |
| 125 | 18.4% |
| 150 | 22.1% |
| 175 | 25.7% |
| 200 | 29.0% |
| 225 | 32.4% |
| 250 | 35.8% |
| 275 | 39.1% |
| 300 | 42.5% |
| 325 | 45.9% |
| 350 | 49.0% |
| 375 | 51.8% |
| 400 | 54.6% |
| 425 | 57.4% |
| 450 | 60.2% |
| 475 | 63.0% |
| 500 | 65.8% |
| 525 | 68.1% |
| 550 | 70.2% |
| 575 | 72.3% |
| 600 | 74.4% |
Note that this algorithm assumes that the game is perfectly timed. In reality, durations are rounded to integer numbers of frames: the game is a discrete system, not a continuous one. Thus in the actual game the real figures will be somewhat rounded compared to these estimates.