random-generator

Consistent pseudo-random numbers across platforms

Hello, I am looking for a way to generate pseudo random number sequences that will yield identical sequence results for a given seed across any platform. I am assuming that rand()/srand() is not going to be consistent (I could easily be wrong about this assumption). ...

Is this a good way to generate a string of random characters?

I found this snippet of code that generates a string of random characters: http://www.c-sharpcorner.com/UploadFile/mahesh/RandomNumber11232005010428AM/RandomNumber.aspx But is there a more elegant/faster/more reliable way to do this? This seems to rely on the fact that the numbers 26-91 are valid characters given the current encoding. ...

How do I select a random key from an NSDictionary?

When I was using an NSArray, it was easy: NSArray *array = ... lastIndex = INT_MAX; ... int randomIndex; do { randomIndex = RANDOM_INT(0, [array count] - 1); } while (randomIndex == lastIndex); NSLog(@"%@", [array objectAtIndex:randomIndex]); lastIndex = randomIndex; I need to keep track of the lastIndex because I want the feeling o...

c# random string generator

Hi, I've developed a random string generator but it's not behaving quite as I'm hoping. My goal is to be able to run this twice and generate two distinct four character random strings. However, it just generates one four character random string twice. Here's the code and an example of its output: private string RandomString(int size)...

Php, should i use sha1 or others version of sha? Whats are the differences?

Hi, I am going to generate a random password for my users. Probably I will use salt and sha1 method. But I found that there are other version of sha1, like sha256, sha512 etc. What is the differences between the sha versions? Which one better, more secure, and faster (performances)? Which one should I use?? EDIT: I am php user, thank...

Algorithm to generate Poisson and binomial random numbers?

i've been looking around, but i'm not sure how to do it. i've found this page which, in the last paragraph, says: A simple generator for random numbers taken from a Poisson distribution is obtained using this simple recipe: if x1, x2, ... is a sequence of random numbers with uniform distribution between zero and one, k is the first int...

How can I create an unique random sequence of characters in C#?

I'm implementing a URL shortening feature in my application in order to provide my users shorter alternative URLs that can be used in Twitter. The point is to be independent from the shortening services that offer this same service and include it as a feature of my web app. What's the best way to create an unique random sequence of char...

Does anyone know where I can find a random text generator tutorial for xcode?

I am trying to make an app that uses a random text generator but I don't know how to do it so i was looking for a tutorial that would help me with it but I haven't found any yet.. Has anyone seen any of them? ...

Randomize value in Javascript

I need to randomize set of values in JS, and I call function randomize for example three times. How can I remember and block random generator from giving me results that it gave me previous times? I can only give one value once. var value = Math.floor(Math.random() * 11); ...

Question about Random function

Hi everybody. I'm new to programming in C#. My question is this; how can i, after generating random numbers (i got so far), get these numbers to show random images in imageboxes? I have 4 imageboxes with a backgroundimage. (but i want them to change, according to the numbers i generate). How do i do that? Anybody got an idea? Thx in...

Random Characters in pseudocode

My assignment is to create in pseudocode a module that accepts a 200 element array of alpha characters. How do I write the code to choose the 200 characters at random and put them in an array? My full assignment is: Create a module in pseudocode which accepts a 200 element array of characters, determines the number of occurre...

How can I get a random time between Now and some previous time point (eg. 1 hour ago)?

Hi folks, I'm trying to make an extension method that allows me to create a random time between Now and some user requested historical time point in the form of a TimeSpan. For example : a random time between now and 1 hour ago. So, I came up with the following Random(..) extension method. I thought to make the random seed NOT static...

How would I create a Program that would take a list of names, and sort them into EVEN groups?

Hello all, I want to be able to create a program that will take a list of names from a .txt file (Doesnt have to be a txt, maybe excell, whatever is easiest) and generate those names into groups or "teams". I have 30 "users" that have to be sorted into "Teams". I want to be able to do this fairly, so I want to random :P. I haven't ye...

what is the best way to create random mysql ID using PHP

hello. i'm building an application that needs a random unique id for each user not a sequence mysql database ID Username for my unique random ID, what is the best way to do that? ...

How do you randomly generate x amount of values and store them?

I found a suggestion on a Stack Overflow topic about problems beginners should do to learn a new language. A user posted a very nice list of problems from Beginner to advanced that should help you get to know a language. One of the problems is to create a phone book, with random phone numbers and random people on the phone book, and a us...

Random object generator in JavaScript

Hi, I need a random object generator in JavaScript that generates a variety of objects with different fields and values. Any ideas where I can find such tool? I need to generate random objects with various complexity.. My goal is to use JSON in order to serialize these objects and fuzz test my application http api. ...

Generate random letters and numbers together

Generate 6 characters: the first character is randomly generated from the alphabets with odd ordering in the alphabet list (A, C, E, …, Y) the second character is randomly generated from the alphabets with even ordering in the alphabet list (B, D, F, …, Z) the third character is randomly generated from alphabet list (A to Z) each of the ...

How do you make a function read form a txt file and store random lines in a variable?

How do you make a function read form a txt file and store random lines in a variable? It will be run over and over in a foreach loop. The language is PHP. Im a new coder so I don't know things like this off the top of my head. ...

C: Random Number Generation - What (If Anything) Is Wrong With This

For a simple simulation in C, I need to generate exponential random variables. I remember reading somewhere (but I can't find it now, and I don't remember why) that using the rand() function to generate random integers in a fixed range would generate non-uniformly distributed integers. Because of this, I'm wondering if this code might ha...

How can I generate a random human-readable colour from a seed? C#

Got a logfile, and it has all kinds of text in it. Currently it is just displayed as one colour, and each entry says something like: Log from section 1: Some text here Log from section 125: Some text here Log from section 17: Some text here Log from section 1: Some text here Log from section 125: Some text here Log from section 1: ...