code: def expected_rs(n):
    
    front = (n - 0.5) / n
    i = np.arange(1,n)
    back = np.sum(np.sqrt((n - i) / i))
    if n <= 340:
      middle = math.gamma((n-1) * 0.5) / math.sqrt(math.pi) / math.gamma(n * 0.5)
    else:
      middle = 1.0 / math.sqrt(n * math.pi * 0.5)
    return front * middle * back
docs: Calculates the expected (R/S)_n for white noise for a given n.
  
    This is used as a correction factor in the function hurst_rs. It uses the
    formula of Anis-Lloyd-Peters (see [h_3]_).
  
    Args:
      n (int):
        the value of n for which the expected (R/S)_n should be calculated
  
    Returns:
      float:
        expected (R/S)_n for white noise