Python scipy.special.kolmogorov() Examples
The following are 13
code examples of scipy.special.kolmogorov().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
scipy.special
, or try the search function
.
Example #1
Source File: _continuous_distns.py From lambda-packs with MIT License | 5 votes |
def _cdf(self, x): return 1.0 - sc.kolmogorov(x)
Example #2
Source File: _continuous_distns.py From lambda-packs with MIT License | 5 votes |
def _sf(self, x): return sc.kolmogorov(x)
Example #3
Source File: _continuous_distns.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def _cdf(self, x): return 1.0 - sc.kolmogorov(x)
Example #4
Source File: _continuous_distns.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def _sf(self, x): return sc.kolmogorov(x)
Example #5
Source File: test_kolmogorov.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_nan(self): assert_(np.isnan(kolmogorov(np.nan)))
Example #6
Source File: test_kolmogorov.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_basic(self): dataset = [(0, 1.0), (0.5, 0.96394524366487511), (1, 0.26999967167735456), (2, 0.00067092525577969533)] dataset = np.asarray(dataset) FuncData(kolmogorov, dataset, (0,), 1, rtol=_rtol).check()
Example #7
Source File: test_kolmogorov.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_round_trip(self): def _ki_k(_x): return kolmogi(kolmogorov(_x)) x = np.linspace(0.0, 2.0, 21, endpoint=True) dataset = np.column_stack([x, x]) FuncData(_ki_k, dataset, (0,), 1, rtol=_rtol).check()
Example #8
Source File: test_kolmogorov.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_round_trip(self): def _k_ki(_p): return kolmogorov(kolmogi(_p)) p = np.linspace(0.1, 1.0, 10, endpoint=True) dataset = np.column_stack([p, p]) FuncData(_k_ki, dataset, (0,), 1, rtol=_rtol).check()
Example #9
Source File: _continuous_distns.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _cdf(self, x): return 1.0 - sc.kolmogorov(x)
Example #10
Source File: _continuous_distns.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _sf(self, x): return sc.kolmogorov(x)
Example #11
Source File: mstats_basic.py From lambda-packs with MIT License | 4 votes |
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./n1, -1./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)
Example #12
Source File: mstats_basic.py From GraphicDesignPatternByPython with MIT License | 4 votes |
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./n1, -1./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)
Example #13
Source File: mstats_basic.py From Splunking-Crime with GNU Affero General Public License v3.0 | 4 votes |
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./n1, -1./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)