random

Random numbers probability

Hi, I am trying to randomly choose from e.g. 4 numbers. I need to compare the probability of these 2 algorithms. 1# int a = random.Next(0, 4); if (a = 0) statement1 if (a = 1) statement2 if (a = 2) statement3 ...

Did I understand /dev/urandom?

Hi, I have been reading about /dev/urandom, and as far as I can tell, /dev/random creates cryptographically random numbers by taking advantage of several events like network packet timings, etc. However, did I understand right that /dev/urandom uses a PRNG, seeded with a number from /dev/random? Or does it just use /dev/random as long a...

How to implement a random float function so that it does not lose entropy? (PHP)

Hi, I am trying to generate random floats using nothing but bytes I get from /dev/urandom. Currently my best idea is to get the platform precision doing something like: $maximumPrecision = strlen('' . 1/3) - 2; and then construct a string of 0-9 in a loop the number of times $maximumPrecision tells us. For examle, if the precision is...

Fetch a random entity from the datastore

Pretty simple, in my AppEngine application, I have over 1 million entities of one kind, what is the best way to pick one at random? ...

How can I create a specified amount of random values that all equal up to a specified number in PHP?

For example, say I enter '10' for the amount of values, and '10000' as a total amount. The script would need to randomize 10 different numbers that all equal up to 10000. No more, no less. But it needs to be dynamic, as well. As in, sometimes I might enter '5' or '6' or even '99' for the amount of values, and any number (up to a billio...

Weighting Different Outcomes when Pseudorandomly Choosing from an Arbitrarily Large Sample

So, I was sitting in my backyard thinking about Pokemon, as we're all wont to do, and it got me thinking: When you encounter a 'random' Pokemon, some specimen appear a lot more often than others, which means that they're weighted differently than the ones that appear less. Now, were I to approach the problem of getting the different Pok...

JQuery - hide a set of divs/images one by one randomly

Hello, I have a set of visible divs/or images. by clicking one item, I'd like to hide the other divs/images. But it should be - randomly - one by one with either fadeOut() out or hide(). - (maybe animated) My HTML: <DIV class="myDivBox">Box no 1</DIV> <DIV class="myDivBox">Box no 2</DIV> <DIV class="myDivBox">Box no 3</DIV> <DIV cla...

A Matlab code for Random way point in MANET

Just started reading on random way point mobility for MANET. I found a lot of work implements this model. Hence, I assumed the Matlab code will be available which I could look into to understand it better. Unfortunately, I found none. Any body can suggest any good tutorial or codes available on random way point ? Help appreciated. UP...

Is there a better/more pythonified way to do this?

I've been teaching myself Python at my new job, and really enjoying the language. I've written a short class to do some basic data manipulation, and I'm pretty confident about it. But old habits from my structured/modular programming days are hard to break, and I know there must be a better way to write this. So, I was wondering if any...

Fetching random rows using a random index and RAND( )

I'm using the following code to return a random row from a table. Using the field 'rand'. SELECT * FROM imgs WHERE rand > RAND( ) ORDER BY rand ASC LIMIT 1 The field 'rand' is generated by mysql at creation using something similar to: INSERT INTO imgs SET rand = RAND () For some reason the results although changing each run are...

Most efficient way of randomly choosing a set of distinct integers

I'm looking for the most efficient algorithm to randomly choose a set of n distinct integers, where all the integers are in some range [0..maxValue]. Constraints: maxValue is larger than n, and possibly much larger I don't care if the output list is sorted or not all integers must be chosen with equal probability My initial idea wa...

SoapUI : is it possible to autogenerate the value from an element in a SOAP message ?

With SoapUI it's possible to send Soap XML message to a WCF service. I've the following SOAP message: <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:my="http://myserviceprovider"&gt; <soap:Header/> <soap:Body> <my:ProcessOrder> <my:Orders> <my:Order> <my:id>rando...

Mixing RAND() and UNION gives random rowcount?

I was testing out a query to get a random integer in MySQL, and I noticed this behavior: mysql> SELECT FLOOR(0 + (RAND() * 5)) UNION SELECT FLOOR(0 + (RAND() * 5)) UNION SELECT FLOOR(0 + (RAND() * 5)); +-------------------------+ | FLOOR(0 + (RAND() * 5)) | +-------------------------+ | 1 | | ...

Flash: Is it possible to `srand`?

Like the title suggests… Is it possible to srand Flash's Math.random? I'm asking because I'd like to generate psudo-random numbers in a repeatable way. ...

Unpredictable EXC_BAD_ACCESS and objc_msgSend_vtable5

Hello, I was testing my application and suddenly it had EXC_BAD_ACCESS. Now this has become a semi-regular thing, happening on some builds and not others. It also spits out lots of errors in the debugger such as objc_msgSend_vtable5 What could cause such a weird issue like this? ...

PHP PayPal payment verification / HTTP POST?

I am working on a software project and have written a validation system to help prevent theft of the software. I was reading back through the code, and found a huge "loophole" that could potentially allow the motiviated users to copy the program and install it without even contacting the activation server. So, I modified the program and ...

Java: Generating a random numbers with a logarithmic distribution

I am attempting to generate a random numbers with a logarithmic distribution. Where n=1 occurs half of the time, n=2 occurs a aurter of the time, n=3 occurs an eight of the time, etc. int maxN = 5; int t = 1 << (maxN); // 2^maxN int n = maxN - ((int) (Math.log((Math.random() * t)) / Math.log(2))); //...

create a random number less than a max given value

What i would love to do is to create a function that takes a parameter that is the limit of which number the random generation should create. I have experienced that some generators that just repeat the number generated over and over again. How can I make a generator that doesn't return the same number consecutively. Can someone please...

How do I generate a number after a button is clicked?

Possible Duplicate: How to create a GUID / UUID in Javascript? I need to have a script that generates random numbers and letters with a form that looks like this: M3KRT-CKKYV-YH4G4-YXP42-46FMT Prefer jQuery, or javascript. I know how to generate number when the button is click using the .click() method in jQuery. But I can n...

Using PHP, randomly pair up group of items, not pairing any with itself, no direct pairings

Assume you have a set of items in an array. A, B, C, D, E, F, G, H Using PHP, how would you randomly pair the letters together without pairing them with a duplicate of themselves? Such as this: A->pairedLetter = G B->pairedLetter = C C->pairedLetter = E D->pairedLetter = A E->pairedLetter = B F->pairedLetter = D G->pairedLette...