random-number-generator

mysql random value change

I have a database in mysql with 1 table composed by 5 fields. Two of these fields are FLOAT and generated by RAND function; now i want to change these values each x time, for example numeric values have to change every 0.01 s to simulate a financial market. Is there a method to do this thing? Thanks ...

Why is this class not Serializable?

I was using the Mersenne-Twister implementation at http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/JAVA/MTRandom.java as a drop-in replacement for the default java.util.Random class. However, four fields (an int, a boolean and two byte[]) are marked as transient. This means that I can't serialize an object of this class without ...

Generating Serial Number

So I'm creating a Activation class for a VB6 project and I've run into a brain fart. I've designed how I want to generate the Serial Number for this particular product in a following way. XXXX-XXXX-XXXX-XXXX Each group of numbers would be representative of data that I can read if I'm aware of the matching document that allows me to und...

How to generate a random number from scratch

How can a random number be generated from scratch, i.e without using any built-in features of the language / outside API that will help with the randomization process? For example php has a rand() function and a seed function, and I'm sure java also has some similar stuff. You can use built-in functions to get the current time etc, but...

Random number in range 0 to n

Given a function R which produces true random 32 bit numbers, I would like a function that returns random integers in the range 0 to n, where n is arbitrary (less than 2^32). The function must produce all values 0 to n with equal probability. I would like a function that executes in constant time with no if statements or loops, so som...

unbiased random number generator using a biased one

you have a biased random number generator that produces a 1 with a probability p and 0 with a probability (1-p). you do not know the value of p. using this make an unbiased random number generator which produces 1 with a probability 0.5 and 0 with a probability 0.5. Note: this problem is an exercise problem from Introduction to Algorith...

Generation of (pseudo) random constrained values of (U)Int64 and Decimal

Note: For brevity's sake, the following will not discern between randomness and pseudo-randomness. Also, in this context, 'constrained' means 'between given min and max values') The System.Random class provides random generation of integers, doubles and byte arrays. Using Random.Next, one can easily generate random constrained values o...

What's the fastest way to randomly generate numbers in Visual Basic 2008?

What's the fastest way to randomly generate numbers, either randomly or simulating random? I don't really need a true random number generator, it would be acceptable to simulate random. I tried other random simulation methods but none were faster than this. Here's the fastest way I have now: Private myRandom As New System.Random(CType(...

Is Java's RNG (using seeds) platform-independent?

Apologies in advance for asking a (seemingly obvious) question. I haven't found an answer online, so I figured I'd ask: Is Java's Util.Random platform-independent? For Example, is new Random(50) going to produce the exact same sequence of random numbers in both *nix and Windows systems? ...

Pseudo Random Number generator with fixed density of 1s

Hi! I'm searching for way to generate pseudo random numbers [possibly of low "randomness"] or pseudo random bit sequences with a fixed Hamming weight [ a fixed density of 1s]. I found some suggestion about using a simple linear congruential generator with a seed having the Hamming weight I need, but no reasoning was given why this is c...

Simulation in WEKA

Can Weka do simulations? I need to transform random subsets of values for a particular attribute and re-do analysis to figure out the variability for a particular coefficient. I guess I don't need Weka per se, just a Java implementation where I can specify the column and transform random subsets of the values repeatedly. ...

Generate a random binary number with a variable proportion of '1' bits

I need a function to generate random integers. (assume Java long type for now, but this will be extended to BigInteger or BitSet later.) The tricky part is there is a parameter P that specifies the (independent) probability of any bit in the result being 1. If P = 0.5 then we can just use the standard random number generator. Some oth...

Pseudorandom Number Generator - Exponential Distribution

I would like to generate some pseudorandom numbers and up until now I've been very content with the .Net library's Random.Next(int min, int max) function. PRNGs of this variety are supposed to be using a Uniform distribution, but I would very much like to generate some numbers using an Exponential Distribution. I'm programming in C#, a...

Sampling sequences of random numbers in Haskell

I need small lists of gaussian random numbers for a simulation and so I tried the following: import System.Random seed = 10101 gen = mkStdGen seed boxMuller mu sigma (r1,r2) = mu + sigma * sqrt (-2 * log r1) * cos (2 * pi * r2) This is just the Box-Muller algorithm - given r1, r2 uniform random numbers in the [0,1] interval it ret...

Random generated number

How would you set up a program using Java to generate a 5 digit number using the following statement: int n = (int)Math.floor(Math.random()*100000+1) It also has to print the number generated. I have tried writing this different ways and keep coming up with errors. ...

How to test a random generator

I need to test a random number generator which produces numbers randomly. How to make sure the numbers generated are random. ...

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...

Python: Random is barely random at all?

I did this to test the randomness of randint: >>> from random import randint >>> >>> uniques = [] >>> for i in range(4500): # You can see I was optimistic. ... x = randint(500, 5000) ... if x in uniques: ... raise Exception('We duped ' + str(x) + ' at iteration number ' + str(i)) ... uniques.append(x) ... Traceback ...

random.sample() returning the same random sequence every time?

I'm using python's random.sample(population, k) function to generate a set of random values from a list to create new permutations of that list. The issue is that each time it runs through a loop, it's generating the exact same random sequence. Why is this? I even used random.seed(i) so that the i variable (changing each time through ...

Using boost::random and getting same sequence of numbers

I have the following code: Class B { void generator() { // creating random number generator boost::mt19937 randgen(static_cast<unsigned int>(std::time(0))); boost::normal_distribution<float> noise(0,1); boost::variate_generator<boost::mt19937, boost::normal_distribution<float> > nD(randgen, noise); for (i...