class_docstr: Result of fitting a Gaussian for mean(empirical distribution).
docstr: Specific recommendations to achieve the given `error_rate`.
docstr_tok: ["Specific","recommendations","to","achieve","the","given","`","error_rate","`","."]
code: def for_error_rate(self, error_rate):
      """Specific recommendations to achieve the given `error_rate`."""
      dist = stats.norm(loc=self.loc, scale=self.scale)
      # Predict a reasonable tolerance
      if self.too_high_p > self.too_low_p:
          # Assume the upper limit is binding
          new_ub = dist.isf(error_rate / 2.0)
          new_atol = new_ub - self.expected
      else:
          # Assume the lower limit is binding
          new_lb = dist.ppf(error_rate / 2.0)
          new_atol = self.expected - new_lb
      new_rtol = new_atol / np.abs(self.expected)
  
      # Predict a reasonable number of samples
      if self.loc >= self.ub or self.loc <= self.lb:
          # No increase in the sample size will make this pass, unless it
          # also shifts the mean, which we cannot predict.
          return _GaussianOneErrorRateResult(
              new_atol,
              new_rtol,
              out_of_bounds=True,
              too_tight=False,
              too_broad=False,
              samples_factor=None,
          )
      else:
          # Given that loc is in bounds, this function is monotonically
          # increasing in the scale factor (because the too_low_p and
          # too_high_p terms are individually increasing toward 0.5).
          def error_rate_good(scale_factor):
              dist = stats.norm(
                  loc=self.loc, scale=self.scale * scale_factor
              )
              too_low_p = dist.cdf(self.lb)
              too_high_p = dist.sf(self.ub)
              return too_low_p + too_high_p - error_rate
  
          if error_rate_good(1000.0) < 0.0:
              # Even a million times fewer samples do not risk exiting the tolerances.
              return _GaussianOneErrorRateResult(
                  new_atol,
                  new_rtol,
                  out_of_bounds=False,
                  too_tight=True,
                  too_broad=False,
                  samples_factor=None,
              )
          elif error_rate_good(0.001) > 0.0:
              # Even a huge number of samples predicts a bad error rate.
              return _GaussianOneErrorRateResult(
                  new_atol,
                  new_rtol,
                  out_of_bounds=False,
                  too_tight=False,
                  too_broad=True,
                  samples_factor=None,
              )
          else:
              scale_factor = optimize.brentq(
                  error_rate_good, 0.001, 1000.0, rtol=1e-9
              )
              return _GaussianOneErrorRateResult(
                  new_atol,
                  new_rtol,
                  out_of_bounds=False,
                  too_tight=False,
                  too_broad=False,
                  samples_factor=scale_factor**-2.0,
              )
  
imports: import collections
  import numpy
  import scipy.optimize
  import scipy.stats
label_desc: Use image node_id 1 for calling the _GaussianResult obj's underlying member method code with example usage: obj.for_error_rate(error_rate) and returns: _GaussianOneErrorRateResult, unknown, _GaussianOneErrorRateResult, _GaussianOneErrorRateResult, _GaussianOneErrorRateResult