python怎样定义zscore_Python stats.zscore方法代码示例

本文详细介绍了Python中scipy.stats.zscore函数的用法,并提供了多个示例,展示了如何在不同场景下使用该函数进行数据标准化处理。示例包括计算样本z分数、信号处理、数据预处理等应用场景。
摘要由CSDN通过智能技术生成

本文整理汇总了Python中scipy.stats.zscore方法的典型用法代码示例。如果您正苦于以下问题:Python stats.zscore方法的具体用法?Python stats.zscore怎么用?Python stats.zscore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块scipy.stats的用法示例。

在下文中一共展示了stats.zscore方法的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_zscore_axis

​点赞 7

# 需要导入模块: from scipy import stats [as 别名]

# 或者: from scipy.stats import zscore [as 别名]

def test_zscore_axis(self):

# Test use of 'axis' keyword in zscore.

x = np.array([[0.0, 0.0, 1.0, 1.0],

[1.0, 1.0, 1.0, 2.0],

[2.0, 0.0, 2.0, 0.0]])

t1 = 1.0/np.sqrt(2.0/3)

t2 = np.sqrt(3.)/3

t3 = np.sqrt(2.)

z0 = stats.zscore(x, axis=0)

z1 = stats.zscore(x, axis=1)

z0_expected = [[-t1, -t3/2, -t3/2, 0.0],

[0.0, t3, -t3/2, t1],

[t1, -t3/2, t3, -t1]]

z1_expected = [[-1.0, -1.0, 1.0, 1.0],

[-t2, -t2, -t2, np.sqrt(3.)],

[1.0, -1.0, 1.0, -1.0]]

assert_array_almost_equal(z0, z0_expected)

assert_array_almost_equal(z1, z1_expected)

开发者ID:ktraunmueller,项目名称:Computable,代码行数:24,

示例2: get_external_state

​点赞 6

# 需要导入模块: from scipy import stats [as 别名]

# 或者: from scipy.stats import zscore [as 别名]

def get_external_state(self):

# Use Hi-Low median as signal:

x = (

np.frombuffer(self.data.high.get(size=self.time_dim)) +

np.frombuffer(self.data.low.get(size=self.time_dim))

) / 2

# Differences along time dimension:

d_x = np.gradient(x, axis=0) * self.p.cwt_signal_scale

# Compute continuous wavelet transform using Ricker wavelet:

cwt_x = signal.cwt(d_x, signal.ricker, self.cwt_width).T

# Note: differences taken once again along channels axis,

# apply weighted scaling to normalize channels

norm_x = np.gradient(cwt_x, axis=-1)

norm_x = zscore(norm_x, axis=0) * self.p.state_ext_scale

#out_x = tanh(norm_x)

out_x = np.clip(norm_x, -10, 10)

return out_x[:, None, :]

开发者ID:Kismuz,项目名称:btgym,代码行数:23,

示例3: test_zscore

​点赞 6

# 需要导入模块: from scipy import stats [as 别名]

# 或者: from scipy.stats import zscore [as 别名]

def test_zscore(self):

for n in self.get_n():

x, y, xm, ym = self.generate_xy_sample(n)

#reference solution

zx = (x - x.mean()) / x.std()

zy = (y - y.mean()) / y.std()

#validate stats

assert_allclose(stats.zscore(x), zx, rtol=1e-10)

assert_allclose(stats.zscore(y), zy, rtol=1e-10)

#compare stats and mstats

assert_allclose(stats.zscore(x), stats.mstats.zscore(xm[0:len(x)]),

rtol=1e-10)

assert_allclose(stats.zscore(y), stats.mstats.zscore(ym[0:len(y)]),

rtol=1e-10)

开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:19,

示例4: efficient_corr

​点赞 6

# 需要导入模块: from scipy import stats [as 别名]

# 或者: from scipy.stats import zscore [as 别名]

def efficient_corr(x, y):

"""

Computes correlation of matching columns in `x` and `y`

Parameters

----------

x, y : (N, M) array_like

Input data arrays

Returns

-------

corr : (M,) numpy.ndarray

Correlations of columns in `x` and `y`

"""

corr = np.sum(zscore(x, ddof=1) * zscore(y, ddof=1), axis=0) / (len(x) - 1)

return corr

开发者ID:rmarkello,项目名称:abagen,代码行数:20,

示例5: neural_sorting

​点赞 6

# 需要导入模块: from scipy import stats [as 别名]

# 或者: from scipy.stats import zscore [as 别名]

def neural_sorting(self,i):

if i==0:

self.isort = np.argsort(self.u[:,int(self.PCedit.text())-1])

elif i==1:

self.isort = self.isort1

if i<2:

self.spF = gaussian_filter1d(self.sp[np.ix_(self.isort,self.tsort)].T,

np.minimum(8,np.maximum(1,int(self.sp.shape[0]*0.005))),

axis=1)

self.spF = self.spF.T

else:

self.spF = self.sp

self.spF = zscore(self.spF, axis=1)

self.spF = np.minimum(8, self.spF)

self.spF = np.maximum(-4, self.spF) + 4

self.spF /= 12

self.img.setImage(self.spF)

self.ROI_position()

开发者ID:MouseLand,项目名称:suite2p,代码行数:20,

示例6: ks_refine

​点赞 6

# 需要导入模块: from scipy import stats [as 别名]

# 或者: from scipy.stats import zscore [as 别名]

def ks_refine(varr, seeds, sig=0.05):

print("selecting seeds

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值