random

Updating table with random data With NEWID() does not work

SQL SERVER 2000: I have a table with test data (about 100000 rows), I want to update a column value from another table with some random data from another table. According to this question, This is what I am trying: UPDATE testdata SET type = (SELECT TOP 1 id FROM testtypes ORDER BY CHECKSUM(NEWID())) -- or even UPDATE testdata SET typ...

Randomization involving buttons (VB)

Using VB I can create and access a random "cell" in an array like so Dim array(5) as array Dim r as new random r.next(0,5) array(r) will then access a random "cell" based upon r's value. Is there a way to say something like button(r) to directly randomize which button is chosen instead of having to use a random and If's like so? r.n...

Code to generate random strings creates same succession of identical strings

I have the following method that should create a 20 character ID (sometimes with a prefix) and return the ID. It seems to reset on launch and every time I use it it will create the same succession of identical numbers. +(NSString *)createUniqueIdentifier:(NSString *)withPrefix { NSString *outstring = nil; if (withPrefix!=nil &...

Generate random number in JavaScript

I need an 2d array [9,16] with 144 numbers from 1->36 in random order (so each number is repeated 4 times). I'm new at JS so can you give a hand, please. Thanks you. ...

Math, circles, interior points and densities

The theory is this: I have a circle C of radius R and centre S. Inside this circle, I want to place N (a "big" number) points such that the density of points in the vicinity V of a point P is equal everywhere in the circle for all points. As N goes to infinity and the vicinity goes to P, the density function in both polar and cartesian c...

Python library needed

I am trying to run a python script which has the following statements: import random as RD import pylab as PL import scipy as SP import networkx as NX Where can I download these packages? I have installed these packages and I get the following error when I run my code I am getting the following error when I run the code Traceback (...

Random simple connected graph generation with given sparseness

I'm trying to find an efficient algorithm to generate a simple connected graph with given sparseness. Something like: Input: N - size of generated graph S - sparseness (numer of edges actually; from N-1 to N(N-1)/2) Output: simple connected graph G(v,e) with N vertices and S edges ...

How long does the stream of Random().Next() take util it repeats?

Consider the .NET Random stream: var r = new Random(); while (true) { r.Next(); } How long does it take to repeat? ...

In Java: create unique random filename in a directory

How do I create a random unique filename in a directory (of my choice)? Note: I don’t want this file in the system temp path but rather in the directory I specify ...

Random selection while breaking down by percentage over multiple groups

I'm trying to put together a simple system for a user to generate a list of users to whom surveys will be sent. The list generation may depend on various constraints. For example, "we only want people from the U.S. and Canada" or "we only want people who have a level 2 or level 3 membership." This part is pretty easy and I've set up the...

Pseudo Random Number generator with fixed density of 1s

Hi! I'm searching for way to generate pseudo random numbers [possibly of low "randomness"] or pseudo random bit sequences with a fixed Hamming weight [ a fixed density of 1s]. I found some suggestion about using a simple linear congruential generator with a seed having the Hamming weight I need, but no reasoning was given why this is c...

Practical Uses of Fractals in Programming

Fractals have always been a bit of a mystery for me. What practical uses (beyond rendering to beautiful images) are there for fractals in the various programming problem domains? And please, don't just list areas that use them. I'm interested in specific algorithms and how fractals are used with those algorithms to solve something in pr...

randomize NSArray

I need to randomize an NSArray that I have loaded with quiz questions, but I need to keep the elements in a specific order. ...

Generating non-repeating random numbers in Python

Ok this is one of those trickier than it sounds questions so I'm turning to stack overflow because I can't think of a good answer. Here is what I want: I need Python to generate a simple a list of numbers from 0 to 1,000,000,000 in random order to be used for serial numbers (using a random number so that you can't tell how many have been...

J2ME: How to generate random number?

Hi, I just wanted to know how do I generate random number using J2ME? Basically i want to generate a 14 digits random number each time when the menu item Generate is clicked from the mobile's screen. Thanks ...

How do I use chi square distribution with C++ Boost library?

I've checked the examples in the Boost website, but they are not what I'm looking for. To put it simple, I want to see if a number on a die is favored, using 600 rolls, so the average appearances of every number (1 through 6) should be 100. And I want to use the chi square distribution to check if the die is fair. Help!, how would I d...

Output array elements randomly with PHP

How could I echo 5 elements randomly from an array of about 20? Thanks. ...

Random linq result

Hello, I have this LINQ query: var agnts = (from a in db.agents select new { a.UserId, a.name }).Take(10); How can I get randomly get 10 records from my agents table? I have tried: agnts = agnts.OrderBy(n => Guid.NewGuid()); but this doesn't seem to do anything. I would appreciate anybody's help on this. Thanks, Louis ...

Why am I getting dups with random.shuffle in Python?

For a list of 10 ints, there are 10! possible orders or permutations. Why does random.shuffle give duplicates after only 5000 tries? >>> L = range(10) >>> rL = list() >>> for i in range(5000): ... random.shuffle(L) ... rL.append(L[:]) ... >>> rL = [tuple(e) for e in rL] >>> len(set(rL)) 4997 >>> for i,t in enumerate(rL): ... ...

C++: why is (rand() % anything) always 0

I am having trouble getting rand() to work in C++. rand() normally gives me a very large number. When I try to use the modulo operator (%) to give it a range, it always returns 0, no matter what. Seeding the random number generator at the beginning of the program doesn't help either. ...