logo
down
shadow

Multiple independent random number streams from single seed


Multiple independent random number streams from single seed

Content Index :

Multiple independent random number streams from single seed
Tag : python , By : Francis
Date : November 25 2020, 07:27 PM

should help you out Approach 3 can work, as the seed for any PRNG can be as long as that PRNG's state (for example, Mersenne Twister has a state length of 19968 bits, or 624 * 32 bits, so can accept a seed of up to that many bits — it's not limited to 32 or 64 bits, as is the practice with many APIs that implement Mersenne Twister). However you should use a PRNG of an unrelated design to Mersenne Twister, such as PCG, to seed that PRNG, then draw the 624-integer seed as you suggest. (Or, if you don't require reproducible results or if you will save the 624-integer seeds generated this way, you can use a cryptographic RNG, such as os.urandom() or secrets.SystemRandom, to draw those seeds instead.) My article on RNGs suggests several PRNGs with different designs.

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to generate random number using multiple seed values?


Tag : development , By : Ted Leung
Date : March 29 2020, 07:55 AM
should help you out Assuming you always need the same seed every time for the set of coordinates: just encrypt a concated string with MD5 or some other hash algorithm. md5("1,2,3") is not the same as md5("3,2,1"). Or if you need a purely numeric string, use something like: "first digit * 9" + "second digit * 8" + "third digit * 7" that will give you more variety.
If you don't, use the above methods with a random number.

Generate multiple independent random streams in python


Tag : python , By : Mario Tristan
Date : March 29 2020, 07:55 AM
This might help you Both Numpy and the internal random generators have instantiatable classes.
For just random:
import random
random_generator = random.Random()
random_generator.random()
#>>> 0.9493959884174072
import numpy
random_generator = numpy.random.RandomState()
random_generator.uniform(0, 1, 10)
#>>> array([ 0.98992857,  0.83503764,  0.00337241,  0.76597264,  0.61333436,
#>>>         0.0916262 ,  0.52129459,  0.44857548,  0.86692693,  0.21150068])

Should I use `random.seed` or `numpy.random.seed` to control random number generation in `scikit-learn`?


Tag : python , By : picamiolo
Date : March 29 2020, 07:55 AM
hope this fix your issue I'm using scikit-learn and numpy and I want to set the global seed so that my work is reproducible. ,
Should I use np.random.seed or random.seed?

Making functions that set the random seed independent


Tag : r , By : George H.
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I've dug into this some more and it looks like the rlecuyer package provides independent random streams:
library(rlecuyer)
.lec.CreateStream(c("stream.12", "stream.prod"))
sample.12 <- function(size) {
  .lec.ResetStartStream("stream.12")
  .lec.CurrentStream("stream.12")
  x <- sample(1:2, size, replace=TRUE)
  .lec.CurrentStreamEnd()
  x
}
rand.prod <- function(x) {
  .lec.ResetStartStream("stream.prod")
  .lec.CurrentStream("stream.prod")
  y <- runif(length(x)) * x
  .lec.CurrentStreamEnd()
  y
}
all.equal(rand.prod(sample.12(10000)), rand.prod(sample.12(10000)))
# [1] TRUE
x <- sample.12(10000)
hist(rand.prod(x))
.lec.GetState("stream.12")
# [1] 3161578179 1307260052 2724279262 1101690876 1009565594  836476762
.lec.GetState("stream.prod")
# [1]  596094074 2279636413 3050913596 1739649456 2368706608 3058697049
library(rlecuyer)
.lec.CreateStream(c("stream.12", "stream.prod"))
.lec.SetSeed("stream.12", c(3161578179, 1307260052, 2724279262, 1101690876, 1009565594, 836476762))
.lec.SetSeed("stream.prod", c(596094074, 2279636413, 3050913596, 1739649456, 2368706608, 3058697049))

Do consequtive RNG seed yield independent random numbers?


Tag : development , By : kokok13
Date : March 29 2020, 07:55 AM
it fixes the issue For many PRNG designs, instances initialized with sequential seeds can lead to random sequences with undesirable correlations. This is illustrated in a post on the Unity Blog. To reduce the chance of this problem, those instances should be initialized with unrelated seeds (see also "Multiple independent random number streams from single seed").
Related Posts Related QUESTIONS :
  • 7C in cs circles- python Im not sure what is wrong with this yet
  • How to fix 'AttributeError: 'list' object has no attribute 'shape'' error in python with Tensorflow / Keras when loading
  • python - thread`s target is a method of an object
  • Retrieve Variable From Class
  • What is the reason for matplotlib for printing labels multiple times?
  • Why would people use ThreadPoolExecutor instead of direct function call?
  • When clear_widgets is called, it doesnt remove screens in ScreenManager
  • Python can't import function
  • Pieces doesn't stack after one loop on my connect4
  • How to change font size of all .docx document with python-docx
  • How to store a word with # in .cfg file
  • How to append dictionaries to a dictionary?
  • How can I scrape text within paragraph tag with some other tags then within the paragraph text?
  • Custom entity ruler with SpaCy did not return a match
  • Logging with two handlers - one to file and one to stderr
  • How to do pivot_table in dask with aggfunc 'min'?
  • This for loop displays only the last entry of the student record
  • How to split a string by a specific pattern in number of characters?
  • Python 3: how to scrape research results from a website using CSFR?
  • Setting the scoring parameter of RandomizedSeachCV to r2
  • How to send alert or message from view.py to template?
  • How to add qml ScatterSeries to existing qml defined ChartView?
  • Django + tox: Apps aren't loaded yet
  • My css and images arent showing in django
  • Probability mass function sum 2 dice roll?
  • Cannot call ubuntu 'ulimit' from python subprocess without using shell option
  • Dataframe Timestamp Filter for new/repeating value
  • Problem with clicking select2 dropdownlist in selenium
  • pandas dataframe masks to write values into new column
  • How to click on item in navigation bar on top of page using selenium python?
  • Add multiple EntityRuler with spaCy (ValueError: 'entity_ruler' already exists in pipeline)
  • error when replacing missing ')' using negative look ahead regex in python
  • Is there a way to remove specific strings from indexes using a for loop?
  • select multiple tags by position in beautifulSoup
  • pytest: getting AttributeError: 'CaptureFixture' object has no attribute 'readouterror' capturing stdout
  • Shipping PyGObject/GTK+ app on Windows with MingW
  • Python script to deduplicate lines in multiple files
  • How to prevent window and widgets in a pyqt5 application from changing size when the visibility of one widget is altered
  • How to draw stacked bar plot from df.groupby('feature')['label'].value_counts()
  • Python subprocess doesn't work without sleep
  • How can I adjust 'the time' in python with module Re
  • Join original np array with resulting np array in a form of dictionary? multidimensional array? etc?
  • Forcing labels on histograms in each individual graph in a figure
  • For an infinite dataset, is the data used in each epoch the same?
  • Is there a more efficent way to extend a string?
  • How to calculate each single element of a numpy array based on conditions
  • How do I change the width of Jupyter notebook's cell's left part?
  • Measure distance between lat/lon coordinates and utm coordinates
  • Installing megam for NLTK on Windows
  • filter dataframe on each value of a samn column have a specific value of another column in Panda\Python
  • Threading with pubsub throwing AssertionError: 'callableObj is not callable' in wxPython
  • Get grouped data from 2 dataframes with condition
  • How can I import all of sklearns regressors
  • How to take all elements except the first k
  • Whats wrong with my iteration list of lists from csv
  • Tensorflow Estimator API save image summary in eval mode
  • How to Pack with PyQt - how to make QFrame/Layout adapt to content
  • How do I get certain Time Range in Python
  • python doubly linked list - insertAfter node
  • Open .h5 file in Python
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com