Skip to main content

gen_harmonic

Function gen_harmonic 

Source
pub fn gen_harmonic(n: u64, a: f64) -> f64
Expand description

Generalized harmonic number $H_{n,a} = \sum_{i=1}^n i^{-a}$

If $a > 1$ and not too close to $1$, the sum is computed using the Hurwitz zeta function as $\zeta(a, 1) - \zeta(a, n + 1)$. Otherwise it is computed as a simple sum of the powers.

Returns NaN if $n = 0$.

Corresponds to xsf::gen_harmonic, which is used by scipy.stats.zipfian.

ยงSee also