random

generating random alphabets with some alphabets having a higher frequency of occurence(vc++6.0)

basically i have a function that generates random alphabets .i have done this using the rand() function to generate numbers and them converted them to their corresponding ascii equivalents. but i want the vowels to be generated in higher numbers as compared to other alphabets.i.e if have generated say 10 alphabets then there should be li...

Random number: 0 or 1

Am I looking too far to see something as simple as pick a number: 0 or 1? Random rand = new Random(); if (rand.NextDouble() == 0) { lnkEvents.CssClass = "selected"; } else { lnkNews.CssClass = "selected"; } ...

php rand() array

I need to be able to pull a random value out of my array, let's assume i have array with 100 values, how can i pull randomly 5 values out of this array? ...

Most Efficient Way to... Unique Random String

I need to efficently insert a 5 character RANDOM string into a database while also ensuring that it is UNIQUE. Generating the random string is not the problem, but currently what I am doing is generating the string and then checking the DB if it exists already... if it does, I start over. Is there a more efficient way to do this proces...

Generating the same random SecretKey twice

I have a need to generate a random SecretKey, in Java, which I will be able to regenerate at some future point. The idea is that this key is unique to the machine on which it is created and isn't stored anywhere. I'm attempting something like this: KeyGenerator keyGen = KeyGenerator.getInstance("DESede"); String hostname = InetAddress....

Does anyone know a way to scramble the elements in a list?

thelist = ['a','b','c','d'] What's the best way to scramble them in Python? ...

Generating random numbers in Javascript

How can I generate a random whole number between two specified variables in Javascript, e.g. x=4 and y=8 would output any of 4,5,6,7,8? ...

TSQL Generate 5 character length string, all digits [0-9] that doesn't already exist in database...

What's the best way to do this? I need to generate a 5 digit length string where all the characters are numeric. However, I need to be able to do this 'x' amount of times (user variable) and store this random strings in a database. Furthermore, I can't generate the same string twice. Old strings will be removed after 6 months. Pseud...

Cannot shuffle list in Python.

This is my list: biglist = [ {'title':'U2','link':'u2.com'}, {'title':'beatles','link':'beatles.com'} ] print random.shuffle(biglist) that doesn't work! It returns none. ...

Generate random strings in vb.net

I need to generate random strings in vb.net, which must consist of (randomly chosen) letters A-Z (must be capitalized) and with random numbers interspersed. It needs to be able to generate them with a set length as well. Thanks for the help, this is driving me crazy! ...

Selecting random in rails sqlite vs mysql

Hey guys, I'm trying to select random data from the database in Ruby on Rails. Unfortunately, sqlite and mysql use different names for the "random" function. Mysql uses rand(), sqlite use random(). I've been pretty happy using sqlite in my development environments so far, and I don't want to give it up for just this. So I have a soluti...

Generate two numbers that are NOT equal in PHP

Hello everyone! I need to generate two numbers that are NOT equal in PHP. I know that I use $random1 = (rand()%9); to generate random a number between 0-9. I need to add something to this I guess. Thanks! ...

randomly change div background image on page load

Hi I have a DIV background which I want to change randomly on page load from a selection of 3 PNGs. I searched around and found this code: $(document).ready(function() { var randomImages = ['img-restaurante-1','img-restaurante-2','img-restaurante-3']; var rndNum = Math.floor(Math.random() * randomImages.length); $("div.lacarta")...

Draw different shape of polygon randomly

My program draw 10 polygon triangles in random sizes (width and height). The coordinate (points) of the polygon were generated using Random generator = new Random(). Since the points of the triangle and the width and height were randomly generated, how can I control the number of sizes drawn? e.g. there are 10 polygon in total, but I wan...

How different do random seeds need to be?

Consider code like this (Python): import random for i in [1, 2, 3, 4]: random.seed(i) randNumbers = [random.rand() for i in range(100)] # initialize a list with 100 random numbers doStuff(randNumbers) I want to make sure that randNumbers differ significantly from one call to another. Do I need to make sure the seed number...

Random background image on DIV

I'm trying to get a randomly picked background image (from a selection of 4 images) to appear as the background image for a asp.net panel. The problem I have is that the code works when stepping through the code in debug mode. Once you run the code on the website without debugging, all the images are the same. Its almost as if the rando...

(.NET) Easy way to generate random, easy to remember passcodes

I have a project in the works, and I'll need to associate a passcode with an item. The password should be completely non sequential or easily guessable, yet simple to remember. I thought about doing something like this. string rand = System.Guid.NewGuid().ToString(); rand.Substring(0,3); Return the first 4 digits of a GUID. I was wo...

How does this MATLAB code work? (probabilities and random sequences)

I saw this code in a comment for the article "Never-ending Shuffled Sequence". I understand the basic premise, but I don't know how it works. The biggest explanation I need is of the first two lines of the while loop. (Because it is written in MATLAB I can only guess at how this code functions.) probabilities = [1 1 1 1 1 1]; unrandomn...

Is there a random function in python that accepts variables?

I'm attempting to create a simple dice roller, and I want it to create a random number between 1 and the number of sides the dice has. However, randint will not accept a variable. Is there a way to do what I'm trying to do? code below: import random a=0 final=0 working=0 sides = input("How many dice do you want to roll?") while a<=si...

Stochastic calculus library in python

Hello, I am looking for a python library that would allow me to compute stochastic calculus stuff, like the (conditional) expectation of a random process I would define the diffusion. I had a look a at simpy (simpy.sourceforge.net), but it does not seem to cover my needs. This is for quick prototyping and experimentation. In java, I u...