code: def crude_age_standardization(e, b, n):
      
      r = e * 1.0 / b
      b_by_n = sum_by_n(b, 1.0, n)
      age_weight = b * 1.0 / b_by_n.repeat(len(e) // n)
      return sum_by_n(r, age_weight, n)
docs: A utility function to compute rate through crude age standardization
  
      Parameters
      ----------
      e          : array
                   (n*h, 1), event variable measured for each age group across n spatial units
      b          : array
                   (n*h, 1), population at risk variable measured for each age group across n spatial units
      n          : integer
                   the number of spatial units
  
      Notes
      -----
      e and b are arranged in the same order
  
      Returns
      -------
                 : array
                   (n, 1), age standardized rate
  
      Examples
      --------
  
      Creating an array of an event variable (e.g., the number of cancer patients)
      for 2 regions in each of which 4 age groups are available.
      The first 4 values are event values for 4 age groups in the region 1,
      and the next 4 values are for 4 age groups in the region 2.
  
      >>> e = np.array([30, 25, 25, 15, 33, 21, 30, 20])
  
      Creating another array of a population-at-risk variable (e.g., total population)
      for the same two regions.
      The order for entering values is the same as the case of e.
  
      >>> b = np.array([100, 100, 110, 90, 100, 90, 110, 90])
  
      Specifying the number of regions.
  
      >>> n = 2
  
      Applying crude_age_standardization function to e and b
  
      >>> crude_age_standardization(e, b, n)
      array([0.2375    , 0.26666667])