random-number-generator

qrand is not generating a random number

Hi there I have a QT app, running 2 more threads. Inside the threads I use the qrand function to generate a random number. The following is the code used to get the number, where m_fluctuations max is a double. int fluctuate = qrand() % (int)(m_FluctuationMax * 100); I tried adding the following code in the main thread, and also in...

How exactly should I implement a shuffle or random-number algorithm for an array to display quotes in random order?

I already know there's answers for this kind of thing, but I don't really know how to implement them in my code. Also, I would like to refrain from using any more functions unless neccessary. Here's my code: int main() { unsigned seed; seed = 1; srand(seed); std::string starFox[8]; int x[8]; starFox[0] = "Do a barrel roll!"; sta...

secure random numbers in asp.net

From what i know Random() is initialize to the current time. If two connections hit during the same second i should get the same two random numbers? With a large site that can be likely. Locking is bad so how should i solve it? note: the number is used for the session id. -edit- i am stuck using a long. It feels wrong to shorten a 128bi...

Randomize numbers in VB.NET without using a range i.e. Min and Max

Hi, I was wondering if anyone can point me in the right direction please? Say I am pulling the following table, I would then like to select an ID randomly. I understand how to select a random number using a Randomize() call followed by the relevant syntax but I want to pre-define the range. i.e. Table Data ID | Name 4345 ...

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

C# Random.Next suddenly stops returning random values

Possible Duplicate: System.Random keeps on returning the same value I'm refactoring and expanding a small C# agent-based model to help some biology professors predict the spread of a disease. Each year of the simulation each individual agent randomly travels to a nearby population node, possibly spreading the disease. I'm br...

How is ActiveSupport::SecureRandom secure?

Is the ActiveSupport::SecureRandom secure in the way that it is 'impossible' to figure out random numbers or is it secure in the way that it will return UUIDs? ...

How to generate random +ve -ve decimal with php?

how can I regenerate random decimal from -0.0010 to 0.0010 with php rand()? or any other? ...

Generate different random -ve +ve number with php rand()?

Dear all, I have asked a question about random generating -ve +ve decimal value here: http://stackoverflow.com/questions/3206563/how-to-generate-random-ve-ve-decimal-with-php But now i have another more challenging problem. May I know how can I generate random integer with -ve +value with a different set? like from -552 to 2200 as an e...

What's the best library to generate random numbers for cryptographic keys in .NET?

In .NET, you can generate RSA key pairs using RSACryptoServiceProvide. But is that the best option in .NET to generate truly random numbers? There are tons of other open source libraries, such as CryptoPlusPlus, that can be used to generate random number. I would like to hear from other experts' opinions. Thanks in advance for your two c...

Create a random string or number in Qt4

Is there any function or something like that by which I can create totally random strings or numbers? ...

Normally distributed random integers?

Is there a nice way to get randomly generated integers with normal distribution? The first method which come to mi mind: int rndi = (int)Math.floor(random.nextGaussian()*std); Is there better way? Thanks ...

Hardware RNG - How to use?

Ok, I've just picked up a hardware RNG and it contains some simple functions as below, GetRandomBytes(UInt Length,out object Array) GetRandomDoubles(UInt Length,out object Array) The functions seem to explain themselves pretty well, how would one use these functions effectivly to generate a number between a certain range? More info f...

random questions from sql server

I am working on a survey application. I have a sql server database holding upto 3000 survey questions. I call database for a set of 10 questions. I have to make sure that none of the of the questions are repeated for the longest time possible. What is the best possible approach I can take here? Write a custom randomization algorithm or S...

How do I generate a set of random strings in a C# program so that they are not trivially predicted?

I faced a following problem: generate N unique alphanumeric strings from a restricted alphabet. Here's my solution in C#: string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; Random generator = new Random(); const int ToGenerate = 10000; const int CharactersCount = 4; ArrayList generatedStrings = new ArrayList(); while( generatedSt...

What's the fastest way to generate a random sequence from a list of data?

Let's say that I have a list of data: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} where n = 10 elements I'd like to randomly choose k elements of this set to form a sublist, say k = 5. In that case, I could end up with a sublist that looks like {9, 3, 5, 2, 7} I could accomplish this by: Randomly determining an offset within the list, between 0 a...

Specify max and min for Random.nextInt()?

Possible Duplicate: Java: generating random number in a range I want to generate a random int in a logical range. So, say for example, I'm writing a program to "roll" a dice with a specified number of sides. public int rollDice() { Random generator = new Random(); return generator.nextInt(sides); } Now the problem ...

How do I seed the random generator and create a random int in Objective-C

I have seen some examples of the random int in Objective-C, but all people are complaining about the same number sequence every time the application runs. I have read about seeding the random number, but I am not sure what that even means. How can a random number be generated differently every time, even after application has relaunche...

Generating two independent random number sequences (C++)

I'd like to be able to do something like this (obviously not valid C++): rng1 = srand(x) rng2 = srand(y) //rng1 and rng2 give me two separate sequences of random numbers //based on the srand seed rng1.rand() rng2.rand() Is there any way to do something like this in C++? For example in Java I can create two java.util.Random objects wi...

Math.random() question

What is the precision of JavaScript's Math.random() function? Thanks! ...