"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "scipy/stats/mstats_basic.py" between
scipy-1.6.2.tar.xz and scipy-1.6.3.tar.xz

About: SciPy are tools for mathematics, science, and engineering (for Python).

mstats_basic.py  (scipy-1.6.2.tar.xz):mstats_basic.py  (scipy-1.6.3.tar.xz)
skipping to change at line 36 skipping to change at line 36
'ttest_ind','ttest_rel','tvar', 'ttest_ind','ttest_rel','tvar',
'variation', 'variation',
'winsorize', 'winsorize',
'brunnermunzel', 'brunnermunzel',
] ]
import numpy as np import numpy as np
from numpy import ndarray from numpy import ndarray
import numpy.ma as ma import numpy.ma as ma
from numpy.ma import masked, nomask from numpy.ma import masked, nomask
import math
import itertools import itertools
import warnings import warnings
from collections import namedtuple from collections import namedtuple
from . import distributions from . import distributions
import scipy.special as special import scipy.special as special
import scipy.stats.stats import scipy.stats.stats
from scipy._lib._util import float_factorial from scipy._lib._util import float_factorial
skipping to change at line 532 skipping to change at line 533
# Exact p-value, see Maurice G. Kendall, "Rank Correlation Methods" (4th Edi tion), Charles Griffin & Co., 1970. # Exact p-value, see Maurice G. Kendall, "Rank Correlation Methods" (4th Edi tion), Charles Griffin & Co., 1970.
if n <= 0: if n <= 0:
raise ValueError('n ({n}) must be positive') raise ValueError('n ({n}) must be positive')
elif c < 0 or 4*c > n*(n-1): elif c < 0 or 4*c > n*(n-1):
raise ValueError(f'c ({c}) must satisfy 0 <= 4c <= n(n-1) = {n*(n-1)}.') raise ValueError(f'c ({c}) must satisfy 0 <= 4c <= n(n-1) = {n*(n-1)}.')
elif n == 1: elif n == 1:
prob = 1.0 prob = 1.0
elif n == 2: elif n == 2:
prob = 1.0 prob = 1.0
elif c == 0: elif c == 0:
prob = 2.0/np.math.factorial(n) if n < 171 else 0.0 prob = 2.0/math.factorial(n) if n < 171 else 0.0
elif c == 1: elif c == 1:
prob = 2.0/np.math.factorial(n-1) if n < 172 else 0.0 prob = 2.0/math.factorial(n-1) if n < 172 else 0.0
elif 4*c == n*(n-1): elif 4*c == n*(n-1):
prob = 1.0 prob = 1.0
elif n < 171: elif n < 171:
new = np.zeros(c+1) new = np.zeros(c+1)
new[0:2] = 1.0 new[0:2] = 1.0
for j in range(3,n+1): for j in range(3,n+1):
new = np.cumsum(new) new = np.cumsum(new)
if j <= c: if j <= c:
new[j:] -= new[:c+1-j] new[j:] -= new[:c+1-j]
prob = 2.0*np.sum(new)/np.math.factorial(n) prob = 2.0*np.sum(new)/math.factorial(n)
else: else:
new = np.zeros(c+1) new = np.zeros(c+1)
new[0:2] = 1.0 new[0:2] = 1.0
for j in range(3, n+1): for j in range(3, n+1):
new = np.cumsum(new)/j new = np.cumsum(new)/j
if j <= c: if j <= c:
new[j:] -= new[:c+1-j] new[j:] -= new[:c+1-j]
prob = np.sum(new) prob = np.sum(new)
return np.clip(prob, 0, 1) return np.clip(prob, 0, 1)
 End of changes. 4 change blocks. 
3 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)