All Samples(550) | Call(514) | Derive(0) | Import(36)
Gaussian distribution. mu is the mean, and sigma is the standard deviation. This is slightly faster than the normalvariate() function. Not thread-safe without a lock around calls.
src/g/r/grease-0.2/examples/blasteroids3.py grease(Download)
debris.shape.verts = segment
debris.position.position = self.position.position
debris.movement.velocity = self.movement.velocity
debris.movement.velocity += segment[0].normalized() * random.gauss(50, 20)
debris.movement.rotation = random.gauss(0, 45)
debris.renderable.color = self.renderable.color
random.choice([-1, 1]) * random.randint(50, window.height / 2))
else:
self.position.position = position
self.movement.velocity = (random.gauss(0, 700 / radius), random.gauss(0, 700 / radius))
if parent_velocity is not None:
self.movement.velocity += parent_velocity
self.movement.rotation = random.gauss(0, 15)
verts = [(random.gauss(x*radius, radius / 7), random.gauss(y*radius, radius / 7))
src/g/r/grease-0.2/examples/blasteroids2.py grease(Download)
debris.shape.verts = segment
debris.position.position = self.position.position
debris.movement.velocity = self.movement.velocity
debris.movement.velocity += segment[0].normalized() * random.gauss(50, 20)
debris.movement.rotation = random.gauss(0, 45)
debris.renderable.color = self.renderable.color
def __init__(self, world, radius=45):
self.position.position = (
random.choice([-1, 1]) * random.randint(50, window.width / 2),
random.choice([-1, 1]) * random.randint(50, window.height / 2))
self.movement.velocity = (random.gauss(0, 700 / radius), random.gauss(0, 700 / radius))
self.movement.rotation = random.gauss(0, 15)
verts = [(random.gauss(x * radius, radius / 7), random.gauss(y * radius, radius / 7))
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 *
position=(uniform(-50, 50), uniform(-30, 30), uniform(-30, 30)), color=color), deviation=Particle( velocity=(gauss(0, 5), gauss(0, 5), gauss(0, 5)), age=1.5), velocity=domain.Sphere((0, gauss(40, 20), 0), 60, 60))
ColorBlender([(0, (1,1,1,1)), (2, color), (self.lifetime, color)]), Fader(fade_out_start=1.0, fade_out_end=self.lifetime * 0.5), ], renderer=PointRenderer(abs(gauss(10, 3)), spark_texturizer)) spark_emitter.emit(int(gauss(60, 40)) + 50, self.sparks) spread = abs(gauss(0.4, 1.0))
Lifetime(self.lifetime * 1.5), Movement(damping=0.83), ColorBlender([(0, (1,1,1,1)), (1, color), (self.lifetime, color)]), Fader(max_alpha=0.75, fade_out_start=0, fade_out_end=gauss(self.lifetime, self.lifetime*0.3)), self.trail_emitter ], renderer=PointRenderer(10, trail_texturizer))
src/g/r/grease-0.2/examples/blasteroids1.py grease(Download)
def __init__(self, world, radius=45):
self.position.position = (
random.choice([-1, 1]) * random.randint(50, window.width / 2),
random.choice([-1, 1]) * random.randint(50, window.height / 2))
self.movement.velocity = (random.gauss(0, 700 / radius), random.gauss(0, 700 / radius))
self.movement.rotation = random.gauss(0, 15)
verts = [(random.gauss(x * radius, radius / 7), random.gauss(y * radius, radius / 7))
src/a/t/atma-HEAD/trunk/examples/basics/root/samplejson.py atma(Download)
a = dict()
a['alpha'] = random.random()
a['bravo'] = random.gauss(1,1)
a['charlie'] = random.sample(range(30),random.randint(10,20))
return pprint.pformat(a)
src/a/t/atma-HEAD/examples/basics/root/samplejson.py atma(Download)
a = dict()
a['alpha'] = random.random()
a['bravo'] = random.gauss(1,1)
a['charlie'] = random.sample(range(30),random.randint(10,20))
return pprint.pformat(a)
src/v/i/vispa-HEAD/vispa/trunk/examples/AnalysisDesigner/withROOT/smear_script.py vispa(Download)
name=particle.getName()
(pt,eta,phi,m)=(particle.getPt(),particle.getEta(),particle.getPhi(),particle.getMass())
if name in rel_resolutions_pt.keys():
pt*=random.gauss(1,rel_resolutions_pt[name])
if name in rel_resolutions_eta.keys():
eta*=random.gauss(1,rel_resolutions_eta[name])
if name in rel_resolutions_eta.keys():
phi*=random.gauss(1,rel_resolutions_phi[name])
src/b/r/brian-HEAD/trunk/examples/misc/pulsepacket.py brian(Download)
'''
This example basically replicates what the Brian PulsePacket object does,
and then compares to that object.
'''
from brian import *
from random import gauss, shuffle
# Generator for pulse packet
def pulse_packet(t, n, sigma):
# generate a list of n times with Gaussian distribution, sort them in time, and
# then randomly assign the neuron numbers to them
times = [gauss(t, sigma) for i in range(n)]
src/b/r/brian-HEAD/examples/misc/pulsepacket.py brian(Download)
'''
This example basically replicates what the Brian PulsePacket object does,
and then compares to that object.
'''
from brian import *
from random import gauss, shuffle
# Generator for pulse packet
def pulse_packet(t, n, sigma):
# generate a list of n times with Gaussian distribution, sort them in time, and
# then randomly assign the neuron numbers to them
times = [gauss(t, sigma) for i in range(n)]
src/l/a/Langtangen-HEAD/src/py/examples/efficiency/pyefficiency.py Langtangen(Download)
def list_append3(n):
import random
r = []
for i in xrange(n):
r.append(random.gauss(0,1))
return r
def list_chunk2(n):
import random
r = [0.0]*n
for i in xrange(n):
r[i] = random.gauss(0,1)
def list_append5(n):
import random
return [random.gauss(0,1) for i in xrange(n)]
def list_chunk3(n):
import random
g = random.gauss
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next