<p dir="auto">This issue relates to scipy.stats.kstest. The one-sided test, as specified by the <code class="notranslate">alternative</code> argument, works in the opposite direction compared to the other statistical tests (ttest_ind, wilcoxon). In the example below, the p-values for the t-test and wilcoxon test are close to zero, but for the Kolmogorov-Smirnov test the p-value is 1.</p>
<h4 dir="auto">Reproducing code example:</h4>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import scipy.stats
import numpy as np

x = np.random.normal(mu, sigma, 1000)
scipy.stats.ttest_ind(x, x+2, alternative='less')
scipy.stats.wilcoxon(x, x+2, alternative='less')
scipy.stats.kstest(x, x+2, alternative='less')"><pre class="notranslate"><code class="notranslate">import scipy.stats
import numpy as np

x = np.random.normal(mu, sigma, 1000)
scipy.stats.ttest_ind(x, x+2, alternative='less')
scipy.stats.wilcoxon(x, x+2, alternative='less')
scipy.stats.kstest(x, x+2, alternative='less')
</code></pre></div>
<h4 dir="auto">Scipy/Numpy/Python version information:</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="1.6.0 1.19.2 sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)"><pre class="notranslate"><code class="notranslate">1.6.0 1.19.2 sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)
</code></pre></div>
<p dir="auto">Hi, I've found that the <code class="notranslate">stats.ks_2samp()</code>  documentation notes section  states:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In the one-sided test, the alternative is that the empirical
cumulative distribution function F(x) of the data1 variable is &quot;less&quot;
or &quot;greater&quot; than the empirical cumulative distribution function G(x)
of the data2 variable, ``F(x)&lt;=G(x)``, resp. ``F(x)&gt;=G(x)``."><pre class="notranslate"><code class="notranslate">In the one-sided test, the alternative is that the empirical
cumulative distribution function F(x) of the data1 variable is "less"
or "greater" than the empirical cumulative distribution function G(x)
of the data2 variable, ``F(x)&lt;=G(x)``, resp. ``F(x)&gt;=G(x)``.
</code></pre></div>
<p dir="auto">However, when running the function it has the opposite behavior. This is perhaps just a documentation error.</p>
<h4 dir="auto">Reproducing code example:</h4>
<p dir="auto">In the code below I generate two gaussian distributions with different means,<code class="notranslate">data1</code> has a smaller mean than <code class="notranslate">data2</code>.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="data1 = np.random.normal(loc = 0, size = 100)
data2 = np.random.normal(loc = 5, size = 100)

# Should accept alternative hypothesis (data1 ECDF is less than data2's). 
ks_2samp(data1, data2, alternative ='less')
&gt;&gt;&gt;Ks_2sampResult(statistic=0.0, pvalue=1.0)

# Should reject alternative hypothesis
ks_2samp(data1, data2, alternative = 'greater')
&gt;&gt;&gt;Ks_2sampResult(statistic=0.98, pvalue=2.197716889733508e-55)"><pre class="notranslate"><code class="notranslate">data1 = np.random.normal(loc = 0, size = 100)
data2 = np.random.normal(loc = 5, size = 100)

# Should accept alternative hypothesis (data1 ECDF is less than data2's). 
ks_2samp(data1, data2, alternative ='less')
&gt;&gt;&gt;Ks_2sampResult(statistic=0.0, pvalue=1.0)

# Should reject alternative hypothesis
ks_2samp(data1, data2, alternative = 'greater')
&gt;&gt;&gt;Ks_2sampResult(statistic=0.98, pvalue=2.197716889733508e-55)
</code></pre></div>
<h4 dir="auto">Scipy/Numpy/Python version information:</h4>

<p dir="auto">Scipy version 1.4.1<br>
Numpy version 1.19.1<br>
sys.version_info(major=3, minor=7, micro=6, releaselevel='final', serial=0)</p>