本文整理匯總了Python中scipy.zeros_like方法的典型用法代碼示例。如果您正苦於以下問題:Python scipy.zeros_like方法的具體用法?Python scipy.zeros_like怎麽用?Python scipy.zeros_like使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scipy
的用法示例。
在下文中一共展示了scipy.zeros_like方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _RLSortRoots
# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import zeros_like [as 別名]
def _RLSortRoots(mymat):
"""Sort the roots from sys._RLFindRoots, so that the root
locus doesn't show weird pseudo-branches as roots jump from
one branch to another."""
sorted = zeros_like(mymat)
for n, row in enumerate(mymat):
if n == 0:
sorted[n, :] = row
else:
# sort the current row by finding the element with the
# smallest absolute distance to each root in the
# previous row
available = list(range(len(prevrow)))
for elem in row:
evect = elem-prevrow[available]
ind1 = abs(evect).argmin()
ind = available.pop(ind1)
sorted[n, ind] = elem
prevrow = sorted[n, :]
return sorted
示例2: ranktrafo
# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import zeros_like [as 別名]
def ranktrafo(data):
X = data.values[:, None]
Is = X.argsort(axis=0)
RV = sp.zeros_like(X)
rank = sp.zeros_like(X)
for i in xrange(X.shape[1]):
x = X[:,i]
rank = sp.stats.rankdata(x)
rank /= (X.shape[0]+1)
RV[:,i] = sp.sqrt(2) * sp.special.erfinv(2*rank-1)
return RV.flatten()