当前位置: 首页>>代码示例>>Python>>正文


Python random.exponential方法代码示例

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


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

示例1: adjustingOperator

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import exponential [as 别名]
def adjustingOperator(self, t, max_t, D, NP1, NP2, Butterflies, best):
		r"""Apply the adjusting operator.

		Args:
			 t (int): Current generation.
			 max_t (int): Maximum generation.
			 D (int): Number of dimensions.
			 NP1 (int): Number of butterflies in Land 1.
			 NP2 (int): Number of butterflies in Land 2.
			 Butterflies (numpy.ndarray): Current butterfly population.
			 best (numpy.ndarray): The best butterfly currently.

		Returns:
			 numpy.ndarray: Adjusted butterfly population.
		"""
		pop2 = copy(Butterflies[NP1:])
		for k2 in range(NP1, NP1 + NP2):
			scale = 1.0 / ((t + 1)**2)
			step_size = ceil(exponential(2 * max_t))
			delataX = self.levy(step_size, D)
			for parnum2 in range(0, D):
				if self.uniform(0.0, 1.0) >= self.PAR:
					Butterflies[k2, parnum2] = best[parnum2]
				else:
					r4 = self.randint(Nmin=0, Nmax=NP2 - 1)
					Butterflies[k2, parnum2] = pop2[r4, 1]
					if self.uniform(0.0, 1.0) > self.BAR:
						Butterflies[k2, parnum2] += scale * \
															 (delataX[parnum2] - 0.5)
		return Butterflies 
开发者ID:NiaOrg,项目名称:NiaPy,代码行数:32,代码来源:mbo.py

示例2: draw_from_prior

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import exponential [as 别名]
def draw_from_prior(self):
        return npr.exponential(size=self.D)*self.th0 
开发者ID:HIPS,项目名称:firefly-monte-carlo,代码行数:4,代码来源:models.py

示例3: __init__

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import exponential [as 别名]
def __init__(self, *args, **kwargs):
        """
        :name: Name of the parameter
        :scale: The scale parameter, \beta = 1/\lambda.
        :step:     (optional) number for step size required for some algorithms, 
                eg. mcmc need a parameter of the variance for the next step
                default is median of rndfunc(*rndargs, size=1000)
        :optguess: (optional) number for start point of parameter
                default is quantile(0.5) - quantile(0.4) of 
                rndfunc(*rndargs, size=1000) 
        """
        super(Exponential, self).__init__(rnd.exponential, 'Exponential', *args, **kwargs) 
开发者ID:thouska,项目名称:spotpy,代码行数:14,代码来源:parameter.py

示例4: generate_poisson

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import exponential [as 别名]
def generate_poisson(self, tstart, tend, cadence):
        n=int((tend-tstart)/cadence*2 + 20)

        dts=cadence*nr.exponential(size=n)

        ts=tstart + np.cumsum(dts)

        return ts[ts<tend] 
开发者ID:bfarr,项目名称:kombine,代码行数:10,代码来源:synthetic.py

示例5: __init__

# 需要导入模块: from numpy import random [as 别名]
# 或者: from numpy.random import exponential [as 别名]
def __init__(self, num_servers=1, arrival_f=None,
                 service_f=None, edge=(0, 0, 0, 1),
                 AgentFactory=Agent, collect_data=False, active_cap=infty,
                 deactive_t=infty, colors=None, seed=None,
                 coloring_sensitivity=2, **kwargs):

        if not isinstance(num_servers, numbers.Integral) and num_servers is not infty:
            msg = "num_servers must be an integer or infinity."
            raise TypeError(msg)
        elif num_servers <= 0:
            msg = "num_servers must be a positive integer or infinity."
            raise ValueError(msg)

        self.edge = edge
        self.num_servers = kwargs.get('nServers', num_servers)
        self.num_departures = 0
        self.num_system = 0
        self.data = {}   # times; agent_id : [arrival, service start, departure]
        self.queue = collections.deque()

        if arrival_f is None:
            def arrival_f(t):
                return t + exponential(1.0)

        if service_f is None:
            def service_f(t):
                return t + exponential(0.9)

        self.arrival_f = arrival_f
        self.service_f = service_f
        self.AgentFactory = AgentFactory
        self.collect_data = collect_data
        self.active_cap = active_cap
        self.deactive_t = deactive_t

        inftyAgent = InftyAgent()
        self._arrivals = [inftyAgent]    # A list of arriving agents.
        self._departures = [inftyAgent]    # A list of departing agents.
        self._num_arrivals = 0
        self._oArrivals = 0
        self._num_total = 0       # The number of agents scheduled to arrive + num_system
        self._active = False
        self._current_t = 0       # The time of the last event.
        self._time = infty   # The time of the next event.
        self._next_ct = 0       # The next time an arrival from outside the network can arrive.
        self.coloring_sensitivity = coloring_sensitivity

        if isinstance(seed, numbers.Integral):
            np.random.seed(seed)

        if colors is not None:
            self.colors = colors
            for col in set(self._default_colors.keys()) - set(self.colors.keys()):
                self.colors[col] = self._default_colors[col]
        else:
            self.colors = self._default_colors 
开发者ID:djordon,项目名称:queueing-tool,代码行数:58,代码来源:queue_servers.py


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