random-number-generator

Did OS4 change how the iPhone reads code?

The code I wrote for 3.2 performs differently in OS4. Still no errors, just new bugs. So I'm initializing the imageView inside an IBAction called "randomize" that produces and random number that goes to one of 86 cases producing a resulting animation and image, the only difference in code between 0 and 86 is that final imageView.image ...

Random ID/Number Generator in PHP

I am building a list of "agent id's" in my database with the following requirements: The ID must be 9 digits long (numeric only) The ID may not contain more than 3 of the same number. The ID may not contain more than 2 of the same number consecutively (i.e. 887766551; cannot have 888..) So far I have part 1 down solid but am struggli...

A CCK field that's a random number

Anyone aware of a CCK module that adds a text field that's just a randomly generated number? This means that when the user tries to create a fresh node, he sees a pre-populated random number as one of the fields (and can't change that field) ...

How to generate a 9 digit number

I'm trying to use php to generate a 9 digit number that does not start with a 0 and is separated by dash every third number. e.g. 102-394-458 I'm also debating whether to store it as a number or do the formatting on the front end or to store it as a number and do the formatting on the backend or to just store the dashes in the dat...

Why do digits 1, 2 and 3 appear so frequently using C rand() function?

What I am trying to do is to generate some random numbers (not necessarily single digit) like 29106 7438 5646 4487 9374 28671 92 13941 25226 10076 and then count the number of digits I get: count[0] = 3 Percentage = 6.82 count[1] = 5 Percentage = 11.36 count[2] = 6 Percentage = 13.64 count[3] = 3 Percenta...

Create a random even number between range

OK I need to create an even random number between 54 and 212 inclusive. The only catch is that it has to be done in a single statement. I have a class to generate random number within a range, but like I said, I want to do it in a single statement. I came up with this, but it's not working correctly. Any ideas? int main() { srand( ...

How do I search a range for a single integer?

My Python code generates a random number between 0 and 35 and stores that number as 'random'. I am looking to compare 'random' against several ranges of numbers to determine which of three groups it falls into and assign another value to 'winning' based on which group 'random' is in. The groups are: 0-16, 16-34, and 34-36. 'winning' alwa...

how to randomize an integer variable, with odds on certain numbers appearing

To get a random whole number between 0 and 4 inclusive, I use the following code: var random = Math.floor(Math.random() * 5); However I want the number 4 to be chosen twice as often as the other numbers. How would I go about doing getting a random number between 0-4 inclusive, but with the number 4 appearing twice as many times as 0-3...

How to eliminate all sources of randomness so that program always gives identical answers?

I have C++ code that relies heavily on sampling (using rand()), but I want it to be reproducible. So in the beginning, I initialize srand() with a random seed and print that seed out. I want others to be able to run the same code again but initializing srand() with that same seed and get exactly the same answer as I did. But under what ...

What is the most secure seed for random number generation?

What are the most secure sources of entropy to seed a random number generator? This question is language and platform independent and applies to any machine on a network. Ideally I'm looking for sources available to a machine in a cloud environment or server provided by a hosting company. There are two important weaknesses to keep in ...

Generate a random vector inside a rectangle but not a circle?

I have a rectangle, and a circle inside that rectangle (that sits around the center of the rectangle). I want to generate a random 2-component vector that falls inside the rectangle, but not the circle. How can I do it? Edit: I'd prefer a method that i can use to generate a vector that meets these constraints without brute-forcing it. ...

Security wise how do i use GUID properly?

I read an answer about guid and it was fairly interesting. It seems that GUID is based on time and v1 uses a MAC address with v4 using a RNG. From the wiki Cryptanalysis of the WinAPI GUID generator shows that, since the sequence of V4 GUIDs is pseudo-random; given full knowledge of the internal state, it is possible to pre...

Probabilistic selection from a set

Suppose I want to randomly select a number n between 0 and 30, where the distribution is arbitrary, and not uniform. Each number has a corresponding weight P(n): P(0) = 5, P(1) = 1, P(2) = 30, P(3) = 25, and so on and so forth. How do I do a random selection from this set, such that the probability of selecting a number is proportional t...

CryptGenRandom Entropy

Hello, CryptGenRandom is a random number generator function in CryptoAPI in Windows. How much entropy has that random number generator ? I have already looked a lot, but I couldn't find it. Thanks in advance. ...

Generating random numbers with ARM Assembly

hi , i want to generate random number to use it in my iphone project by Inlining in my objective-c code some assembly , is this possible with arm-assembly ?! Thank you to help .. ...

Generate random numbers according to distributions

Hi, I want to generate random numbers according some distributions. How can I do this? Regards, nilani ...

How to generate unique 64 bits integers from Python?

I need to generate unique 64 bits integers from Python. I've checked out the UUID module. But the UUID it generates are 128 bits integers. So that wouldn't work. Do you know of any way to generate 64 bits unique integers within Python? Thanks. ...

How to make a selective RNG for a game in Python?

This is almost certainly a very novice question, but being as I am a complete novice, I'm fine with that. To put it simply, I'd like to know how to make a loot drop system in a simple game, where when you achieve a certain objective, you have a chance of getting certain objects more than others. If there are any open-source python game...

PRNG with adjustable period

I need to build an in-place pseudo-random number generator with an adjustable period. In addition, there must be no collisions within one period. That is, the following must return true: // prng is "generated" at run-time // (though a by-hand solution would work) bool test(func prng, int period) { int seed = 0; // Any number sho...

Algorithm to generate a random number? Don't use System.Random

Had there been no System.Random class, how would have you generated a random number? Are there any known algorithms or have you guys ever designed one? ...