本文整理匯總了Python中scipy.special.kolmogorov方法的典型用法代碼示例。如果您正苦於以下問題:Python special.kolmogorov方法的具體用法?Python special.kolmogorov怎麽用?Python special.kolmogorov使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scipy.special
的用法示例。
在下文中一共展示了special.kolmogorov方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _cdf
# 需要導入模塊: from scipy import special [as 別名]
# 或者: from scipy.special import kolmogorov [as 別名]
def _cdf(self, x):
return 1.0 - sc.kolmogorov(x)
示例2: _sf
# 需要導入模塊: from scipy import special [as 別名]
# 或者: from scipy.special import kolmogorov [as 別名]
def _sf(self, x):
return sc.kolmogorov(x)
示例3: test_nan
# 需要導入模塊: from scipy import special [as 別名]
# 或者: from scipy.special import kolmogorov [as 別名]
def test_nan(self):
assert_(np.isnan(kolmogorov(np.nan)))
示例4: test_basic
# 需要導入模塊: from scipy import special [as 別名]
# 或者: from scipy.special import kolmogorov [as 別名]
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()
示例5: test_round_trip
# 需要導入模塊: from scipy import special [as 別名]
# 或者: from scipy.special import kolmogorov [as 別名]
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()
示例6: ks_twosamp
# 需要導入模塊: from scipy import special [as 別名]
# 或者: from scipy.special import kolmogorov [as 別名]
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)