• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(20)  |  Call(16)  |  Derive(0)  |  Import(4)
Triangular distribution.

Continuous distribution bounded by given lower and upper limits,
and having a given mode value in-between.

http://en.wikipedia.org/wiki/Triangular_distribution

src/s/h/shedskin-HEAD/examples/genetic2.py   shedskin(Download)
#!/usr/bin/env python
 
# placed in the public domain by Stavros Korokithakis
 
import time
import copy
from random import randrange, randint, seed, random, choice, triangular
        iters = int(Pool.population_size * 0.6)
        for counter in range(0, iters, 2):
            # Perform rank roulette selection.
            father = self.population[int(triangular(0, iters, 0))]
            mother = self.population[int(triangular(0, iters, 0))]
            children = self.crossover(father, mother)
            children[0].mutate()

src/s/c/scrapy-HEAD/profiling/priorityqueue/run.py   scrapy(Download)
def triangular_priority(priorities):
    half = priorities // 2
    return random.triangular(-half-1, half+1, 0)
 
def uniform_priority(priorities):
    return int(random.random() * priorities) - (priorities / 2)
 

src/m/y/mysql.integra.dbfiller-HEAD/simulation.py   mysql.integra.dbfiller(Download)
import calendar
import datetime
from datetime import datetime, timedelta, date
from random import randint, gauss, triangular
import MySQLdb
from helpers.XMLparsers import *
from helpers import *
    def __addUserHasOperation (self, user, day, shift) :
        """Metoda dodająca do bazy log operacji użytkownika w ciągu jednej zmiany."""
 
        cur = self.__connection.cursor()
        # wyznaczamy czas pierwszej operacji (początek zmiany + od -30 do 60 min (rozkład trójkątny(-30, 60, 0) ) )
        latetime = timedelta(seconds=triangular(-30*60,60*60, 0) ) #czas spóznienia
        starttime = datetime(day.year, day.month, day.day, SHIFTS[shift -1][0]) + latetime

src/p/g/pgaf-HEAD/trunk/genetics/population.py   pgaf(Download)
from copy import deepcopy
from genetics.creature import creature
from genetics.gene import gene
from random import triangular
from genetics.reproduction import asex_gauss, asex_uniform, sex_gauss
 
class Population:
  def get(self):
    """Get a creature [to reproduce], weighted towards higher fitness"""
    if len(self.all) < self.pool:
      return asex_uniform(self.all[0])
 
    with self.pad:
      father = self.all[int(triangular(0, self.pool-1, 0))]

src/p/g/pgaf-HEAD/genetics/population.py   pgaf(Download)
from copy import deepcopy
from genetics.creature import creature
from genetics.gene import gene
from random import triangular
from genetics.reproduction import asex_gauss, asex_uniform, sex_gauss
 
class Population:
  def get(self):
    """Get a creature [to reproduce], weighted towards higher fitness"""
    if len(self.all) < self.pool:
      return asex_uniform(self.all[0])
 
    with self.pad:
      father = self.all[int(triangular(0, self.pool-1, 0))]

src/y/a/yann-HEAD/trunk/editor/topologyview.py   yann(Download)
 
    # Set all the connections weights except the last one
    for oConnection in self._voSelectedConnections[:-1]:
      oConnection.setWeight(random.triangular(fMin, fMax))
 
    # Now, reset the flag and set the weight of the last connection, which will trigger
    # the colors re-computation
    TopologyView._bChangingManyWeights = False
    self._voSelectedConnections[-1].setWeight(random.triangular(fMin, fMax))

src/y/a/yann-HEAD/trunk/editor/dataview.py   yann(Download)
            fMax = fOldMin
 
          for oCell in voSelectedCells:
            self._oDataModel.setData(oCell, random.triangular(fMin, fMax), Qt.DisplayRole)
 
  ## Slot called when the shuffle data action is triggered. It directly modifies the data model, so
  # that the views are automatically updated.

src/s/h/shedskin-HEAD/tests/191.py   shedskin(Download)
# random module improvements
import random
random.seed(1)
print random.triangular()
print random.triangular(high=1.1, low=0.0)
print random.triangular(0.1)
print random.triangular(-2, 2)
print random.triangular(-2.0, 2.1, 1.5)
print random.triangular(mode=1.5)
print random.triangular(0, 5, 0)