random-number-generator

Generating totally random numbers without random function?

Possible Duplicate: True random number generator I was talking to a friend the other day and we were trying to figure out if it is possible to generate completely random numbers without the help of a random function? In C for example "rand" generates pseudo-random numbers. Or we can use something like "srand( time( NULL ) );...

Generating a random sequence with no repeats

Hi, I read a couple of posts here about generating random sequence without repeats (for example http://stackoverflow.com/questions/693880/create-random-number-sequence-with-no-repeats) and decided to implement it for my own need Actually it was an algorithm applying some non-destructive (reversible) operations with the bits of the cur...

Random number always generates 1 number.

//Generate Food Personality for(i=0; i<food.size(); i++) { srand(time(0)); int randomFood = rand() % 6; if(randomFood == 1 || randomFood == 3 || randomFood == 5) { badFood.push_back(food[randomFood]); } else if(randomFood == 0 || randomFood == 2 || randomFood == 4) { goodFood.push_...

Why are my particles drifting? ( aka Is Math.random() broken or is it my algorithm? )

Using Javascript I'm crudely simulating Brownian motion of particles, but for some reason I don't understand my particles are drifting up and to the left. The algorithm is pretty straight forward. Each particle is a div and I simply add or subtract a random number from each div's top and left position each round. I read up on Math.rand...

Linear congruential generator: How important is setting seed?

I'm learning about linear congruential generator in an algorithms and data structures course. After thinking about RNG implementation we've been using (a=429493445, c=907633385, mod=4294967296, X is _uint32), one thing came to my mind: Program has a function for setting seed. How important would that function be in C and C++? Here's ...

Cryptographically-secure pseudorandom number generator seed

Do we need to seed a CSPRNG with a truly random number? Examples and documentation use truly random numbers, but no justification is given (that I can find). If we were to seed one with a pseudorandom number, I don't see what the difference would be compared to with a truly random seed. If someone finds either of the seeds, then the e...

Random number generator that generates integers for Java

hi, I want to generate some random integers in Java, but this according to some distribution laws. More specific: I want to generate some random integers for gaussian distribution. I found out only generators which return double results for the gaussian distribution. Why is that? I want to generate some random integers between some li...

How to generate a predictable shuffling of a sequence without generating the whole sequence in advance?

The following python code describes exactly what I want to achieve for a sequence of arbitrary size (population): import random fixed_seed = 1 #generate the same sequence every time with a fixed seed population = 1000 sample_count = 5 #demonstration number num_retries = 3 #just enough to show the repeatable behaviour for trynum in xran...

linear_congruential library in boost

I am trying to use random::linear_congruential in boost (http://www.boost.org/doc/libs/1_33_1/libs/random/random-generators.html#linear_congruential) to generate uniform random numbers. The declaration is defined as: template<class IntType, IntType a, IntType c, IntType m, IntType val> Does anyone know what the last parameter IntType ...

Is there a pseudo-random number generator simple enough to do in your head?

Are there are any pseudo-random number generators that are easy enough to do with mental arithmetic, or mental arithmetic plus counting on your fingers. Obviously this limits to fairly simple math - it needs to be something someone of average mathematical ability can do, or maybe average ability for a programmer, not a math prodigy. The...

Properly implementing C#'s random number generator

I'm trying to generate two random numbers, one for a row and one for a column. In this exact instance, it is a multidimensional array with 4 rows and 4 columns. Thus, the number generator can use the values 0 to 3 for both row and column. I must also make sure that there are no duplicate points, so if [0,0] is chosen the first time, [0...

Combination of Random Number Generators

Given two random integer generators one that generates between 1 and 7 and another that generates between 1 and 5, how do you make a random integer generator that generates between 1 and 13? I have tried solving this question in various ways but I have not been able to come up with a solution that generates numbers from 1 to 13 with equa...

Dynamic Frequency Evaluation on Massive Random Numbers

I use a random function(Let's call it randomNum()) to generate random numbers(unsigned long) continuously(will generate about one million numbers in total).My question is How to determine whether the frequency of current number generated is greater than 20%(among the total numbers generated so far) efficiently? Please write down your op...

How to write a Linear Congruential Generator (LCG) in C#? Or are there any well known implementations?

I am wanting to generate a random array of sequences that repeat and only use each number once. For example, given a range of 0-9 with 2 different seeds you might get Seed 1: 7 3 5 9 0 8 1 2 6 4 | 7 3 5 9 0 8 1 2 6 4 | 7 3 5 9 0 8 1 2 6 4 Seed 2: 2 5 7 1 4 9 6 8 3 0 | 2 5 7 1 4 9 6 8 3 0 | 2 5 7 1 4 9 6 8 3 0 From what I understand, a...

Generating samples from the logistic distribution

I am working on some statistical code and exploring different ways of creating samples from random distributions - starting from a random number generator that generates uniform floating point values from 0 to 1 I know it is possible to generate approximate samples from a normal distribution by adding together a sufficiently large numbe...

How do I generate a random number in java between 450 and 150 that is a multiple of 10?

So far I have this code int w = (int)((450-150)*random()+150); This generates a number between 450 and 150... But I have no idea how to make that number a multiple of 10. Thanks in advance! ...

How to get really random number?

Possible Duplicates: Understanding randomness Fastest implementation of a true random number generator in C# Hello. Function: Random rand = new Random(); rand.Next() It gives pseudo random numbers based on time in seconds. How to get really random numbers? I mean totally random not based on system time and some algorithm....

How do you create a random string in Postgresql?

I'd like to make a random string for use in session verification using postgresql. I know I can get a random number with "Select random()", so I tried "select md5(random())", but that doesn't work. How can I do this? ...

How do I use rand_r and how do I use it in a thread safe way?

I am trying to learn how to use rand_r, and after reading this question I am still a little confused, can someone please take a look and point out what I'm missing? To my understanding, rand_r takes a pointer to some value (or a piece of memory with some initial value) and use it to generate new numbers every time it is called. Each thre...

Calculating a Random for C++

This is probably a super easy question, but I just wanted to make 10000% sure before I did it. Basically Im doing a formula for a program, it takes some certain values and does things when them.....etc.. Anyways Lets say I have some values called: N Links_Retrieved True_Links True_Retrieved. I also have a % "scalar" ill call it, for ...