pseudo-random-numbers

Improve "resolution" of random data

I've been working on an MPD front end in Ruby, with the ability to play a random album. album = all[(rand*all.length).floor] Where all is an array of the names of all albums in the library, chooses the album to play. This works, however, I find it plays some albums more than others, and sometimes very obviously (I've seen it play the...

How can I fairly choose an item from a list?

Let's say that I have a list of prizes: PrizeA PrizeB PrizeC And, for each of them, I want to draw a winner from a list of my attendees. Give that my attendee list is as follows: user1, user2, user3, user4, user5 What is an unbiased way to choose a user from that list? Clearly, I will be using a cryptographically secure pseudo-rand...

Pseudorandom seed methodology for lookup tables

Could someone please suggest a good way of taking a global seed value e.g. "Hello World" and using that value to lookup values in arrays or tables. I'm sort of thinking like that classic spacefaring game of "Elite" where there were different attributes for the planets but they were not random, simply derived from the seed value for the ...

C++: why is (rand() % anything) always 0

I am having trouble getting rand() to work in C++. rand() normally gives me a very large number. When I try to use the modulo operator (%) to give it a range, it always returns 0, no matter what. Seeding the random number generator at the beginning of the program doesn't help either. ...

Binomial Random Variate Generator on CUDA

Hello, My problem is the following: I need to generate lot of random numbers in parallel using Binomial Distribution on CUDA. All the Random Number Generators on CUDA are based on the Uniform Distribution (as far I know), what is also useful since all the algorithms for Binomial Distribution needs to use Uniform variates. Is there any...

Is it possible to get an appriximtion to a seed based on a finite sequance of pseudo random numbers?

suppose I have some numbers that form a series for example : 652,328,1,254 and I want to get a seed that if I ,for example ,do srand(my_seed); I will get some kind of approximation with bounded error to my origonal sequance , when all numbers appearing in the same order. thanks, Alex ...

C#/Java Number Randomization

Is it possible, from .NET, to mimic the exact randomization that Java uses? I have a seed, and I would like to be able to recieve the same results in both C# and Java when creating a random number. ...

Algorithm to generate unique (possibly auto incremented) ids

I need to generate unique ids for my application and I am looking for suitable algorithms. I would prefer something like this -- YYYY + MM + DD + HH + MM + SS + <random salt> + <something derived from the preceding values> F.ex. - 20100128184544ewbhk4h3b45fdg544 I was thinking about using SHA-256 or something but the resultant string...

Distributed computing with different random number generators

I have a computation/simulation system with one master server and (potentially) many clients (workers). All of them are working with the same data but need random numbers for the computation. What would be the best PRNG and the best way to seed it to make sure that two clients aren't using the same cycle and computing the same results t...

Stable/repeatable random sort (MySQL, Rails)

I'd like to paginate through a randomly sorted list of ActiveRecord models (rows from MySQL database). However, this randomization needs to persist on a per-session basis, so that other people that visit the website also receive a random, paginate-able list of records. Let's say there are enough entities (tens of thousands) that storin...

C: Random Number Generation - What (If Anything) Is Wrong With This

For a simple simulation in C, I need to generate exponential random variables. I remember reading somewhere (but I can't find it now, and I don't remember why) that using the rand() function to generate random integers in a fixed range would generate non-uniformly distributed integers. Because of this, I'm wondering if this code might ha...

Pseudo random numbers in php

I have a function that outputs items in a different order depending on a random number. for example 1/2 of the time Popeye's and its will be #1 on the list and Taco Bell and its logo will be #2 and half the time \it will be the other way around. The problem is that when a user reloads or comes back to the page, the order is re-random...

RANDOM Number Generation in C

Recently i have begun development of a simple game. It is improved version of an earlier version that i had developed. Large part of the game's success depends on Random number generation in different modes: MODE1 - Truly Random mode myRand(min,max,mode=1); Should return me a random integer b/w min & max. MODE2 - Pseudo...

Biased Random Number Generator

I am looking for a random number generator that can be biased. For instance, say I want a random number between 1-5, with the probability being: 1: Comes up 20% of the time 2: Comes up 10% of the time 3: Comes up 40% of the time 4: Comes up 25% of the time 5: Comes up 5% of the time Is there anything in the standard library, or other...

PHP Game weapon accuracy

I'm trying to come up with a way for players to fire their weapons and only hit for a certain percentage. For example, one gun can only hit 70% of the time while another only hits 34% of the time. So far all I could come up with is weighted arrays. Attempt 1: private function weighted_random(&$weight) { $weights = array(($...

Computationally simple Pseudo-Gaussian Distribution with varying mean and standard deviation?

This picture from wikipedia has a nice example of the sort of functions I'd ideally like to generate http://en.wikipedia.org/wiki/File:Normal_Distribution_PDF.svg Right now I'm using the Irwin-Hall Distribution, which is more or less a Polynomial approximation of the Gaussian distribution...basically, you use uniform random number gene...

Alternate sources of randomness in ActionScript 2.0

I write a piece of software that runs inside banner ads which generates millions of session IDs every day. For a long time I've known that the random number generator in Flash is't random enough to generate sufficiently unique IDs, so I've employed a number of tricks to get even more random numbers. However, in ActionScript 2.0 it's not ...

Initializing a C++ vector to random values... fast

Hey, id like to make this as fast as possible because it gets called A LOT in a program i'm writing, so is there any faster way to initialize a C++ vector to random values than: double range;//set to the range of a particular function i want to evaluate. std::vector<double> x(30, 0.0); for (int i=0;i<x.size();i++) { x.at(i) = (rand(...

Is this a correct porting of java.util.Random in objectiveC

I have ported the code inside java.util.Random class in objectivec. I want to have an identical random number generator so that it synchs with the server app running on java. Now is this a safe porting and if not is there a way to mimic AtomicLong as it is found in java? Please see my code below. static long long multiplier = 0x5DEECE...

Reversible pseudo-random sequence generator

I would like some sort of method to create a fairly long sequence of random numbers that I can flip through backwards and forwards. Like a machine with "next" and "previous" buttons, that will give you random numbers. Something like 10-bit resolution (i.e. positive integers in a range from 0 to 1023) is enough, and a sequence of >100k ...