random-number-generator

How to generate pseudo random in cuda

I am attempting to build a particle system utilizing CUDA to do the heavy lifting. I want to randomize some the particles initial values like velocity and life span. The random numbers don't have to be super random since its just for visual effect. I found this post that addresses the same subject http://stackoverflow.com/questions/8...

why 48 bit seed in util Random class?

Why this class uses 48 bit seed in its linear congruence formula? I would have expected 32 or 64... I know it takes higher order bits when asked for 32 bit values. But why only 16 more additional bits? Was it a "random" choice? ...

Random Number Generation in C++

Possible Duplicate: Whats the Right Way to use the rand() Function in C++? Hi all, I'm trying to set up a random number generation function in c++. Im trying to set it up so that it generates a number between 1 & 500. Right now it returns integers in order according to the system clock, I need TRUE random numbers. Can anyone h...

How do I pass a C++0x random number generator to a function?

Do they all inherit from a base class? Do I have to use templates? (I am referring to these http://www.codeguru.com/cpp/cpp/cpp_mfc/stl/article.php/c15319/) I am doing this right now: typedef std::mt19937 RNG; and then class Chooser { public: Chooser(RNG& rng, uint n, uint min_choices, uint max_choices): In other words, I'm ...

How can I create a unique 7-digit code for an entity?

When a user adds a new item in my system, I want to produce a unique non-incrementing pseudo-random 7-digit code for that item. The number of items created will only number in the thousands (<10,000). Because it needs to be unique and no two items will have the same information, I could use a hash, but it needs to be a code they can sh...

Random Number on SQL without using NewID()

Hello I want to generate a Unique Random number with out using the follow statement : Convert(int, (CHECKSUM(NEWID()))*100000) AS [ITEM] Cause when I use joins clauses on "from" it generates double registers by using NEWID() Im using SQL Server 2000 *PD : When I use Rand() it probably repeat on probability 1 of 100000000 but this ...

Boost random number generator

Does anyone have a favorite boost random number generator and can you explain a little on how to implement it into code. I am trying to get the mersenne twister to work and was wondering if anyone had preference towards one of the others. ...

Need a fast Java beta distribution random number generator

I need to generate random numbers that have a beta distribution in some speed critical code. Currently I'm using the BetaRandomVariable() class from the numerics4j library - but currently represents about 95% of my code's CPU usage! Can anyone recommend a faster way to generate these random numbers? ...

C# Random Numbers

I'm looking at generating a random number between 1 and 5 Million. The process doesnt have to be quick (Although be good if it was) but it must be as random as possible (I know nothing is random). I have a variety of data sources for the seed. I'm not sure if the .Net Random class is going to be good enough for this. Edit: This will b...

How to generate unique order number?

I'm looking for a good way to generate a unique order ID. Can you see any problems with the code below? int customerId = 10000000; long ticks = DateTime.UtcNow.Ticks; long orderId = customerId + ticks; int orderNumber = orderId.GetHashCode(); I'm going to check that the number is unique in the database before creating the order. ...

Random number generator that fills an interval

How would you implement a random number generator that, given an interval, (randomly) generates all numbers in that interval, without any repetition? It should consume as little time and memory as possible. Example in a just-invented C#-ruby-ish pseudocode: interval = new Interval(0,9) rg = new RandomGenerator(interval); count = inter...

srandom( time( NULL ) )

may I know the meaning or even how to read this: srandom( time( NULL ) )? ...

Random number generator in C# - unique values

I'm busy in C# with coding an array. I can fill it up with random generators but now is my question how do i do this but so that i can check if the value is already in the array and if so generate an new value Extra info: Max value : 100 Number of elements : 100 IMPORTANT PLZ WORK FURTHER ON MY IDEA my idea public void FillArray(in...

random number generator

I need help on which random number generator to use simultaneously from multiple threads and get less execution time ...

Generating "too perfect" random numbers

A good RNG ought to pass several statistical tests of randomness. For example, uniform real values in the range 0 to 1 can be binned into a histogram with roughly equal counts in each bin, give or take some due to statistical fluctuations. These counts obey some distribution, I don't recall offhand if it's Poisson or binomial or what, ...

c - random number generator

How do I generate a random number between 0 and 1? ...

A problem with random number generation

Hello! I am taking a course on programming, and we're using C++. We had an assignment where, at some point, we needed to code a function that would return a random number in an [upper, lower] interval. I used the following: lower + (int) (upper * (rand() / (RAND_MAX + 1.0))); I did not forget to change srand by using srand((unsigned ...

How to adjust the distribution of values in a random data stream?

Given a infinite stream of random 0's and 1's that is from a biased (e.g. 1's are more common than 0's by a know factor) but otherwise ideal random number generator, I want to convert it into a (shorter) infinite stream that is just as ideal but also unbiased. Looking up the definition of entropy finds this graph showing how many bits o...

C++ random number from a set

Is it possible to print a random number in C++ from a set of numbers with ONE SINGLE statement? let's say the set is 2, 5, 22, 55, 332 i looked up rand, but I double it's possible to do in a single statement ...

How do i generate a random integer between min and max in java?

What method returns a random int between a min and max? Or does no such method exist? what i'm looking for is something like this: NAMEOFMETHOD (min, max) (where min and max are ints) that returns soemthing like this: 8 (randomly) if such a method does exist could you please link to the relevant documentation with your answ...