python中mean方法_Python stats.gmean方法代码示例

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

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

示例1: geometric_mean_var

​点赞 6

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

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

def geometric_mean_var(z):

for row in np.eye(z.shape[1]):

if not np.any(np.all(row == z, axis=1)):

z = np.row_stack([z, row])

n_points, n_dim = z.shape

D = vectorized_cdist(z, z)

np.fill_diagonal(D, np.inf)

k = n_dim - 1

I = D.argsort(axis=1)[:, :k]

first = np.column_stack([np.arange(n_points) for _ in range(k)])

val = gmean(D[first, I], axis=1)

return val.var()

开发者ID:msu-coinlab,项目名称:pymoo,代码行数:19,

示例2: test_1D

​点赞 6

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

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

def test_1D(self):

a = (1,2,3,4)

actual = mstats.gmean(a)

desired = np.power(1*2*3*4,1./4.)

assert_almost_equal(actual, desired, decimal=14)

desired1 = mstats.gmean(a,axis=-1)

assert_almost_equal(actual, desired1, decimal=14)

assert_(not isinstance(desired1, ma.MaskedArray))

a = ma.array((1,2,3,4),mask=(0,0,0,1))

actual = mstats.gmean(a)

desired = np.power(1*2*3,1./3.)

assert_almost_equal(actual, desired,decimal=14)

desired1 = mstats.gmean(a,axis=-1)

assert_almost_equal(actual, desired1, decimal=14)

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

示例3: rl_reward

​点赞 6

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

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

def rl_reward(env):

delay = np.asarray(env.env_D)

mask = delay == np.inf

delay[mask] = len(delay)*np.max(delay[~mask])

if env.PRAEMIUM == 'AVG':

reward = -np.mean(matrix_to_rl(delay))

elif env.PRAEMIUM == 'MAX':

reward = -np.max(matrix_to_rl(delay))

elif env.PRAEMIUM == 'AXM':

reward = -(np.mean(matrix_to_rl(delay)) + np.max(matrix_to_rl(delay)))/2

elif env.PRAEMIUM == 'GEO':

reward = -stats.gmean(matrix_to_rl(delay))

elif env.PRAEMIUM == 'LOST':

reward = -env.env_L

return reward

# WRAPPER ITSELF

开发者ID:knowledgedefinednetworking,项目名称:a-deep-rl-approach-for-sdn-routing-optimization,代码行数:22,

示例4: main

​点赞 6

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

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

def main() -> None:

throughputs_hase = []

throughputs_original = []

for i in range(args.n):

with open(f"{args.name}_{i}.out") as file:

benchmarks, throughput = parse(file)

throughputs_original.append(throughput)

with open(f"{args.name}_hase_{i}.out") as file:

benchmarks, throughput = parse(file)

throughputs_hase.append(throughput)

throughputs_hase = np.array(throughputs_hase)

throughputs_original = np.array(throughputs_original)

ratios = aggregate(throughputs_hase) / aggregate(throughputs_original)

for i in range(len(benchmarks)):

print(f"{benchmarks[i]}\t{ratios[i]:.4f}")

print("GeoMean\t" + str(gmean(ratios)))

开发者ID:hase-project,项目名称:hase,代码行数:22,

示例5: main

​点赞 6

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

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

def main() -> None:

throughputs_hase = []

throughputs_original = []

for i in range(args.n):

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值