docs: def fit_feedback_params(calibration, max_resistor_readings):
      '''
      Fit model of control board high-voltage feedback resistor and
      parasitic capacitance values based on measured voltage readings.
      '''
      R1 = 10e6
  
      # Get transfer function to compute the amplitude of the high-voltage input
      # to the control board _(i.e., the output of the amplifier)_ based on the
      # attenuated voltage measured by the analog-to-digital converter on the
      # control board.
      #
      # The signature of the transfer function is:
      #
      #     H(V1, R1, C1, R2, C2, f)
      #
      # See the `z_transfer_functions` function docstring for definitions of the
      # parameters based on the control board major version.
      def fit_resistor_params(x):
          resistor_index = x['resistor index'].values[0]
          p0 = [calibration.R_hv[resistor_index],
                calibration.C_hv[resistor_index]]
  
          def error(p, df, R1):
              v1 = compute_from_transfer_function(calibration.hw_version.major,
                                                  'V1',
                                                  V2=df['board measured V'],
                                                  R1=R1, R2=p[0], C2=p[1],
                                                  f=df['frequency'].values)
              e = df['oscope measured V'] - v1
              return e
  
          p1, success = optimize.leastsq(error, p0, args=(x, R1))
          # take the absolute value of the fitted values, since is possible
          # for the fit to produce negative resistor and capacitor values
          p1 = np.abs(p1)
          return pd.DataFrame([p0 + p1.tolist()],
                              columns=['original R', 'original C',
                                       'fitted R', 'fitted C']).T
  
      results = (max_resistor_readings
                 [max_resistor_readings['resistor index'] >= 0]
                 .groupby(['resistor index']).apply(fit_resistor_params))
      data = results.unstack()
      data.columns = data.columns.droplevel()
      return data