Python numpy.random.exponential() Examples
The following are 5
code examples of numpy.random.exponential().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
numpy.random
, or try the search function
.
Example #1
Source File: mbo.py From NiaPy with MIT License | 5 votes |
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
Example #2
Source File: models.py From firefly-monte-carlo with MIT License | 5 votes |
def draw_from_prior(self): return npr.exponential(size=self.D)*self.th0
Example #3
Source File: parameter.py From spotpy with MIT License | 5 votes |
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)
Example #4
Source File: synthetic.py From kombine with MIT License | 5 votes |
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]
Example #5
Source File: queue_servers.py From queueing-tool with MIT License | 4 votes |
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