pseudo-random-numbers

Random numbers

While thinking about this question and conversing with the participants, the idea came up that shuffling a finite set of clearly biased random numbers makes them random because you don't know the order in which they were chosen. Is this true and if so can someone point to some resources? EDIT: I thnk I might have been a little uncle...

Pseudo-random number generator

What is the best way to create the best pseudo-random number generator? (any language works) ...

Psuedo-Random-Number-Generator from a computable normal number

Isn't it easily possible to construct a PRNG in such a fashion? Why is it not done? That is, as far as I know we could simply have a PRNG that takes a seed n. When you ask for a random bit, it takes the nth digit of the binary expansion of the computable normal number, and increments n. My first thought was that perhaps we hadn't found...

Deterministic Random Number Streams in C++ STL

I want to supply a number, and then receive a set of random numbers. However, I want those numbers to be the same regardless of which computer I run it on (assuming I supply the same seed). Basically my question is: in C++, if I make use of rand(), but supply srand() with a user-defined seed rather than the current time, will I be able...

Convert sequence of numbers to random-looking IDs?

I'm working on an application where I need to generate unique, non-sequential IDs. One of the constraints I have is that they must consist of 3 digits followed by 2 letters (only about 600k IDs). Given my relatively small pool of IDs I was considering simply generating all possible IDs, shuffling them and putting them into a database. ...

Random number generator that produces a power-law distribution?

I'm writing some tests for a C++ command line Linux app. I'd like to generate a bunch of integers with a power-law/long-tail distribution. Meaning, I get a some numbers very frequently but most of them relatively infrequently. Ideally there would just be some magic equations I could use with rand() or one of the stdlib random functi...

Evenly distributed random numbers relatively prime to 2

A specific example I need to generate a random number between 0 and 2, inclusive. (or choose randomly between -1, 0, and 1). The naive approach would be to do something like rand() mod 3 where rand() returns an integer. This approach will not generate statistically random numbers unless the upper bound of rand() is not relatively prim...

How random is JavaScript's Math.random?

For 6 years I've had a random number generator page on my website. For a long time, it was the first or second result on Google for "random number generator" and has been used to decide dozens, if not hundreds of contests and drawings on discussion forums and blogs (I know because I see the referrers in my web logs and usually go take a ...

Seeding random in django

In a view in django I use random.random(). How often do I have to call random.seed()? One time for every request? One time for every season? One time while the webserver is running? ...

C# Mersenne Twister random integer generator implementation (SFMT) monte carlo simulation

So far I've been using the C# Mersenne Twister found here to generate random numbers: http://www.centerspace.net/resources.php I just discovered SFMT which is supposed to be twice as fast here: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/ Can anyone point me at a C# implementation of SFMT? My requirements are to generate an...

Intel Math Kernel on windows, calling from c# for random number generation

Has anyone used the Intel Math Kernel library http://software.intel.com/en-us/intel-mkl/ I am thinking of using this for Random Number generation from a C# application as we need extreme performance (1.6 trillion random numbers per day). Also any advice on minimising the overhead of consuming functions from this c++ code in my c# Monte...

Pseudorandom number generator for noise

I'm trying to make the Perlin noise algorithm described at http://freespace.virgin.net/hugo.elias/models/m_perlin.htm using Lua. However, it doesn't work properly since Lua doesn't support bitwise operators, which are necessary for the pseudorandom number function on that page. I tried messing around with randomseed() but everything I co...

How deterministic Are .Net GUIDs ?

Yesterday I asked Are GUIDs generated on Windows 2003 safe to use as session IDs? and the answer combined with combined with this article GUIDs are globally unique, but substrings of GUIDs aren't prompted me to think about replacing my current mechanism of using GUIDs as session ID's in cookies. Because it's a bit of work to make that c...

Generating a random seed in PHP for consumption by Flash

I'm working on a project with remote Flash developers, and they have requested that when my PHP application sets up the HTML to load their Flash object, I pass in a seed that they can use to generate random numbers with (the seed is stored so that a particular game can be replayed later). If you were seeding PHP's RNG, you might use the...

Simple Pseudo-Random Algorithm

I'm need a pseudo-random generator which takes a number as input and returns another number witch is reproducible and seems to be random. Each input number should match to exactly one output number and vice versa same input numbers always result in same output numbers sequential input numbers that are close together (eg. 1 and 2) shoul...

How different do random seeds need to be?

Consider code like this (Python): import random for i in [1, 2, 3, 4]: random.seed(i) randNumbers = [random.rand() for i in range(100)] # initialize a list with 100 random numbers doStuff(randNumbers) I want to make sure that randNumbers differ significantly from one call to another. Do I need to make sure the seed number...

Why would rand() return a negative value when min and max values are positive?

Hi, I have a simple piece of PHP code which requires a random number to be created. However, even though the input is always positive, it sometimes returns a negative output. Here's my debug code: $debt = rand($this->gdp * 0.02, $this->gdp * 0.17); echo "<p>GDP: ".$this->gdp." rand(".$this->gdp * 0.02." , ".$this->gdp * 0.17.") = <st...

Generating random numbers from -n to n in C

I want to generate random numbers from -n to n excluding 0. Can someone provide me the code in C? How to exclude 0? ...

c++: what exactly does &rand do?

This is an excerpt of some c++ code, that i'll have to explain in detail in some days: std::vector<int> vct(8, 5); std::generate(vct.begin(), vct.end(), &rand); std::copy(vct.rbegin(), vct.rend(), std::ostream_iterator<int>(std::cout, "\n")); i think i understand everything about it, except that tiny mystical &rand. what exactly...

Verify Knuth shuffle algorithm is as unbiased as possible

I'm implementing a Knuth shuffle for a C++ project I'm working on. I'm trying to get the most unbiased results from my shuffle (and I'm not an expert on (pseudo)random number generation). I just want to make sure this is the most unbiased shuffle implementation. draw_t is a byte type (typedef'd to unsigned char). items is the count of i...