python Programming Glossary: random.seed
Multiple objects somehow interfering with each other [original version] http://stackoverflow.com/questions/12262716/multiple-objects-somehow-interfering-with-each-other-original-version math import random import itertools import numpy as np random.seed 0 def rand a b return b a random.random a def sigmoid x return.. you're using different random numbers each time. If you random.seed 0 before you call NN 2 3 1 you get exactly the same results..
Mutli-threading python with Tkinter http://stackoverflow.com/questions/14379106/mutli-threading-python-with-tkinter Queue import random import math import time import Tkinter random.seed 0 class App def __init__ self queue width 400 height 300 self.width..
Python multiprocessing: restrict number of cores used http://stackoverflow.com/questions/1575067/python-multiprocessing-restrict-number-of-cores-used i_sigma i number_of_steps sigma import random time random.seed time.time # simulation of random walk def run_sim kwargs number_of_steps..
Longest equally-spaced subsequence http://stackoverflow.com/questions/18159911/longest-equally-spaced-subsequence Input data about 100000 integers is generated this way random.seed 42 s sorted list set random.randint 0 200000 for r in xrange..
when does Python allocate new memory for identical strings? http://stackoverflow.com/questions/2123925/when-does-python-allocate-new-memory-for-identical-strings contents N 10000 exec n .join sys.argv 1 # var val ... random.seed 1 # big list of random names of states names for j in xrange..
Python import X or from X import Y? (performance) http://stackoverflow.com/questions/3591962/python-import-x-or-from-x-import-y-performance this quite well using the dis module import random def f_1 random.seed dis.dis f_1 0 LOAD_GLOBAL 0 random 3 LOAD_ATTR 0 seed 6 CALL_FUNCTION..
Is it possible to specify your own distance function using Scikits.Learn K-Means Clustering? http://stackoverflow.com/questions/5529625/is-it-possible-to-specify-your-own-distance-function-using-scikits-learn-k-means 1 threshold 200 edgeitems 5 suppress True np.random.seed seed random.seed seed print N d dim d ncluster d kmsample d.. 200 edgeitems 5 suppress True np.random.seed seed random.seed seed print N d dim d ncluster d kmsample d metric s N dim ncluster..
Python: Retrieve items from a set http://stackoverflow.com/questions/5979861/python-retrieve-items-from-a-set memory used by a set of 1 000 000 instances of this class random.seed 42 s set A for i in xrange 1000000 is on my machine 240 MB... same data in a dictionary def key_value a A return a.x a random.seed 42 d dict key_value for i in xrange 1000000 this uses 249 MB..
High quality, simple random password generator http://stackoverflow.com/questions/7479442/high-quality-simple-random-password-generator 13 chars string.ascii_letters string.digits ' @# ^ ' random.seed os.urandom 1024 print ''.join random.choice chars for i in range..
How to use timeit correctly http://stackoverflow.com/questions/8220801/how-to-use-timeit-correctly a test for sorting import timeit setup ''' import random random.seed 'slartibartfast' s random.random for i in range 1000 timsort..
|