random

Best seed for parallel process

偶尔善良 提交于 2020-01-03 16:45:34
问题 I need to run a MonteCarlo simulations in parallel on different machines. The code is in c++, but the program is set up and launched with a python script that set a lot of things, in particular the random seed. The function setseed thake a 4 bytes unsigned integer Using a simple import time setseed(int(time.time())) is not very good because I submit the jobs to a queue on a cluster, they remain pending for some minutes then they starts, but the start time is impredicible, it can be that two

What is the proper way of seeding std::mt19937 with std::chrono::high_resolution_clock inside a class?

戏子无情 提交于 2020-01-03 15:39:49
问题 First off, hello everyone! This is my first ever question here, so I hope I am not screwing up. I googled a lot before writing here. I am new to coding, to c++ and I am learning it on my own. Considering that I was told that it is a good practice (i'm probably wrong here) to only seed any Random Engine once, what is the proper / best / more efficient way of using std::mt19937 from the random standard library inside a class, seeded by std::chrono::high_resolution_clock::now().time_since_epoch(

What is the proper way of seeding std::mt19937 with std::chrono::high_resolution_clock inside a class?

◇◆丶佛笑我妖孽 提交于 2020-01-03 15:38:09
问题 First off, hello everyone! This is my first ever question here, so I hope I am not screwing up. I googled a lot before writing here. I am new to coding, to c++ and I am learning it on my own. Considering that I was told that it is a good practice (i'm probably wrong here) to only seed any Random Engine once, what is the proper / best / more efficient way of using std::mt19937 from the random standard library inside a class, seeded by std::chrono::high_resolution_clock::now().time_since_epoch(

add exact proportion of random missing values to data.frame

二次信任 提交于 2020-01-03 14:17:09
问题 I would like to add random NA to a data.frame in R. So far I've looked into these questions: R: Randomly insert NAs into dataframe proportionaly How do I add random NAs into a data frame add random missing values to a complete data frame (in R) Many solutions were provided here, but I couldn't find one that comply with these 5 conditions: Add really random NA, and not the same amount by row or by column Work with every class of variable that one can encounter in a data.frame (numeric,

How do I use random numbers in C#?

半世苍凉 提交于 2020-01-03 14:11:18
问题 I'm working on Pong in C# w/ XNA. I want to use a random number (within a range) to determine things such as whether or not the ball rebounds straight, or at an angle, and how fast the ball moves when it hits a paddle. I want to know how to implement it. 回答1: Use the Random class. For example: Random r = new Random(); int nextValue = r.Next(0, 100); // Returns a random number from 0-99 回答2: Unless you need cryptographically secure numbers, Random should be fine for you... but there are two

How do I use random numbers in C#?

限于喜欢 提交于 2020-01-03 14:11:02
问题 I'm working on Pong in C# w/ XNA. I want to use a random number (within a range) to determine things such as whether or not the ball rebounds straight, or at an angle, and how fast the ball moves when it hits a paddle. I want to know how to implement it. 回答1: Use the Random class. For example: Random r = new Random(); int nextValue = r.Next(0, 100); // Returns a random number from 0-99 回答2: Unless you need cryptographically secure numbers, Random should be fine for you... but there are two

cherrypy /dev/urandom (or equivalent) not found — error

本小妞迷上赌 提交于 2020-01-03 13:51:04
问题 I am running a cherrypy 3.2.0 server with Python 2.5.1, which gives the following error every few days on any instruction from UI until it is killed and re-started:- [29/Mar/2012:06:37:57] HTTP Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/CherryPy-3.2.0-py2.5.egg/cherrypy/_cprequest.py", line 636, in respond File "/usr/lib/python2.5/site-packages/CherryPy-3.2.0-py2.5.egg/cherrypy/_cprequest.py", line 97, in run File "/usr/lib/python2.5/site-packages/CherryPy-3.2.0

cherrypy /dev/urandom (or equivalent) not found — error

北慕城南 提交于 2020-01-03 13:51:02
问题 I am running a cherrypy 3.2.0 server with Python 2.5.1, which gives the following error every few days on any instruction from UI until it is killed and re-started:- [29/Mar/2012:06:37:57] HTTP Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/CherryPy-3.2.0-py2.5.egg/cherrypy/_cprequest.py", line 636, in respond File "/usr/lib/python2.5/site-packages/CherryPy-3.2.0-py2.5.egg/cherrypy/_cprequest.py", line 97, in run File "/usr/lib/python2.5/site-packages/CherryPy-3.2.0

Random numbers between 1 and 15

一个人想着一个人 提交于 2020-01-03 13:39:18
问题 I generate many many random numbers that need to be between 1 and 15 (included) in C++. Of course, I can generate zillons of std::uniform_int_distribution<std::mt19937::result_type> random(1, 15); but this is a waste since this mersenn twister generates 32 bits (or even 64 using mt19937_64) of random values, and I would only keep 4 bits and throw away all the rest, and in my case, performance is an issue and random number generation is a significant contributor. My idea was thus to generate

Math#random ain't so random?

為{幸葍}努か 提交于 2020-01-03 13:34:31
问题 I am finding something odd happening with my program. This program basically is used for component clicking, as it is a concept to test randomness. As you can see, it is printing correctly, as it should have a tendency to click towards the middle, which is does perfect. Problem is, it seems biased. import java.applet.Applet; import java.awt.Point; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.awt