random

Random int64 and float64 numbers

I'm trying to generate random 64-bit integer values for integers and floats using Numpy, within the entire range of valid values for that type. To generate random 32-bit floats, I can use: In [2]: np.random.uniform(low=np.finfo(np.float32).min,high=np.finfo(np.float32).max,size=10) Out[2]: array([ 1.47351436e+37, 9.93620693e+37, 2...

Select Random Datas From File

Hello, I'm learning C# and now I need to build a home project(just to learn how to use file I/O and random). I have a file(names.txt) like this: Nathan John Max Someone But how I can access this file(already know) and select a random name, print it and delete this name from the file? Thanks. ...

algorithm to add randomly-generated NSStrings to NSMutableArray

The goal is to generate an NSString chars in length and assign each string to an array. I'm getting stuck on what I need to do with my algorithm to get the correct result. Here's the sample. The result I get is the same randomly generated string added to my array 26 times instead of 26 DIFFERENT strings added. I've thought about de...

Libraries or tools for generating random but realistic text

I'm looking for tools for generating random but realistic text. I've implemented a Markov Chain text generator myself and while the results were promising, my attempts at improving them haven't yielded any great successes. I'd be happy with tools that consume a corpus or that operate based on a context-sensitive or context-free grammar...

Randomize external RSS feed order in PHP

I'm using a third-party AJAX slideshow for a website that takes an RSS feed as its picture source. I would like to randomize the order of the pictures, but that's not a feature of the slideshow (or the RSS feed I'm pulling from). Surely it shouldn't be difficult to write a short function in PHP that takes an external RSS feed, randomiz...

iPhone SDK: Two animation sequences playing at random *help*

I have two animation sequences, and I want one of them to play randomly when a button is pressed. Here is the code: { color.animationImages = [NSArray arrayWithObjects: [UIImage imageName: @"1.gif"], [UIImage imageName: @"2.gif"], [UIImage imageName: @"3.gif"],...

Replacing sequence with random number

I would like to replace some of the sequences I use for id's in my postgresql db with my own custom made id generator. The generator would produce a random number with a checkdigit at the end. So this: SELECT nextval('customers') would be replaced by something like this: SELECT get_new_rand_id('customer') The function would then re...

Algorithm to generate random order of elements

How to randomize order of approximately 20 elements with lowest complexity? (generating random permutations) ...

Shake iphone to view random html files

hi every , i have 20 HTML files ok ? i am going to shake the iphone , after shook , one of 20 html files shows up as random . i don't know random value on the objective C . can u help me ? here is my code : #pragma mark - - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration { ...

How to generate random file name under Linux?

I want to make a small program which use local namespace socket and I will need to use temporary file name as address of the socket. So how to generate random file name under Linux? + I'm using the C programming language under Debian Linux. + Acoording to the GNU C Library Reference,tmpname is not safe.But the safe ones tmpfile and mks...

What is suggested seed value to use with random.seed()?

Simple enough question: I'm using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this default to the current time, but this is not ideal. It seems like a string literal constant (similar to a password) would also not be ideal/...

How can I randomize DataMapper collection and convert it to JSON?

Hi, I'm pulling my hair out trying to build a little random photo JSON feed using DataMapper/Sinatra. Here's what I have so far.. Photo.favorites.to_json(:methods => [:foo, :bar]) So that works fine. The to_json method is provided in the dm-serializer library. All I want to do is randomize that feed so the photos don't show up in the...

MySQL: Fill with random iterated position values

I suppose this will be easy to MySQL pros. Given an existing filled MySQL-InnoDB table like key1 | key2 | foobar | position where key1 and key2 together make up the primary key, and position is mostly still NULL, with what SQL would I best fill the "position" field with a randomly ordered but iterated integer value? E.g. if there were...

Most efficient way to order a list by a preset random.

I have a online PHP system where users vote different awards for their friends, however I am finding that the awards in the middle of the page and at the bottom get less votes overall. I would prefer this to be evenly distributed so came up with ordering the list of awards by random to make it different each time you load the page. This...

Random MySQL row with PHP- low system resources.

I'm looking to get a random row from MySQL without using too much time or resources on the system. I don't care about weather the code given is PHP or MySQL based, however please note there are 'gaps' in my table. My table columns are 'id' (Primary key, auto increment), varchar, int, int I'd like it to be as random as possible ...

.NET: Random number or number of free bytes in memory?

How can I get the number of free bytes available in memory, in .NET? Also, can you think of a potentially better random number beside new Random().Next(), DateTime.Now.Ticks, or available system memory? ...

To calculate the chernoff's bound for the sum of N poisson randon variables

Let X = sum of n iid random variables. X = \sum_{i=1}^n X_i where n is a poisson random variable with some mean i have to calculate Pr(X > a) I am not able to apply the chernoff's bound theorem as poisson random variable is in th epower. pl help me Ranjan ...

How to get two random records with Django

How do I get two distinct random records using Django? I've seen questions about how to get one but I need to get two random records and they must differ. ...

Java permutations with least random numbers possible

hi folks! i looking to generate a permutation of the array a and I dont want to use util function such as shuffle on collections... The permutations(#) should be randomised and every single permutation should be possible - but there is no need for an equally distributed probability. the following code was the first idea that struck my mi...

Generate unique names???

I am working on a php site in which we have to upload images from users.i have to rename that file for preventing conflicts in the name of the image. uniqid(rand(), true); and adding a large random number after it. Will this work perfectly. Any suggestions..?? Its about generation unique names for the image..... ...