• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python measures.impose_mean函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mystic.math.measures.impose_mean函数的典型用法代码示例。如果您正苦于以下问题:Python impose_mean函数的具体用法?Python impose_mean怎么用?Python impose_mean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: bounded_mean

def bounded_mean(mean_x, samples, xmin, xmax, wts=None):
  from mystic.math.measures import impose_mean, impose_spread
  from mystic.math.measures import spread, mean
  from numpy import asarray
  a = impose_mean(mean_x, samples, wts)
  if min(a) < xmin:   # maintain the bound
    #print "violate lo(a)"
    s = spread(a) - 2*(xmin - min(a)) #XXX: needs compensation (as below) ?
    a = impose_mean(mean_x, impose_spread(s, samples, wts), wts)
  if max(a) > xmax:   # maintain the bound
    #print "violate hi(a)"
    s = spread(a) + 2*(xmax - max(a)) #XXX: needs compensation (as below) ?
    a = impose_mean(mean_x, impose_spread(s, samples, wts), wts)
  return asarray(a)
开发者ID:agamdua,项目名称:mystic,代码行数:14,代码来源:discrete.py


示例2: constraints

 def constraints(x):
     # constrain the last x_i to be the same value as the first x_i
     x[-1] = x[0]
     # constrain x such that mean(x) == target
     if not almostEqual(mean(x), target):
         x = impose_mean(target, x)
     return x
开发者ID:jcfr,项目名称:mystic,代码行数:7,代码来源:constraint2_example01.py


示例3: test_proxified_constraint

def test_proxified_constraint():

  from mystic.math.measures import impose_mean

  @inner_proxy(inner=impose_mean)
  def mean_then_squared(x): #XXX: proxy doesn't preserve function signature
    return [i**2 for i in x]

  from numpy import array
  x = array([1,2,3,4,5])
  assert mean_then_squared(5,x) == [i**2 for i in impose_mean(5,x)]
开发者ID:uqfoundation,项目名称:mystic,代码行数:11,代码来源:test_coupler.py


示例4: test_with_mean

def test_with_mean():

  from mystic.math.measures import mean, impose_mean

  @with_mean(5.0)
  def mean_of_squared(x):
    return [i**2 for i in x]

  from numpy import array
  x = array([1,2,3,4,5])
  y = impose_mean(5, [i**2 for i in x])
  assert mean(y) == 5.0
  assert mean_of_squared(x) == y
开发者ID:uqfoundation,项目名称:mystic,代码行数:13,代码来源:test_constraints.py


示例5: test_with_constraint

def test_with_constraint():

  from mystic.math.measures import mean, impose_mean

  @with_constraint(inner, kwds={'target':5.0})
  def mean_of_squared(x, target):
    return impose_mean(target, [i**2 for i in x])

  from numpy import array
  x = array([1,2,3,4,5])
  y = impose_mean(5, [i**2 for i in x])
  assert mean(y) == 5.0
  assert mean_of_squared(x) == y
开发者ID:uqfoundation,项目名称:mystic,代码行数:13,代码来源:test_constraints.py


示例6: test_inner_constraint

def test_inner_constraint():

  from mystic.math.measures import impose_mean

  def impose_constraints(x, mean, weights=None):
    return impose_mean(mean, x, weights)

  @inner(inner=impose_constraints, kwds={'mean':5.0})
  def mean_then_squared(x):
    return [i**2 for i in x]

  from numpy import array
  x = array([1,2,3,4,5])
  assert mean_then_squared(x) == [i**2 for i in impose_mean(5,x)]
开发者ID:uqfoundation,项目名称:mystic,代码行数:14,代码来源:test_coupler.py


示例7: test_with_mean_spread

def test_with_mean_spread():

  from mystic.math.measures import mean, spread, impose_mean, impose_spread

  @with_spread(50.0)
  @with_mean(5.0)
  def constrained_squared(x):
    return [i**2 for i in x]

  from numpy import array
  x = array([1,2,3,4,5])
  y = impose_spread(50.0, impose_mean(5.0,[i**2 for i in x]))
  assert almostEqual(mean(y), 5.0, tol=1e-15)
  assert almostEqual(spread(y), 50.0, tol=1e-15)
  assert constrained_squared(x) == y
开发者ID:uqfoundation,项目名称:mystic,代码行数:15,代码来源:test_constraints.py


示例8: test_outer_constraint

def test_outer_constraint():

  from mystic.math.measures import impose_mean, mean

  def impose_constraints(x, mean, weights=None):
    return impose_mean(mean, x, weights)

  @outer(outer=impose_constraints, kwds={'mean':5.0})
  def mean_of_squared(x):
    return [i**2 for i in x]

  from numpy import array
  x = array([1,2,3,4,5])
  y = impose_mean(5, [i**2 for i in x])
  assert mean(y) == 5.0
  assert mean_of_squared(x) == y
开发者ID:uqfoundation,项目名称:mystic,代码行数:16,代码来源:test_coupler.py


示例9: test_inner_constraints

def test_inner_constraints():

  from mystic.math.measures import impose_mean, impose_spread

  def impose_constraints(x, mean=0.0, spread=1.0):
    x = impose_mean(mean, x)
    x = impose_spread(spread, x)
    return x

  @inner(inner=impose_constraints, kwds={'mean':5.0, 'spread':50.0})
  def constrained_squared(x):
    return [i**2 for i in x]

  from numpy import array
  x = array([1,2,3,4,5])
  y = impose_spread(50.0, impose_mean(5.0,x))
  assert constrained_squared(x) == [i**2 for i in y]
开发者ID:uqfoundation,项目名称:mystic,代码行数:17,代码来源:test_coupler.py


示例10: constrain

 def constrain(rv):
   "constrain:  y >= m  and  sum(wi)_{k} = 1 for each k in K"
   pm = scenario()
   pm.load(rv, pts)      # here rv is param: w,x,y
   #impose: sum(wi)_{k} = 1 for each k in K
   norm = 1.0
   for i in range(len(pm)):
     w = pm[i].weights
     w[-1] = norm - sum(w[:-1])
     pm[i].weights = w
   #impose: y >= m 
   values, weights = pm.values, pm.weights
   y = float(mean(values, weights))
   if not (y >= float(target[0])):
     pm.values = impose_mean(target[0]+target[1], values, weights)
   rv = pm.flatten(all=True) 
   return rv
开发者ID:agamdua,项目名称:mystic,代码行数:17,代码来源:discrete.py


示例11: test_proxified_constraints

def test_proxified_constraints():

  from mystic.math.measures import impose_mean, impose_spread

  def impose_constraints(x, mean=0.0, spread=1.0):
    x = impose_mean(mean, x)
    x = impose_spread(spread, x)
    return x

  @inner_proxy(inner=impose_constraints)
  def constrained_squared(x): #XXX: proxy doesn't preserve function signature
    return [i**2 for i in x]

  from numpy import array
  x = array([1,2,3,4,5])
  y = impose_spread(50.0, impose_mean(5.0,x))
  assert constrained_squared(x, 5.0, 50.0) == [i**2 for i in y]
开发者ID:uqfoundation,项目名称:mystic,代码行数:17,代码来源:test_coupler.py


示例12: mean_of_squared

 def mean_of_squared(x, target):
   return impose_mean(target, [i**2 for i in x])
开发者ID:uqfoundation,项目名称:mystic,代码行数:2,代码来源:test_constraints.py


示例13: impose_constraints

 def impose_constraints(x, mean, weights=None):
   return impose_mean(mean, x, weights)
开发者ID:uqfoundation,项目名称:mystic,代码行数:2,代码来源:test_coupler.py


示例14: mean_constraint

 def mean_constraint(x, mean=0.0):
   return impose_mean(mean, x)
开发者ID:uqfoundation,项目名称:mystic,代码行数:2,代码来源:test_coupler.py


示例15: __set_mean

 def __set_mean(self, m):
   self.positions = impose_mean(m, self.positions, self.weights)
   return
开发者ID:agamdua,项目名称:mystic,代码行数:3,代码来源:discrete.py


示例16: set_mean_value

 def set_mean_value(self, m):  # set mean of y's
   """set the mean for the associated values of a scenario"""
   from mystic.math.measures import impose_mean
   self.values = impose_mean(m, self.values, self.weights)
   return
开发者ID:agamdua,项目名称:mystic,代码行数:5,代码来源:discrete.py



注:本文中的mystic.math.measures.impose_mean函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python measures.mean函数代码示例发布时间:2022-05-27
下一篇:
Python math.poly1d函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap