random-seed

How to generate uniformly distributed random numbers between 0 and 1 in a C code using OpenMP?

白昼怎懂夜的黑 提交于 2020-04-16 05:47:10
问题 I am trying to write an OpenMP code in which each thread will work on big arrays of uniformly distributed random numbers between 0 and 1. Each thread needs to have different and independent random number distributions. In addition, the random number distributions need to be different every time the code is called. This is what I am using right now. Does this always guarantee each thread has its own/different random number sequences? Will the sequences be different every time the code is

Making functions that set the random seed independent

半腔热情 提交于 2020-01-22 13:36:26
问题 Sometimes I want to write a randomized function that always returns the same output for a particular input. I've always implemented this by setting the random seed at the top of the function and then proceeding. Consider two functions defined in this way: sample.12 <- function(size) { set.seed(144) sample(1:2, size, replace=TRUE) } rand.prod <- function(x) { set.seed(144) runif(length(x)) * x } sample.12 returns a vector of the specified size randomly sampled from the set {1, 2} and rand.prod

Making functions that set the random seed independent

最后都变了- 提交于 2020-01-22 13:35:27
问题 Sometimes I want to write a randomized function that always returns the same output for a particular input. I've always implemented this by setting the random seed at the top of the function and then proceeding. Consider two functions defined in this way: sample.12 <- function(size) { set.seed(144) sample(1:2, size, replace=TRUE) } rand.prod <- function(x) { set.seed(144) runif(length(x)) * x } sample.12 returns a vector of the specified size randomly sampled from the set {1, 2} and rand.prod

Random Seed in PIC18F

我是研究僧i 提交于 2020-01-04 15:17:28
问题 I'm going to run modified DES code(C language) on the PIC18F2550 microcontroller. For this I am using mplabx IDE v 2 and Mplab xc8 v 1.30. To modify the code, I need a random number so that each run will produce different numbers. I want to use the rand function but I need a good seed for Srand function! Good seed can be time, but since there is no such thing as a micro or I do not know!! 回答1: You can store an integer value in EEPROM. When the device boots, you use it as a seed and then

Python: where is random.random() seeded?

天大地大妈咪最大 提交于 2019-12-30 21:08:00
问题 Say I have some python code: import random r=random.random() Where is the value of r seeded from in general? And what if my OS has no random, then where is it seeded? Why isn't this recommended for cryptography? Is there some way to know what the random number is? 回答1: Follow da code . To see where the random module "lives" in your system, you can just do in a terminal: >>> import random >>> random.__file__ '/usr/lib/python2.7/random.pyc' That gives you the path to the .pyc ("compiled") file,

Python: where is random.random() seeded?

自作多情 提交于 2019-12-30 21:07:55
问题 Say I have some python code: import random r=random.random() Where is the value of r seeded from in general? And what if my OS has no random, then where is it seeded? Why isn't this recommended for cryptography? Is there some way to know what the random number is? 回答1: Follow da code . To see where the random module "lives" in your system, you can just do in a terminal: >>> import random >>> random.__file__ '/usr/lib/python2.7/random.pyc' That gives you the path to the .pyc ("compiled") file,

Best practices for seeding random and numpy.random in the same program

廉价感情. 提交于 2019-12-24 03:45:05
问题 In order to make random simulations we run reproducible later, my colleagues and I often explicitly seed the random or numpy.random modules' random number generators using the random.seed and np.random.seed methods. Seeding with an arbitrary constant like 42 is fine if we're just using one of those modules in a program, but sometimes, we use both random and np.random in the same program. I'm unsure whether there are any best practices I should be following about how to seed the two RNGs

C# - Random number with seed

半世苍凉 提交于 2019-12-23 15:17:13
问题 I have this code: var rand = new Random(0); for(int i = 0; i < 100; i++) { Console.WriteLine(rand.Next(0, 100)); } And program should give me 100 times the same number (because seed is the same), but it gives different numbers... Why? Edit: When I will do for(int i = 0; i < 100; i++) { Console.WriteLine(new Random(0).Next); } That returns the same number every time. That means, seed is changing? If yes, how? Is it increasing? 回答1: It should not give you 100 same numbers but it should give you

R: set.seed() results don't match if caret package loaded

大城市里の小女人 提交于 2019-12-23 09:38:33
问题 I am using createFolds() in R (version: 3.3.0) to create train/test partitions. To make results reproducible, I used set.seed() with a seed value of 10. As expected, the results (generated folds) were reproducible. But once I loaded caret package just after setting the seed. And then used the createFolds function, I found that the created folds were different (although still reproducible). Specifically, the created folds differ in the following two cases: Case 1: library(caret) set.seed(10)

How to cancel the effect of numpy seed()?

孤街浪徒 提交于 2019-12-22 09:41:33
问题 I would like to use np.random.seed() in the first part of my program and cancel it in the second part. Again, in the first part of my python file, I want the same random numbers to be generated at each execution in the second part , I want different random numbers to be generated at each execution 回答1: In the first part initialize the seed with a constant, e.g. 0: numpy.random.seed(0) In the second part initialize the seed with time: import time t = 1000 * time.time() # current time in