A class I am taking currently requires us to do all of our coding in smalltalk (it's a Design class). On one of our projects, I am looking to do some things, and am having a tough time finding how to do them. It seems that what most people do is modify their own version of smalltalk to do what they need it to do. I am not at liberty to d...
I need to generate random numbers with in specified interval [max,min]
Also the random numbers should be uniformly distributed over interval, not located to particular point
Currenly I am generating as:
for(int i=0;i<6;i++)
{
DWORD random= rand()%(max-min+1) + min;
}
From my tests random numbers are generated around one point only
...
I am using a System.Random object which is instantiated with a fixed seed all thoughout the application. I am calling the NextDouble method and after some time passed I am getting 0.0 as result.
Is there any remedy to this, has anyone else encountered this ?
EDIT: I have one seed for the whole run which is set to 1000 for convience sak...
Okay, I guess this is entirely subjective and whatnot, but I was thinking about entropy sources for random number generators. It goes that most generators are seeded with the current time, correct? Well, I was curious as to what other sources could be used to generate perfectly valid, random (The loose definition) numbers.
Would using m...
Hi!
When using a Random Number Generator, which is the better way to use it for greater randomness of the new value:
Have a method that instantiates a new instance of the RNG each time and then returns a value?
Have an instance of the RNG at the class level, which is instantiated once in the Constructor, and all subsequent calls for a...
There's a lot of conflicting information about this topic. So let's try to agree on a definitive answer:
Which one of these random number generator in C create better randomness: rand, random or arc4random?
note: Just to make the question clear, this is not a question about true randomness, it's only a clash between those 3.
As poin...
I have a PRNG with nice properties which uses 6 UInt32s as state. I need to come up with a reasonable way to seed it. Two obvious possibilities are: 1) generate 6 random numbers using System.Random and use them as seeds; 2) generate 2 Guids with Guid.NewGuid(). Which would be better?
I do not need cryptographic security.
...
George Marsaglia has written an excellent random number generator that is extremely fast, simple, and has a much higher period than the Mersenne Twister. Here is the code with a description:
good C random number generator
I wanted to port the CMWC4096 code to Java, but it uses several unsigned datatypes so I am not sure how to do this ...
I would like to use RNGCryptoServiceProvider as my source of random numbers. As it only can output them as an array of byte values how can I convert them to 0 to 1 double value while preserving uniformity of results?
...
Currently, Boost only implements the random_device class for Linux (maybe *nix) systems. Does anyone know of existing implementations for other OS-es? Ideally, these implementations would be open-source.
If none exist, how should I go about implementing a non-deterministic RNG for Windows as well as Mac OS X? Do API calls exist in ei...
I'm in need of a C++ (pseudo, i don't care) random number generator that can get me different numbers every time I call the function. This could be simply the way I seed it, maybe there's a better method, but every random generator I've got doesn't generate a new number every time it's called. I've got a need to get several random number...
What are the pros and cons of using System.Security.Cryptography.RNGCryptoServiceProvider vs System.Random are. I know that RNGCryptoServiceProvider is 'more random', i.e. less predictable for hackers. Any other pros or cons?
UPDATE:
According to the responses, here are the pros and cons of using RNGCryptoServiceProvider so far:
Pro...
The JavaScript Math.random() function returns a random value between 0 and 1 (automatically seeded based on the current time (similar to Java I believe)). However I'd like to make a more robust function that accepts a min, a max, and (optionally) a seed.
I found this code kicking around and it appears to work fine for getting a random ...
I've simplified a bug I'm experiencing down to the following lines of code:
int[] vals = new int[8];
for (int i = 0; i < 1500; i++)
vals[new Random(i).nextInt(8)]++;
System.out.println(Arrays.toString(vals));
The output is: [0, 0, 0, 0, 0, 1310, 190, 0]
Is this just an artifact of choosing consecutive numbers to s...
Given the extremely high requirements for unpredictability to prevent casinos from going bankrupt, what random number generation algorithm and seeding scheme is typically used in devices like slot machines, video poker machines, etc.?
EDIT: Related questions:
http://stackoverflow.com/questions/203382/do-stateless-random-number-generat...
I'd like to generate uniformly distributed random integers over a given range. The interpreted language I'm using has a builtin fast random number generator that returns a floating point number in the range 0 (inclusive) to 1 (inclusive). Unfortunately this means that I can't use the standard solution seen in another SO question (when th...
Two Questions:
Will I get different sequences of numbers for every seed I put into it?
Are there some "dead" seeds? (Ones that produce zeros or repeat very quickly.)
By the way, which, if any, other PRNGs should I use?
Solution: Since, I'm going to be using the PRNG to make a game, I don't need it to be cryptographically secure. I'm ...
Could someone explain if and why the following random number function from XKCD works?
I have never quite been able to understand it. I ask the question on SO hoping to find a more "human" explanation that could be understood by me.
...
Hi everybody,
I have this long and complex source code that uses a RNG with a fix seed.
This code is a simulator and the parameters of this simulator are the random values given by this RNG.
When I execute the code in the same machine, no matter how many attempts I do the output is the same. But when I execute this code on two differe...
I want to generate random numbers manually. I know that every language have the rand or random function, but I'm curious to know how this is working.
Does anyone have code for that?
...