random

Fast, Secure Random Numbers

Hello Friends, I was searching for a faster alternative to /dev/urandom when I stumbled across this interesting tidbit: One good trick for generating very good non-random-but-nearly-random bits is to use /dev/random's entropy to seed a fast symmetric stream cipher (my favorite is blowfish), and redirect it's output to the applicatio...

Encapsulating boost::random for ease of usage to replace rand()

Hello, for my program I need pseudo random integers with different ranges. Until now I used the rand() function but it has it's limitations. I found the boost::random library to be a much better replacement but I didn't want to create random generators all over the place. ( I need random integers in many classes, because it's a stress t...

smart way to generate unique random number

Hi, i want to generate a sequence of unique random numbers in the range of 00000001 to 99999999. So the first one might be 00001010, the second 40002928 etc. The easy way is to generate a random number and store it in the database, and every next time do it again and check in the database if the number already exists and if so, genera...

Alternative to ORDER BY RAND() on joined tables?

I have a table of approx 3500 Items. In another table I'm storing user votes - the Item id, the user id and the score. When a user hits this script, it must randomly select an Item they haven't already voted on. At the moment I'm using LEFT JOIN then testing for null to find the set of Items they haven't voted on. Trouble is, using ORDE...

Calculating which item is next in a percentage distribution

I'm working on a project that involves diverting phone calls to a number of destinations. For example, I want: 10% of calls to go to destination A 20% of calls to go to destination B 30% of calls to go to destination C 40% of calls to go to destination D The number of destinations and their percentages must be configurable. I've ...

ASP - Loop while eof or bof - Select random product from idproduct but skip empty ids

Hi, I am trying to display a random product image and description from the access database, so i am selecting the highest idproduct then randomising a number between 1 and %highestid%, this is what i have so far.... IF frontpage = 1 then SQLSTR = "SELECT idproduct AS prodtot FROM products order by idproduct desc" Set objRS = Server.C...

Generating every character combination up to a certain word length

I am doing a security presentation for my Computer and Information Security course in a few weeks time, and in this presentation I will be demonstrating the pros and cons of different attacks (dictionary, rainbow and bruteforce). I am do the dictionary and rainbow attacks fine but I need to generate the bruteforce attack on the fly. I ne...

Applescript: say words from txt file with new (random) voice for each word

I need to make an script that picks a random sentence from a txt-file and says each word in a random voice, using an array of voices, speaking rate modulation and pitch. For example: A sentence is chosen randomly from the txt file: "make a bed:listen carefully:read a book" and {"make", "a", "bed"} is spoken word-for-word by a random voi...

Seed random from milliseconds in Windows and Linux

Hey, I need to seed the random number generator in boost (which is loaded from an int) for a few processes, for a program that has to compile and work both in Windows and in Linux. I used std:time(0), which worked, but since the processes are jobs which are run simultaneously, some of them would run at the same second, producing the s...

Elegant way to bias random boolean

I'd like to create a random boolean in JavaScript, but I want to take the previous value into account. If the previous value was true, I want it to be more likely for the next value to be true. At the moment I've got this (this is in the context of a closure - goUp and lastGoUp are locals to the containing scope): function setGoUp() { ...

Random marker within a rectangular bounds?

this is my code : function getRandom_marker(bounds) { var leftBottom=[bounds.getSouthWest().lat(),bounds.getSouthWest().lng()] var rightTop=[bounds.getNorthEast().lat(),bounds.getNorthEast().lng()] var latlng=[leftBottom[0]+Math.floor(Math.random() * (rightTop[0]-leftBottom[0])), leftBottom[1]+Math.floor(Math.random() * (right...

change random line with shellscript

how can i easily (quick and dirty) change, say 10, random lines of a file with a simple shellscript? i though about abusing ed and generating random commands and line ranges, but i'd like to know if there was a better way ...

How to generate random events in android?

I have a an array of objects and would like to be able to randomly choose one from the list when a button is pressed. How would you do that in Android? ...

selection based on percentage weighting

I have a set of values, and an associated percentage for each: a: 70% chance b: 20% chance c: 10% chance I want to select a value (a, b, c) based on the percentage chance given. how do I approach this? my attempt so far looks like this: r = random.random() if r <= .7: return a elif r <= .9: return b else: return c I'...

How can I get true randomness in this class without Thread.Sleep(300)?

I've made a class (code below) that handles the creation of a "matching" quiz item on a test, this is the output: It works fine. However, in order to get it completely random, I have to put the thread to sleep for at least 300 counts between the random shuffling of the two columns, anything lower than 300 returns both columns sorted ...

getting random images for a test script

I have an app that processes images. For testing it, I have a script that submits an image. This is not completely uncommon. I am bored with my test images. Filling up a folder with some images and getting my test script to randomly pick one gets boring really quickly. Is there any script - in any language, really - that can get a r...

Do randomly generated 2D points clump together, and how do I stop it?

Say you have a 2D area and you want to generate random points within it, by setting x = random() * width y = random() * height do the points clump around the centre of the area? I remember reading something saying they would, but I can't quite figure out why, and how to prevent it. ...

How to get a random integer in Freemarker template?

Is it possible to generate a random integer in Freemarker template? ...

Using the Python random module with XCHAT IRC scripts

I'm trying to print random items from a list into my XCHAT channel messages. So far I've only been able to print the random items from my list alone, but not with any specific text. Example usage would be: "/ran blahblahblah" to produce the desired effect of a channel message such as "blahblahblah [random item]" __module_name__ = "ra...

Conditional Random Fields -- How Do They Work?

I've read the papers linked to in this question. I half get it. Can someone help me figure out how to implement it? I assume that features are generated by some heuristic. Using a POS-tagger as an example; Maybe looking at training data shows that 'bird' is tagged with NOUN in all cases, so feature f1(z_(n-1),z_n,X,n) is generated as (...