pseudo-random-numbers

Generating two differnet pseudorandom numbers using the same seed

Is it possible to generate two different psuedorandom numbers on two separate program runs without using time as the seed? i.e. using the same seed on both runs, is it possible to get two different numbers? ...

Generate n-dimensional random numbers in Python

I'm trying to generate random numbers from a gaussian distribution. Python has the very useful random.gauss() method, but this is only a one-dimensional random variable. How could I programmatically generate random numbers from this distribution in n-dimensions? For example, in two dimensions, the return value of this method is essentia...

is there a such thing as a randomly accessible pseudo-random number generator? (preferably open-source)

first off, is there a such thing as a random access random number generator, where you could not only sequentially generate random numbers as we're all used to, assuming rand100() always generates a value from 0-100: for (int i=0;i<5;i++) print rand100() output: 14 75 36 22 67 but also randomly access any random value like: rand...

A function where small changes in input always result in large changes in output

I would like an algorithm for a function that takes n integers and returns one integer. For small changes in the input, the resulting integer should vary greatly. Even though I've taken a number of courses in math, I have not used that knowledge very much and now I need some help... An important property of this function should be that ...

How can I generate an "unlimited" world?

I would like to create a game with an endless (in reality an extremely large) world in which the player can move about. Whether or not I will ever get around to implement the game is one matter, but I find the idea interesting and would like some input on how to do it. The point is to have a world where all data is generated randomly o...

Can Java's random function be zero?

Just out of curiosity, can Math.random() ever be zero? For example, if I were to have: while (true){ if (Math.random() == 0) return 1; } Would I ever actually get a return of one? There's also rounding error to consider because Math.random() returns a double. I ask because my CS professor stated that random() goes from 0 to 1 ...

How can I convert words to numbers in PHP?

The first method that springs to mind is reading each character and converting it to its ASCII value. Are there any other methods of doing this? I would like to be able to give a php script a string, and have it turn that same string (that may or may not contain numbers or symbols) into the same series of numbers every time. ...

Pseudo-Random Binary Sequence Prediction (Newbie)

Hi, i know nothing about programming or C or windowing... nothing too deep about computers... but i'm very interested in: given a pseudo-random binary sequence (e.g.: 00101010010101) of finite values, predict how will the sequence continue. Can someone please tell me the easiest way to do it? Or in case it's too difficult for someone who...

LR: Can I make the pseudorandom in LoadRunner deterministic?

There are a couple of sources for random in LoadRunner scenarios: rand () function Random think time deltas (runtime settings) Random pacing time components (runtime settings) Random parameters (as part of the VUGen test) I use those functionalities, and I could live with their pseudorandomness. I cannot, however, live with the fa...

Cocoa Touch - X,Y coordinates

I want to display a image at random places on the screen. My idea is to generate two random numbers one being a x-value or a y-value and then passing it into a method which displays the image on the xy coordinates provided. But, I dont know how to accomplish that so I need some help with coordinates...Also if you know a better way to ac...

PRNG with adjustable period

I need to build an in-place pseudo-random number generator with an adjustable period. In addition, there must be no collisions within one period. That is, the following must return true: // prng is "generated" at run-time // (though a by-hand solution would work) bool test(func prng, int period) { int seed = 0; // Any number sho...

Generating Full Period/Full Cycle Random Numbers or Permutations Similar to LCG but without odd/even

I wish to generate psuedo-random numbers/permutations that 'occupy' a full period or full cycle within a range. Usually an 'Linear Congruential Generator' (LCG) can be used to generate such sequences, using a formula such as: X = (a*Xs+c) Mod R Where Xs is the seed, X is the result, a and c are relatively prime constants and R is the ...

Distributed sequential random number generation in Ruby 1.9.2

The Random class in Ruby 1.9.2 is guaranteed to generate random numbers in the same order, given a particular seed and range. For instance: r = Random.new(23) r.rand(100) # 83 r.rand(100) # 40 But suppose I want to generate the next number in the sequence on another computer (without re-generating the earlier numbers i...

What shuffling algorithms exist besides Fisher-Yates and finding the "next permutation?"

Specifically in the domain of one-dimensional sets of items of the same type, such as a vector of integers. Say, for example, you had a vector of size 32,768 containing the sorted integers 0 through 32,767. What I mean by "next permutation" is performing the next permutation in a lexical ordering system. Wikipedia lists two (http://en...

Generate fast pseudorandom data in PHP

I need to generate uncompressible data (therefore pseudorandom), and have been trying with the code below. But it's only producing about 10MB/s of data. I need about 100-200 MB/s. Do you have any advice? if ($length > 8*1024*1024){ //Default max string length in php. while (($length - $bytesGenerated)>8*1024*1024){ $bytesGen...

Encapsulating boost::random for ease of usage to replace rand()

Hello, for my program I need pseudo random integers with different ranges. Until now I used the rand() function but it has it's limitations. I found the boost::random library to be a much better replacement but I didn't want to create random generators all over the place. ( I need random integers in many classes, because it's a stress t...

Can one use negative numbers as seeds for random number generation?

Hi, This is not a coding question, but am hoping that someone has come across this in the forums here. I am using Python to run some simulations. I need to run many replications using different random number seeds. I have two questions: Are negative numbers okay as seeds? Should I keep some distance in the seeds? Currently I am usi...

How can I get true randomness in this class without Thread.Sleep(300)?

I've made a class (code below) that handles the creation of a "matching" quiz item on a test, this is the output: It works fine. However, in order to get it completely random, I have to put the thread to sleep for at least 300 counts between the random shuffling of the two columns, anything lower than 300 returns both columns sorted ...

How to generate a boolean with p probability using C rand() function?

How can I generate a random boolean with a probability of p (where 0 <= p <= 1.0) using the C standard library rand() function? i.e. bool nextBool(double probability) { return ... } ...

Thread-safe random number generation for Monte-Carlo integration.

Im trying to write something which very quickly calculates random numbers and can be applied on multiple threads. My current code is: /* Approximating PI using a Monte-Carlo method. */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <omp.h> #define N 1000000000 /* As lareg as possible for increased ...