random

True (not pseudo) random number generators. What's out there?

I am looking for affordable solutions that generate true random numbers. I have found LavaRnd, which is a cryptographically sound random number generator. Does anybody has experience in this field and/or knows about other solutions? PS: IMHO the SO question True random number generator did not really cover this EDIT: My curiosity i...

Simple random english sentence generator...

I need a simple random English sentence generator. I need to populate it with my own words, but it needs to be capable of making longer sentences that at least follow the rules of English, even if they don't make sense. I expect there are millions of them out there, so rather than re-inventing the wheel, I'm hoping you know of a source...

Fastest implementation of a true random number generator in C#

I was reading about Random.Next() that for "cryptographically secure random number suitable for creating a random password" MSDN suggests RNGCryptoServiceProvider Class What the speed penality? There is some fastest way to get true random numbers? EDIT: With Random.Next() I get a new random number. And with... byte[] randomNumber = ne...

Generate random values in C#

How can I generate random Int64 and UInt64 values using the Random class in C#? ...

Generate User Friendly Codes

I am researching methods to generate a random human friendly code but not (easily) guessable. This will be used to give away prizes (think unique discount codes). We are to generate about 50k. Are there any standard methods/algorithms to accomplish this? I was thinking of using a GUID and applying CRC. Is this a bad idea? Using .netfram...

How to get random string with spaces and mixed case?

Hi all, I am in need of generating a random string with spaces and mixedCase. This is all I got so far: /// <summary> /// The Typing monkey generates random strings - can't be static 'cause it's a monkey. /// </summary> /// <remarks> /// If you wait long enough it will eventually produce Shakespeare. /// </rema...

C++ random float

How do I generate random floats in C++? I thought I could take the integer rand and divide it by something, would that be adequate enough? ...

What is the best way to efficiently extract a small random subset of a large enumeration?

What is the best way to grab n items from an IEnumerable<T> in random order? I'm writing a store API and need to provide a small set of random items from a sometimes huge enumeration of items. The underlying enumerable is sometimes an array, and sometimes a lazy evaluated filter of said array. Since I'm just grabbing a proportionally ...

Best way to choose a random file from a directory

What is the best way to choose a random file from a directory in Python? Edit: Here is what I am doing: import os import random import dircache dir = 'some/directory' filename = random.choice(dircache.listdir(dir)) path = os.path.join(dir, filename) Is this particularly bad, or is there a particularly better way? ...

Best way to choose a random file from a directory in a shell script

What is the best way to choose a random file from a directory in a shell script? Here is my solution in Bash but I would be very interested for a more portable (non-GNU) version for use on Unix proper. dir='some/directory' file=`/bin/ls -1 "$dir" | sort --random-sort | head -1` path=`readlink --canonicalize "$dir/$file"` # Converts to ...

simulating randomness

I'm just curious... How do you simulate randomness? How is it done in modern OS (Windows, Linux, etc.)? Edit: Okay, NOT JUST GENERATING RANDOM NUMBER, which can be just done with calling rand() functions in most high level programming languages. But, I'm more concerned with how it is actually done in modern operating systems. ...

Place random non-overlapping rectangles on a panel

I've a panel of size X by Y. I want to place up to N rectangles, sized randomly, upon this panel, but I don't want any of them to overlap. I need to know the X, Y positions for these rectangles. Algorithm, anyone? Edit: All the N rectangles are known at the outset and can be selected in any order. Does that change the procedure? ...

question about Arrays

Hello guys, I have a question regarding this code. I'm a beginner and enjoy learning C#. But then I'm on the topic now called Array which is quite difficult and I need your help. I would like to understand the code. What I don't understand here is what does the part 1, 2, 3, 4 and 5 here mean? I don't understand what is the function of ...

How can I generate a file of random negative and positive integers in serial?

I want a file of randomly generated positive or negative serial integers. For now, I ask the file contain roughly (no guarantee required) equal numbers of negative and positive, but make it easy to change the proporotions later. By "serial", I mean the kth random negative is equal to -k, and the kth random positive is equal to +k. Thi...

Excel 2007 question about random numbers

Hello Experts In cell A1:A50 i have random numbers geberated by formula ( from 0 to 20), now what ever i do these numbers keeps on changing all the time, so i want to know the formula which will shuffle these random numbers automaticallly till the series whcich have got 5-12-19 in a row will appear. I would really appriciate if some one ...

How do I select a Random Row using NHibernate's ICriteria API?

Can I select a random row using NHibernate's ICriteria API? ...

Unique random string generation

I'd like to generate random unique strings like the ones being generated by MSDN library: http://msdn.microsoft.com/en-us/library/t9zk6eay.aspx, for example. A string like 't9zk6eay' should be generated. ...

select a random sample of results from an oracle query

This question asks about getting a random(ish) sample of records on sqlserver and the answer was to use "TABLESAMPLE", is there an equivalent in Oracle 10? If there isn't is there a standard way to get a random sample of results from a query set. For example to get 1000 random rows from a query that will return Millions normally. ...

What is the proper method of constraining a pseduo-random number to a smaller range?

What is the best way to constrain the values of a PRNG to a smaller range? If you use modulus and the old max number is not evenly divisible by the new max number you bias toward the 0 through (old_max - new_max - 1). I assume the best way would be something like this (this is floating point, not integer math) random_num = PRNG() / ma...

select random file from directory

I've seen a few examples but none so far in C#, what is the best way to select a random file under a directory? In this particular case I want to select a wallpaper from "C:\wallpapers" every 15 or so minutes. Thanks. ...