random

Choosing random numbers efficiently

I have a method, which uses random samples to approximate a calculation. This method is called millions of times, so its very important that the process of choosing the random numbers is efficient. I'm not sure how fast javas Random().nextInt really are, but my program does not seem to benefit as much as I would like it too. When cho...

take out objects from randomizer obj c

hello everyone, I'm a new "developer" trying to build some iPhone app I'm making an app which gets text from a list of objects in a NSArray and then randomizes them and display one in a TextView, here's the code: - (IBAction)azione{ NSArray *myArray= [NSArray arrayWithObjects: @"Pasta",@"Pizza",@"Wait",@"Go", nil]; int length = [myArra...

SQL: select random row from table where the ID of the row isn't in another table?

I've been looking at fast ways to select a random row from a table and have found the following site: http://74.125.77.132/search?q=cache:http://jan.kneschke.de/projects/mysql/order-by-rand/&hl=en&strip=1 What I want to do is to select a random url from my table 'urls' that I DON'T have in my other table 'urlinfo'.The query I am...

Generating unique N-valued key

I want to generate unique random, N-valued key. This key can contain numbers and latin characters, i.e. A-Za-z0-9. The only solution I am thinking about is something like this (pseudocode): key = ""; smb = "ABC…abc…0123456789"; // allowed symbols for (i = 0; i < N; i++) { key += smb[rnd(0, smb.length() - 1)]; // select symbol at ra...

how to generate random number from array

How to generate random number from an array? and not from a range. int n [] = {1,7,3,5,8,10,33,12,18} ...

How to generate distinct random numbers per distinct threads in .NET?

Dear ladies and sirs. I have to generate 19 bit random numbers. However, there is a constraint - two threads may not generate the same random number when running certain code. The simplest solution is lock the entire code. However, I would like to know if there is a non locking solution. I thought, I can incorporate ManagedThreadId wit...

Rearranging a sequence

I'm have trouble rearranging sequences so the amount of letters in the given original sequence are the same in the random generated sequences. For example: If i have a string 'AAAC' I need that string rearranged randomly so the amount of A's and C's are the same. ...

Hausman Test, Fixed/random effects in SAS?

Hey guys, I'm trying to do a fixed effecs OLS regression, a random effects OLS Regression and a Hausman test to back up my choice for one of those models. Alas, there does not seem to be a lot of information of what the code looks like when you want to do this. I found for the Hausman test that proc model data=one out=fiml2; en...

How should I use random.jumpahead in Python

I have a application that does a certain experiment 1000 times (multi-threaded, so that multiple experiments are done at the same time). Every experiment needs appr. 50.000 random.random() calls. What is the best approach to get this really random. I could copy a random object to every experiment and do than a jumpahead of 50.000 * expi...

Java: random long number in 0 <= x < n range.

Random class has a method to generate random int in a given range. For example: Random r = new Random(); int x = r.nextInt(100); This would generate an int number more or equal to 0 and less than 100. I'd like to do exactly the same with long number. long y = magicRandomLongGenerator(100); Random class has only nextLong(), but it ...

Matlab - binary vector with high concentration of 1s (or 0s)

What's the best way to generate a number X of random binary vectors of size N with concentration of 1s (or, simmetrically, of 0s) that spans from very low to very high? Using randint or unidrnd (as in this question) will generate binary vectors with uniform distributions, which is not what I need in this case. Any help appreciated! ...

Randomly generating sequence of ints in a specific range

Hi, I am unsure how to put this and my math skills aren't that strong. But here's what I need. I want to generate a list of all the 16bit integers (0-65535). But everytime I do so I want to seed the algorithm randomly that each time the list starts with a different integer and all the subsequent integers will be generated once but also ...

Very slow guards in my monadic random implementation (haskell)

Hi! I was tried to write one random number generator implementation, based on number class. I also add there Monad and MonadPlus instance. What mean "MonadPlus" and why I add this instance? Because of I want to use guards like here: -- test.hs -- import RandomMonad import Control.Monad import System.Random x = Rand (randomR ...

Random loading swf files into main swf with countdown timer

ok guys a question, can this be done or has it already been done, or can someone point me in the right direction (be aware i an a total newbie with action script) i have a main swf movie about 600px x 400 px what i want is this to run for say 30 seconds, then i want a countdown timer in the bottom corner for say 10 seconds, after this ...

Most Efficient Way To Retrieve MYSQL data in random order PHP

Hey, I have a query like so SELECT * FROM table WHERE premium = 3 I'm just wondering how I can have it return a random order for the results! i was told not to use ORDER BY RAND(); because of the amount of system resources it uses. Thanks. ...

how to quickly create dummy image directly in .NET code

How to quickly create some random image with the icon size? I don't want to use neither Image.FromFile, nor Image.FromStream ...

How could I generate instances of an object randomly at the top of the screen and make them "fall"?

I am making a game in Flash CS4 (actionscript 3) and I would like to be able to make "copies" of an instance that would randomly appear at the top of the screen and fall. For example, multiple objects(that are the same one) are falling from the top of the screen continuously, starting at random X positions. (i think this would be consid...

Python: why does `random.randint(a, b)` return a range inclusive of `b`?

It has always seemed strange to me that random.randint(a, b) would return an integer in the range [a, b], instead of [a, b-1] like range(...). Is there any reason for this apparent inconsistency? ...

how do i display the coordinates of a random triangle in a graph which ranges from +10 to -10 XY axis in actionscript 2.0?

Hi how i display the coordinates of a random triangle in a graph which ranges from -10 to +10 in XY axis with the points like A(2,1) etc with arcs in each corner, in actionscript 2.0 ...

How to use /dev/random or urandom in C ?

I want to use /dev/random or /dev/urandom in C - how can i do it ? I don't know how can i handle them in C, if someone knows please tell me how. Thank you. ...