random-seed

SQL Server random using seed

流过昼夜 提交于 2019-12-11 10:51:56
问题 I want to add a column to my table with a random number using seed. If I use RAND: select *, RAND(5) as random_id from myTable I get an equal value(0.943597390424144 for example) for all the rows, in the random_id column. I want this value to be different for every row - and that for every time I will pass it 0.5 value(for example), it would be the same values again(as seed should work...). How can I do this? ( For example, in PostrgreSql I can write SELECT setseed(0.5); SELECT t.* , random()

Non-recursive random number generator

筅森魡賤 提交于 2019-12-11 09:01:34
问题 I have searched for pseudo-RNG algorithms but all I can find seem to generate the next number by using the previous result as seed. Is there a way to generate them non-recursively? The scenario where I need this is during OpenCL concurrent programming, each thread/pixel needs an independent RNG. I tried to seed them using BIG_NUMBER + work_id , but the result has a strong visual pattern in it. I tried several different RNG algorithms and all have this problem. Apparently they only guarantee

Simple Haskell Monad - Random Number

守給你的承諾、 提交于 2019-12-11 04:09:21
问题 I'm trying to extend the code in this post (accepted answer) to allow me to be able to call randomGen2 to get a random number, based on the function randomGen which takes a seed as an argument. But everytime I call randomGen2, despite returning an Int, I get an error about not been able to print Random (when infact I am only trying to print Int). <interactive>:3:1: No instance for (Show (Random Int)) arising from a use of `print' Possible fix: add an instance declaration for (Show (Random Int

How to automatically set the random seed on current time?

给你一囗甜甜゛ 提交于 2019-12-10 21:39:21
问题 Every time one opens a R console, the random seed is set to the same value. On my computer (it might be the same on your machine), if I run rnorm(1) , I always get 0.1777571 at the first call. I tried to automatically set the random seed using the computer current time by adding something like set.seed( as.integer( as.numeric( gsub("[^0-9]","",paste(format(Sys.time(), "%Y %X %x"))) )%%.Machine$integer.max ) ) in the file .Rprofile but it does not change anything. The first call to rnorm(1)

Multiple independent random number streams from single seed

大城市里の小女人 提交于 2019-12-10 19:45:56
问题 I have n similar analyses each using m_i pseudo-random number streams ( m_i may vary between analyses). Each analysis has its own random number seed so that the random numbers are uncorrelated between analyses. My problem is that I need to create the m_i streams from the single seed. The analysis is currently written in Numpy, so solutions its Mersenne Twister are ideal, but I am open to solutions in other mature libraries. I considered these possibilities: Use the seed to create a random

In Tensorflow, is there a way to set a seed at the session level?

风格不统一 提交于 2019-12-10 19:30:43
问题 I'm trying to get repeatable results when running a session, but want to change the seed freely between sessions. Something like this: a = tf.random_uniform([1]) #Set seed here to e.g. 123 with tf.Session() as sess: print(sess.run(a)) #Output: A1 print(sess.run(a)) #Output: A2 #Set seed here to e.g. 42 with tf.Session() as sess: print(sess.run(a)) #Output: A3 print(sess.run(a)) #Output: A4 #Set seed here to e.g. 123 with tf.Session() as sess: print(sess.run(a)) #Output: A1 print(sess.run(a))

Unable to reproduce randomness with tensorflow and numpy combined?

时间秒杀一切 提交于 2019-12-10 19:18:51
问题 I have a project in which I cannot reproduce random numbers when I use numpy in combination with tensorflow. In the beginning of all my tests, I set tf.set_random_seed(seed) np.random.seed(seed) I have been debugging, and when I use numpy and no TF, all results are reproducible. When I add the TF code, the random numbers stop being reproducible. When I use both TF and numpy, I get the following results: TF variables are initialized to the same value every time (OK) When I use np.random

Always returning incorrect simple math lua

为君一笑 提交于 2019-12-10 17:42:43
问题 I have a very basic Lua script that asks a math question math.randomseed(os.time()) print ("Let's play Math") a = math.random(1,10) b = math.random(1,10) io.write("What is " .. a .. " + " .. b .. "?") answer = io.read() correct = (a + b) if (answer == correct) then print ("Correct") else print ("Wrong") print (correct) --For debug end For some reason, I am always getting "incorrect" even when answered correctly. I also print out the correct answer, just to make sure the program is handling

Why would an R package load random numbers?

扶醉桌前 提交于 2019-12-10 15:06:44
问题 Recently, I was reading the documentation for the caret package when I noticed this: Also, please note that some packages load random numbers when loaded (directly or via namespace) and this may effect [ sic ] reproducibility. What are possible use cases for packages loading random numbers? This seems to be counter to the idea of reproducible research and might interfere with my own attempts to set.seed . (I've started setting seeds closer to code that requires random number generation

How can I store the state of the pseudo-random generator in Perl?

为君一笑 提交于 2019-12-10 02:15:49
问题 Is there a way to store the current state of the built in pseudo-random number generator in Perl so that when my program is run again, it can pick up the sequence from where it left off rather than starting with a new sequence? Right now, I am storing where I am as well as the initial seed and then throwing away the initial segment which I have already seen using something similar to: sub consume_upto_n { my ($seed, $n) = @_; $n = 1 unless defined $n and $n >= 1; srand $seed; rand for 1 .. $n