|
What is the best method of generating a number with 256 random bits?
Does concatenating random bytes work?
byte[] data = new byte[32]; RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); rng.GetNonZeroBytes(data); // should include zero bytes...
Answer Snippets (Read the full thread at stackoverflow):
If the random byte generator is good, any method works concatenate random bytes....
EDIT: Not sure why you would need 256 bits to shuffle are equally likely, assuming use of a good RNG .
Yes, concatenating random bytes would work.
|
|
How can I generate a (pseudo)random alpha-numeric string, something like: 'd79jd8c' in PHP?
Started by Unkwntech on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Then, in a loop, choose a random number and use it as the index to the $characters string to get a random character, and append it to your string....
Abcdefghijklmnopqrstuvwxyz0123456789';
You could also use range() to do this more quickly .
|
|
Ok this is one of those trickier than it sounds questions so I'm turning to stack overflow because I can't think of a good answer. Here is what I want: I need Python to generate a simple a list of numbers from 0 to 1,000,000,000 in random order to be ...
Answer Snippets (Read the full thread at stackoverflow):
Examples
MySQL:
SELECT column FROM table ORDER BY RAND() LIMIT....
With some modular for a random unused number? Most databases support such a request.
And a seed like a timestamp + random number and it should do for almost any situation.
|
Ask your Facebook Friends
|
Like my question, i need to generate random numbers that have identical pairs between a range. i have tried to generate random numbers and stored in an array but the numbers are repeating more than twice. i have 16 random numbers to be generated in the...
Answer Snippets (Read the full thread at stackoverflow):
New ArrayList<Integer>(); Random randomizer = new Random(); for(int i = 0; i < 8; ) { int r.
|
|
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...
Started by RobS on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
The resulting distribution of values will be identical to the distribution of the random numbers, so uniformity depends....
If the random number generator delivers a uniform distribution = highest + 1 .
I don't see why the + 1 is needed.
|
|
I was using the arc4random() function in order to generate a random group and sequence of numbers, but I was told that this was overkill and that I should use the random() function instead. However, the random() function gives me the same group and sequence...
Started by schwabrX on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
There is some additional uniformity gained by generating some amount of numbers and throwing them away, but unless you are looking for security level random number ....
No, you do not need to reseed the random number generator.
|
|
How I can generate a random new GUID inside of the Dephi IDE?
I am using Delphi 2007.
Started by Salvador on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
With enclosing square brackets - [] - , but once you've got the GUID in the text editor you can do ... .
It's formatted for use as an interface IID, i.e.
Just press Ctrl + Shift + G
Ctrl+Shift+G will place a new GUID at the current position in the editor .
|
|
Lets say my alphabet contains X letters and my language supports only Y letter words (Y < X ofcourse). I need to generate all the words possible in random order.
E.g. Alphabet=a,b,c,d,e,f,g Y=3
So the words would be: aaa aab aac aba .. bbb ccc .. (...
Started by Sridhar Iyer on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
I think you can do something pretty straightforward by generating a random array of characters; Random rand = new Random(); for (int i = 0; i < 5; i++) { char[] word = new char[wordLength its order, you can keep adding a....
|
|
How can I generate a random number within range 0 to n where n can be > RAND_MAX in c,c++?
Thanks.
Started by ebaccount on
, 10 posts
by 10 people.
Answer Snippets (Read the full thread at stackoverflow):
Generating random numbers is a solved problem in other librariesDo x random numbers (from 0 to RAND_MAX) and add them together, where
x = n % RAND_MAX
split at a decent random number library....
Complicated, inaccurate, or both.
|
|
I know how to generate a random number in PHP but lets say I want a random number between 1-10 but I want more 3,4,5's then 8,9,10's. How is this possible? I would post what I have tried but honestly, I don't even know where to start.
Started by kyct on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
For an efficient random number skewed consistently towards one end of the scale:
Choose a continuous ....
Pick a random number if it is.
Basically:
Sum the weights of all the numbers.
There's a pretty good tutorial for you.
From that.
|