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

All Samples(2674)  |  Call(2571)  |  Derive(0)  |  Import(103)
Get a random number in the range [a, b) or [a, b] depending on rounding.

src/l/e/lepton-1.0b2/examples/fireworks.py   lepton(Download)
 
import os
import math
from random import expovariate, uniform, gauss
from pyglet import image
from pyglet.gl import *
 
	def __init__(self):
		color=(uniform(0,1), uniform(0,1), uniform(0,1), 1)
		while max(color[:3]) < 0.9:
			color=(uniform(0,1), uniform(0,1), uniform(0,1), 1)
 
		spark_emitter = StaticEmitter(
			template=Particle(
				position=(uniform(-50, 50), uniform(-30, 30), uniform(-30, 30)), 
		spark_emitter.emit(int(gauss(60, 40)) + 50, self.sparks)
 
		spread = abs(gauss(0.4, 1.0))
		self.trail_emitter = PerParticleEmitter(self.sparks, rate=uniform(5,30),
			template=Particle(
				color=color),
			deviation=Particle(

src/p/y/PyMT-0.5.1/examples/games/bloop/bloop.py   PyMT(Download)
    def generateBloop(self,dt):
        self.num_bloops = self.num_bloops + 1
        self.redpt = random.uniform(0, 1)
        self.greenpt = random.uniform(0, 1)
        self.bluept = random.uniform(0, 1)
        self.x = int(random.uniform(100, w.width-100))
        self.y = int(random.uniform(100, w.height-100))

src/p/y/pyobjc-framework-Quartz-2.3/Examples/PathDemo/DemoView.py   pyobjc-framework-Quartz(Download)
def setRandomFillColor(context):
    CGContextSetRGBFillColor(context, 
           random.uniform(0, 1), random.uniform(0, 1),
           random.uniform(0, 1), random.uniform(0, 1))
 
def setRandomStrokeColor(context):
    CGContextSetRGBStrokeColor(context, 
           random.uniform(0, 1), random.uniform(0, 1),
           random.uniform(0, 1), random.uniform(0, 1))
 
 
def randomPointInRect(rect):
    return CGPoint(
        x = random.uniform(CGRectGetMinX(rect), CGRectGetMaxX(rect)),
def randomPointInRect(rect):
    return CGPoint(
        x = random.uniform(CGRectGetMinX(rect), CGRectGetMaxX(rect)),
        y = random.uniform(CGRectGetMinY(rect), CGRectGetMaxY(rect)))
 
def randomRectInRect(rect):
    p = randomPointInRect(rect)

src/p/e/peyote-HEAD/examples/substrate.py   peyote(Download)
        a = Substrate.cgrid[seed]
 
        if random.randrange(100) < 50:
            a = a - (90 + int(random.uniform(-2.0,2.1)))
        else:
            a = a + (90 + int(random.uniform(-2.0,2.1)))
        self.startCrack(seed[1],seed[0],a)
        self.x += 0.42*cos(self.t*pi/180.0)
        self.y += 0.42*sin(self.t*pi/180.0)
        z = 0.33
        cx = int(self.x+random.uniform(-z,z))
        cy = int(self.y+random.uniform(-z,z))
 
        self.regionColor()
    def __init__(self):
        global Substrate
 
        self.c = pygame.Color(*random.choice(Substrate.goodcolor))
        self.c_int = map_rgb(self.c)
        self.g = random.uniform(0.01,0.1)
 
    def render(self, x, y, ox, oy):
        global Substrate
 
        self.g += random.uniform(-0.050,0.050)

src/t/i/timba-HEAD/Waterhole/contrib/OMS/doc/TDL_Companion/Scripts/ME2/example10-tracking.py   timba(Download)
  # create nodes to compute tracking errors per antenna
  for p in array.stations():
    # pick random periods of dl/dm variation, in seconds
    dlp = random.uniform(min_tr_period*3600,max_tr_period*3600);
    dmp = random.uniform(min_tr_period*3600,max_tr_period*3600);
    # pick a random starting phase for the variations
    dlp_0 = random.uniform(0,2*math.pi); 
    dmp_0 = random.uniform(0,2*math.pi);

src/p/y/PyMT-0.5.1/examples/apps/particles/particles.py   PyMT(Download)
    def random_color(self):
        r_min, r_max = map(lambda x: x/255., self.settings.color_r)
        g_min, g_max = map(lambda x: x/255., self.settings.color_g)
        b_min, b_max = map(lambda x: x/255., self.settings.color_b)
        self.color      = [random.uniform(r_min, r_max),
                           random.uniform(g_min, g_max),
                           random.uniform(b_min, b_max),

src/c/o/coopr.pysp-2.3/examples/pysp/lotsizing/generator/generate_instance.py   coopr.pysp(Download)
      new_tree_node.number_in_stage = i
 
      if t == 1:
         new_tree_node.initial_inventory = random.uniform(initial_inventory_lower_bound, initial_inventory_upper_bound)
 
      new_tree_node.setup_cost = random.uniform(setup_cost_lower_bound, setup_cost_upper_bound)
      new_tree_node.holding_cost = random.uniform(holding_cost_lower_bound, holding_cost_upper_bound)
      new_tree_node.shortage_cost = random.uniform(shortage_cost_lower_bound, shortage_cost_upper_bound)
      new_tree_node.demand = random.uniform(demand_lower_bound, demand_upper_bound)

src/p/y/python-visual-HEAD/examples/planar.py   python-visual(Download)
from visual import *
from random import uniform, randint
 
scene.forward = (-0.25,-0.25,-1)
 
nboxes = 8
nlinks = 16
for t in arange(-pi,pi,2*pi/nboxes):
  b = cylinder( pos=(10*sin(t),0,10*cos(t)) )
  b.color = b.icolor = (0.5,0.5,1)
  height = uniform(0.5,4)
  b.axis = (0,height,0)
  nodes.append( b )
 
  j = randint(0,nboxes-1)
  c = curve( ends=[nodes[i].pos,nodes[j].pos], radius=0.2 )
  c.red = 0
  c.green = uniform(0.3,1)
  c.blue = 0
  c.pos = c.ends
  links.append(c)

src/k/h/khronos-des-HEAD/khronos/examples/broken/animation.py   khronos-des(Download)
from khronos.components import Process
from khronos.primitives import Chain
from khronos.engine import Simulator
from khronos.extra.animation import Animator, Object2D, shape
from math import pi
from random import uniform
 
        self.shape["body"].props.fill = color
        self.scale = scale
 
sim = Simulator(members=[CrazyCar("blue", uniform(0.25, 4.0)), 
                         CrazyCar("darkgreen", uniform(0.25, 4.0)), 
                         CrazyCar("black", uniform(0.25, 4.0)), 
                         CrazyAnt("red", uniform(0.25, 4.0)), 
                         CrazyAnt("green", uniform(0.25, 4.0)), 
                         CrazyAnt("yellow", uniform(0.25, 4.0)), 
                         CrazyAnt("pink", uniform(0.25, 4.0))])

src/s/h/shedskin-HEAD/examples/dijkstra.py   shedskin(Download)
                v = V[random.randint(0, len(V) - 1)]
                if v is not u:
                    break
            E.append(Edge(u, v, random.uniform(10, 100)))
 
        self.V = V
        self.E = E

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next