code: def _profile_loglike_spline(self, x):
          
          z = []
          y = []
  
          yv = self._nuis_pdf.profile_bins()
          nuis_vals = self._nuis_pdf.log_value(yv) - self._nuis_log_norm
          for xtmp in x:
              zv = -1. * self._lnlfn.interp(xtmp * yv) + nuis_vals
              sp = splrep(yv, zv, k=2, s=0)
  
              def rf(t): return splev(t, sp, der=1)
              ix = np.argmax(splev(yv, sp))
              imin, imax = max(0, ix - 3), min(len(yv) - 1, ix + 3)
              try:
                  y0 = opt.brentq(rf, yv[imin], yv[imax], xtol=1e-10)
              except:
                  y0 = yv[ix]
              z0 = self.loglike(xtmp, y0)
              z.append(z0)
              y.append(y0)
  
          self._prof_y = np.array(y)
          self._prof_z = np.array(z)
          self._prof_z = self._prof_z.max() - self._prof_z
          
          self._prof_interp = castro.Interpolator(x, self._prof_z)
          return self._prof_y, self._prof_z
docs: Internal function to calculate and cache the profile likelihood