code: def prob_larger_ordinal_choice(prob):
      """probability that observed category is larger than distribution prob
  
      This is a helper function for Ordinal models, where endog is a 1-dim
      categorical variable and predicted probabilities are 2-dimensional with
      observations in rows and choices in columns.
  
      Parameter
      ---------
      prob : array_like
          Expected probabilities for ordinal choices, e.g. from prediction of
          an ordinal model with observations in rows and choices in columns.
  
      Returns
      -------
      cdf_mid : ndarray
          mid cdf, i.e ``P(x < y) + 0.5 P(x=y)``
      r : ndarray
          Probability residual ``P(x > y) - P(x < y)`` for all possible choices.
          Computed as ``r = cdf_mid * 2 - 1``
  
      References
      ----------
      .. [2] Li, Chun, and Bryan E. Shepherd. 2012. “A New Residual for Ordinal
         Outcomes.” Biometrika 99 (2): 473–80.
  
      See Also
      --------
      `statsmodels.stats.nonparametric.rank_compare_2ordinal`
  
      """
      # similar to `nonparametric rank_compare_2ordinal`
  
      prob = np.asarray(prob)
      cdf = prob.cumsum(-1)
      if cdf.ndim == 1:
          cdf_ = np.concatenate(([0], cdf))
      elif cdf.ndim == 2:
          cdf_ = np.concatenate((np.zeros((len(cdf), 1)), cdf), axis=1)
      # r_1 = cdf_[..., 1:] + cdf_[..., :-1] - 1
      cdf_mid = (cdf_[..., 1:] + cdf_[..., :-1]) / 2
      r = cdf_mid * 2 - 1
      return cdf_mid, r
  
file_path: statsmodels/statsmodels/stats/diagnostic_gen.py
imports: import numpy
  from scipy import stats
  from statsmodels.stats.base import HolderTuple
  from statsmodels.stats.effect_size import _noncentrality_chisquare
label_desc: Use image node_id 2 for calling a global function with example usage: prob_larger_ordinal_choice(prob) and returns: cdf_mid,  r