# harmonic_variances¶

harmonic_variances(n)[source]

Pre-calculate variances of inverse rank distributions.

With

$H_p(n) = \sum \limits_{i=1}^{n} i^{-p}$

denoting the generalized harmonic numbers, and abbreviating $$H(n) := H_1(n)$$, we have

$\begin{split}\textit{V}[n] &= \frac{1}{n} \sum \limits_{i=1}^n \left( i^{-1} - \frac{H(n)}{n} \right)^2 \\ &= \frac{n \cdot H_2(n) - H(n)^2}{n^2}\end{split}$
Parameters:

n (int) – the maximum rank number

Return type:

ndarray

Returns:

shape: (n+1,) the variances for the discrete uniform distribution over $$\{\frac{1}{1}, \dots, \frac{1}{k}\}`$$