random

How to generate random 'greenish' colors

Anyone have any suggestions on how to make randomized colors that are all greenish? Right now I'm generating the colors by this: color = (randint(100, 200), randint(120, 255), randint(100, 200)) That mostly works, but I get brownish colors a lot. ...

Draw a random line.Set CGPoint nil ? - Objective C

Hi, I use ccTouchesBegan and ccTouchesEnded to draw a line. I want to draw a line when i drag the cursor(or finger) on screen. That mean, when i release the cursor, it will draw a line with the first point is the position which i has a first touch (ccTouchesBegan) and last point which i have when release (ccTouchesEnded). Here is my code...

Why would rand() return a negative value when min and max values are positive?

Hi, I have a simple piece of PHP code which requires a random number to be created. However, even though the input is always positive, it sometimes returns a negative output. Here's my debug code: $debt = rand($this->gdp * 0.02, $this->gdp * 0.17); echo "<p>GDP: ".$this->gdp." rand(".$this->gdp * 0.02." , ".$this->gdp * 0.17.") = <st...

Where to get a list of almost all the words in English language?

I want to get some random text generated. I tried writing a basic Java programme, int nowords = r.nextInt(2000); int i, j; for (i = 0; i < nowords; i++) { int lengthofword = r.nextInt(10) + 2; for (j = 0; j < lengthofword; j++) { int ch = r.nextInt(26); System.out...

R: How do I best simulate an arbitrary univariate random variate using its probability function?

R: What's the best way to simulate an arbitrary univariate random variate if only its probability/density function is available? ...

Optimizing my mysql statement! - RAND() TOO SLOW

So I have a table with over 80,000 records, this one is called system. I also have another table called follows. I need my statement to randomly select records from the system table, where that id is not already listed within the follows table under the current userid. So here is what I have: SELECT system.id, system.u...

How can I SELECT 16 records at random from a range of rows in MySQL?

I want to display a list of 16 of the most popular items in my database, but I want that list to be different every time. So from say, the top 50 downloaded items, choose 16 at random and return that in the result. Is that possible with just one query? ...

Unique random numbers in an integer array in the C programming language.

How do I fill an integer array with unique values (no duplicates) in C? int vektor[10]; for (i = 0; i < 10; i++) { vektor[i] = rand() % 100 + 1; } //No uniqueness here ...

simple rand() question

I need a random 4 digit number right now im using rand(1000,9999) that always gives me a 4 digit number but i eliminates 0000-0999 as possible results. how do you pad a random number? (also this is eventually going to be added to a string do i need to cast the int as a string?) thanks ...

Non repeating Random Numbers.

Im using. for (int i = 1, i<100, i++) int i = arc4random() % array count; But im getting repeats everytime so how can i full out the chosen int value from the range so when the program loops i will not get any dupe? Thanks. ...

How do I delete a random value from an array in Perl?

I'm learning Perl and building an application that gets a random line from a file using this code: open(my $random_name, "<", "out.txt"); my @array = shuffle(<$random_name>); chomp @array; close($random_name) or die "Error when trying to close $random_name: $!"; print shift @array; But now I want to delete this random name from the fi...

How could I improve this C# randomising method?

I think I've settled on this as the most simple and unit-testable method for randomising a list, but would be interested to hear of any improvements. public static IList<T> RandomiseList<T>(IList<T> list, int seed) { Random random = new Random(seed); List<T> takeFrom = new List<T>(list); List<T> ret = new List<T>(takeFrom.Co...

Random record from mysql database with CodeIgniter

Hi friends, I researched over the internet, but could not find anything... I have a mysql db, and records at a table, and I need to get random record from this table at every page load. how can I do that? Is there any func for that? Appreciate! thanks SORTED: link: http://www.derekallard.com/blog/post/ordering-database-results-by-r...

boost random number library, use same random number generator for different variate generators

It seems that one can use the following code to produce random numbers from a particular Normal distribution: float mean = 0, variance = 1; boost::mt19937 randgen(static_cast<unsigned int>(std::time(0))); boost::normal_distribution<float> noise(mean, variance); variate_generator<mt19937, normal_distribution<float> > nD(randgen, noise); ...

Need a fast random generator for c++

Hi guys. I'm trying to do some opt-3 swapping on my TSP generator for euclidian distances, and since I in many cases have more than ~500 nodes, I need to randomly select at least 1 of the 3 nodes that I want to try swapping. So basically I need a random-number function that's fast. (the normal rand() is way too slow) It doesn't have to...

PHP Random Numbers

i need to print out numbers 1-100 in a random order. the print statement should be: echo 'h{'.$num.'}'; what is the shortest code to do this? ...

How to get random value out of an array

I have a an array called $ran = array(1,2,3,4); I need to get a random value out of this array and store it in a variable, how can I do this? ...

C# Random Code Field Generator for Object

I have an object with the following properties GID ID Code Name Some of the clients dont want to enter the Code so the intial plan was to put the ID in the code but the baseobject of the orm is different so I'm like screwed... my plan was to put ####-#### totally random values in code how can I generate something like that say a windo...

iPhone: choose random value

hi all, i am new to iPhone Programing i have 10 number say (1,2,3,4,5,6,7,8,9,10) i want to choose randomly 1 number from above 10 number.so how can i choose random number from a set of numbers ...

How do I generate a random list of person names?

I need to generate a list of people's name randomly. Where can I find lists of names? I need a list of first names, a list of middle names and a list of surnames. --EDIT-- Just want to make it clear, these names are only English names. ...