random

Probability distribution in Python

I have a bunch of keys that each have an unlikeliness variable. I want to randomly choose one of these keys, yet I want it to be more unlikely for unlikely (key, values) to be chosen than a less unlikely (a more likely) object. I am wondering if you would have any suggestions, preferably an existing python module that I could use, else I...

Can the uncommon maths library be trusted?

There is a Java library by the name of Uncommon Maths that claims to provide better random number generators than Sun and (potentially) even BouncyCastle. How one can determine whether their library can be trusted? I trust Sun and BouncyCastle because a lot of important companies use their stuff. It's not clear if Uncommon Maths falls in...

WPF: Rendering a canvas at Random Points

With reference to this programming game I am currently building. When the game is started, I am generating these robots at supposingly random points on a Canvas, and at first look (adding one or two bots at the same time), this seemed to be working as it should. ...but, when I added a ton of bots at the same time, this is how they wher...

Is there an easy way to randomize a list in VB.NET?

I have a list of type System.IO.FileInfo, and I would like to randomize the list. I thought I remember seeing something like list.randomize() a little while back but I cannot find where I may have seen that. My first foray into this yielded me with this function: Private Shared Sub GetRandom(ByVal oMax As Integer, ByRef currentVals As...

Select variable number of random records from MySQL

I want to show a random record from the database. I would like to be able to show X number of random records if I choose. Therefore I need to select the top X records from a randomly selected list of IDs (There will never be more than 500 records involved to choose from, unless the earth dramatically increases in size. Currently there...

Drupal 5 views -- can I have a random block and a sorted page?

I keep running into the same problem, and I feel like I'm solving it the clunky way. Do you have a better solution? I have a site that with the content type "Staff Bios". I've created a view page that lists all the bios in alphabetical order. I want to have a block that shows just one bio (like a sidebar teaser), and I want the choic...

Generate a number of ranges for a random set of values

Given a set of random numeric values in a database, how do I generate a limited list of ranges where each range contains at least one value? The ranges should not overlap and ideally have a similar amount of values in them. Ideally their boundaries should also be multiples of 10, 100, 1000 etc... For example: Values: 100,150,180,300,40...

Best method of generating a number with 256 random bits?

What is the best method of generating a number with 256 random bits? Does concatenating random bytes work? byte[] data = new byte[32]; RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); rng.GetNonZeroBytes(data); // should include zero bytes? string number = BitConverter.ToString(data, 0).Replace("-", ""); Further more, ...

Why can't gcc find the random() interface when -std=c99 is set?

I do "#include <stdlib.h>" at the top of the source. Example compilation: /usr/bin/colorgcc -std=c99 -fgnu89-inline -g -Wall -I/usr/include -I./ -I../ -I../../ -I../../../ -I../../../../ -O3 -o f8 f8.c In file included from f8.c:7: ctype-cmp.c: In function ‘randomized’: ctype-cmp.c:48: warning: implicit declaration of function ‘ra...

How to randomly select rows in SQL??

In my db, I have a table "customerNames" which has two columns "Id" and "Name" and approx. 1,000 results. I am creating a functionality where I have to pick up the 5 customers randomly every time. Can anyone tell me how to create a query which will get random 5 rows (Id, and Name) every time when query is executed. edited I am using M...

Pseudo-random number generator

What is the best way to create the best pseudo-random number generator? (any language works) ...

When using random, which form returns an equal 50% chance?

I'm guessing that most built in random generators return something like this: [0.0, 1.0) so if I would like a 50% chance would I use something like this: if random() < .5 or something like: if random() <= .5 Thanks for the help. ...

Random word generator

What would be the best way to go about getting a function that returns a random English word (preferably a noun), without keeping a list of all possible words in a file before hand? Edit: Sorry for the failure of wording. After the tiniest amount of thought i suppose i am after some sort of online list or api that would not require me t...

MySQL query to assign a unique random number to each row

Hi I wish to attach a column to my table which will be a random number from a sequential list = to the number of rows. So, if my table had 999 rows, then the numbers 1 to 999 would be assigned randomly and uniquely. Now, I figured that I could add a dummy TempRandomColumn=Rand(), sort by that and add the numbers sequentially using PHP...

Which algorithm for extremely high non burst errors?

I have a binary stream that has a very high error rate. The error rate is 50% meaning each bit has a 50% chance of being flipped. The error does not occur in bursts and is completely random, so Reed–Solomon codes wouldn't work well. Which scheme or algorithm should I apply to the stream? I don't care about the overhead at all. This ...

Generating a Random Decimal in C#

How can I get a random System.Decimal? System.Random doesn't support it directly. ...

Dictionary(words such as names, items, etc) library for .NET?

I am looking for a library that can be used in .NET to retrieve strings of random names(John, Peter), items(table, bottle), objects etc I want to use this in a database-filling operation and the requirement is that the data should look real. ...

Advertising rotation: What's the best to determine when and what ad should be displayed on the page?

A client I'm creating a site for wants a custom advertising "engine". The plan is to have a few ads on the site and fill the rest with Google Adsense until all the spots are full. My problem is how to determine which ad to dipslay. (Assume for now that I only have 1 ad placement.) My thinking was I'd have a table with: year month impr...

Random Number Generator

I need to write a program in Java to generate random numbers within the range [0,1] using the formula: Xi = (aXi-1 + b) mod m assuming any fixed int values of a, b & m and X0 = 0.5 (ie i=0) How do I go about doing this? i tried doing this but it's obviously wrong: int a = 25173, b = 13849, m = 32768; double X_[i]; for (int i = ...

Select random sampling from sqlserver quickly

I have a huge table of > 10 million rows. I need to efficiently grab a random sampling of 5000 from it. I have some constriants that reduces the total rows I am looking for to like 9 millon. I tried using order by NEWID(), but that query will take too long as it has to do a table scan of all rows. Is there a faster way to do this? ...