code: def ks_twosamp(data1, data2, alternative="two-sided"):
      """
      Computes the Kolmogorov-Smirnov test on two samples.
  
      Missing values are discarded.
  
      Parameters
      ----------
      data1 : array_like
          First data set
      data2 : array_like
          Second data set
      alternative : {'two-sided', 'less', 'greater'}, optional
          Indicates the alternative hypothesis.  Default is 'two-sided'.
  
      Returns
      -------
      d : float
          Value of the Kolmogorov Smirnov test
      p : float
          Corresponding p-value.
  
      """
      (data1, data2) = (ma.asarray(data1), ma.asarray(data2))
      (n1, n2) = (data1.count(), data2.count())
      n = n1 * n2 / float(n1 + n2)
      mix = ma.concatenate((data1.compressed(), data2.compressed()))
      mixsort = mix.argsort(kind="mergesort")
      csum = np.where(mixsort < n1, 1.0 / n1, -1.0 / n2).cumsum()
      # Check for ties
      if len(np.unique(mix)) < (n1 + n2):
          csum = csum[np.r_[np.diff(mix[mixsort]).nonzero()[0], -1]]
  
      alternative = str(alternative).lower()[0]
      if alternative == "t":
          d = ma.abs(csum).max()
          prob = special.kolmogorov(np.sqrt(n) * d)
      elif alternative == "l":
          d = -csum.min()
          prob = np.exp(-2 * n * d**2)
      elif alternative == "g":
          d = csum.max()
          prob = np.exp(-2 * n * d**2)
      else:
          raise ValueError(
              "Invalid value for the alternative hypothesis: "
              "should be in 'two-sided', 'less' or 'greater'"
          )
  
      return (d, prob)
  
imports: from __future__ import division, print_function, absolute_import
  import numpy
  from numpy import ndarray
  import numpy.ma
  from numpy.ma import masked, nomask
  from scipy._lib.six import iteritems
  import itertools
  import warnings
  from collections import namedtuple
  from .None import distributions
  import scipy.special
  from ._stats_mstats_common import _find_repeats, linregress, theilslopes, siegelslopes
label_desc: Use image node_id 25 for calling a global function with example usage: ks_twosamp(data1, data2, alternative) and returns: d,  prob