code: def jackknife(pdf, statistic=np.std, M=None):
      """
      Jackknife resampling [3]_ to quickly estimate the bias and standard
      error of a desired statistic in a probability distribution function (pdf).
  
      Parameters
      ----------
      pdf : ndarray (N, 1)
          Probability distribution function to resample. N should be reasonably
          large.
      statistic : method (optional)
          Method to calculate the desired statistic. (Default: calculate
          standard deviation)
      M : integer (M < N)
          Total number of samples in jackknife pdf. (Default: M == N)
  
      Returns
      -------
      jk_pdf : ndarray (M, 1)
          Jackknife probability distribution function of the statistic.
      bias : float
          Bias of the jackknife pdf of the statistic.
      se : float
          Standard error of the statistic.
  
      See Also
      --------
      numpy.std, numpy.mean, numpy.random.random
  
      Notes
      -----
      Jackknife resampling like bootstrap resampling is non parametric. However,
      it requires a large distribution to be accurate and in some ways can be
      considered deterministic (if one removes the same set of samples,
      then one will get the same estimates of the bias and variance).
  
      In the context of this implementation, the sample size should be at least
      larger than the asymptotic convergence of the statistic (ACstat);
      preferably, larger than ACstat + np.greater(ACbias, ACvar)
  
      The clear benefit of using jackknife is its ability to estimate the bias
      of the statistic. The most powerful application of this is estimating the
      bias of a bootstrap-estimated standard error. In fact, one could
      "bootstrap the bootstrap" (nested bootstrap) of the estimated standard
      error, but the inaccuracy of the bootstrap to characterize the true mean
      would incur a poor estimate of the bias (recall: bias = mean[sample_est] -
      mean[true population])
  
      References
      ----------
      .. [3] Efron, B., 1979. 1977 Rietz lecture--Bootstrap methods--Another
             look at the jackknife. Ann. Stat. 7, 1-26.
  
      """
      N = len(pdf)
      pdf_mask = np.ones(
          (N,), dtype="int16"
      )  # keeps track of all n - 1 indexes
      mask_index = np.copy(pdf_mask)
      if M is None:
          M = N
      M = np.minimum(M, N - 1)
      jk_pdf = np.empty((M,))
  
      rng = np.random.default_rng()
  
      for ii in range(0, M):
          rand_index = np.round(rng.random() * (N - 1))
          # choose a unique random sample to remove
          while pdf_mask[rand_index] == 0:
              rand_index = np.round(rng.random() * (N - 1))
          # set mask to zero for chosen random index so not to choose again
          pdf_mask[rand_index] = 0
          mask_index[rand_index] = 0
          jk_pdf[ii] = statistic(
              pdf[mask_index > 0]
          )  # compute n-1 statistic
          mask_index[rand_index] = 1
  
      return (
          jk_pdf,
          (N - 1) * (np.mean(jk_pdf) - statistic(pdf)),
          np.sqrt(N - 1) * np.std(jk_pdf),
      )
  
file_path: dipy/dipy/boots/resampling.py
imports: import numpy
  import scipy
  import warnings
label_desc: Use image node_id 9 for calling a global function with example usage: jackknife(pdf, statistic, M) and returns: jk_pdf,  unknown,  unknown