class_docstr: Permutation test based on distance.
  
  Perform a permutation test based on distance. You have the choice of 3
  different statistic:
  
  - 'pairwise' :
      the statistic is based on paiwire distance as
      descibed in [1]_. This is the fastest option for low sample size since
      the pairwise distance matrix does not need to be estimated for each
      permutation.
  
  - 'ttest' :
      t-test based statistic obtained by the ration of the
      distance between each riemannian centroid and the group dispersion.
      The means have to be estimated for each permutation, leading to a
      slower procedure. However, this can be used for high sample size.
  
  - 'ftest':
      f-test based statistic estimated using the between and
      within group variability. As for the 'ttest' stats, group centroid
      are estimated for each permutation.
  
  Parameters
  ----------
  n_perms : int, default=100
      The number of permutation. The minimum should be 20 for a resolution of
      0.05 p-value.
  metric : string | dict, default='riemann'
      The type of metric used for centroid and distance estimation.
      see `distance` anb `mean_covariance` for the list of supported metric.
      the metric could be a dict with two keys, `mean` and `distance` in
      order to pass different metric for the centroid estimation and the
      distance estimation. Typical usecase is to pass 'logeuclid' metric for
      the mean in order to boost the computional speed and 'riemann' for the
      distance in order to keep the good sensitivity for the classification.
  mode : string, default='pairwise'
      Type of statistic to use. could be 'pairwise', 'ttest' of 'ftest'
  n_jobs : integer, default=1
      The number of CPUs to use to do the computation. -1 means
      'all CPUs'.
  random_state : int, default=42
      random state for the permutation test.
  estimator : None or sklearn compatible estimator, default=None
      If provided, data are transformed before every permutation. should
      not be used unless a supervised opperation must be applied on the data.
      This would be the case for ERP covariance.
  
  Attributes
  ----------
  p_value_ : float
      the p-value of the test
  scores_ : list
      contain all scores for all permutations. The fist element is the
      non-permuted score.
  
  See Also
  --------
  PermutationModel
  
  References
  ----------
  .. [1] `A new method for non-parametric multivariate analysis of variance
      <https://doi.org/10.1111/j.1442-9993.2001.01070.pp.x>`_
      M. Anderson. Austral ecology, Volume 26, Issue 1, February 2001.
class_docstr_tok: ["Permutation","test","based","on","distance",".","Perform","a","permutation","test","based","on","distance",".","You","have","the","choice","of","3","different","statistic",":","-","'pairwise","'",":","the","statistic","is","based","on","paiwire","distance","as","descibed","in","[","1","]","_",".","This","is","the","fastest","option","for","low","sample","size","since","the","pairwise","distance","matrix","does","not","need","to","be","estimated","for","each","permutation",".","-","'ttest","'",":","t-test","based","statistic","obtained","by","the","ration","of","the","distance","between","each","riemannian","centroid","and","the","group","dispersion",".","The","means","have","to","be","estimated","for","each","permutation",",","leading","to","a","slower","procedure",".","However",",","this","can","be","used","for","high","sample","size",".","-","'ftest","'",":","f-test","based","statistic","estimated","using","the","between","and","within","group","variability",".","As","for","the","'ttest","'","stats",",","group","centroid","are","estimated","for","each","permutation",".","Parameters","--","--","--","--","--","n_perms",":","int",",","default=100","The","number","of","permutation",".","The","minimum","should","be","20","for","a","resolution","of","0.05","p-value",".","metric",":","string","|","dict",",","default='riemann'","The","type","of","metric","used","for","centroid","and","distance","estimation",".","see","`","distance","`","anb","`","mean_covariance","`","for","the","list","of","supported","metric",".","the","metric","could","be","a","dict","with","two","keys",",","`","mean","`","and","`","distance","`","in","order","to","pass","different","metric","for","the","centroid","estimation","and","the","distance","estimation",".","Typical","usecase","is","to","pass","'logeuclid","'","metric","for","the","mean","in","order","to","boost","the","computional","speed","and","'riemann","'","for","the","distance","in","order","to","keep","the","good","sensitivity","for","the","classification",".","mode",":","string",",","default='pairwise'","Type","of","statistic","to","use",".","could","be","'pairwise","'",",","'ttest","'","of","'ftest'","n_jobs",":","integer",",","default=1","The","number","of","CPUs","to","use","to","do","the","computation",".","-1","means","'all","CPUs","'",".","random_state",":","int",",","default=42","random","state","for","the","permutation","test",".","estimator",":","None","or","sklearn","compatible","estimator",",","default=None","If","provided",",","data","are","transformed","before","every","permutation",".","should","not","be","used","unless","a","supervised","opperation","must","be","applied","on","the","data",".","This","would","be","the","case","for","ERP","covariance",".","Attributes","--","--","--","--","--","p_value_",":","float","the","p-value","of","the","test","scores_",":","list","contain","all","scores","for","all","permutations",".","The","fist","element","is","the","non-permuted","score",".","See","Also","--","--","--","--","PermutationModel","References","--","--","--","--","--","..","[","1","]","`","A","new","method","for","non-parametric","multivariate","analysis","of","variance","<","https",":","\/\/doi.org\/10.1111\/j.1442-9993.2001.01070.pp.x",">","`","_","M.","Anderson",".","Austral","ecology",",","Volume","26",",","Issue","1",",","February","2001","."]
docstr: Score for the pairwise distance test.
docstr_tok: ["Score","for","the","pairwise","distance","test","."]
code: def _score_pairwise(self, X, y):
      """Score for the pairwise distance test."""
      classes = np.unique(y)
      n_classes = len(classes)
      n_samples = len(y)
      total_ss = X.sum() / (2 * n_samples)
      pattern = np.zeros((n_samples, n_samples))
      for classe in classes:
          ix = y == classe
          pattern += np.outer(ix, ix) / ix.sum()
  
      within_ss = (X * pattern).sum() / 2
  
      between_ss = total_ss - within_ss
  
      score = (between_ss / (n_classes - 1)) / (
          within_ss / (n_samples - n_classes)
      )
  
      return score
  
imports: import sys
  import math
  import numpy
  from .utils.utils import check_version
  from .utils.distance import distance, pairwise_distance
  from .utils.mean import mean_covariance
  from .classification import MDM, _check_metric
label_desc: Use image node_id 7 for calling the PermutationDistance obj's underlying member method code with example usage: obj._score_pairwise(X, y) and returns: score