本文整理汇总了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)