I am trying to predict the output of a program that uses msvcrt's rand() function for generating the face of three dice. I believe the code is something like:
dice[0] = rand() % 6 + 1; dice[1] = rand() % 6 + 1; dice[2] = rand() % 6 + 1;, and I was wondering if I could use a prediction program for linear congruential generators to predict...
I am reading random bytes from /dev/urandom, and I want to make a random float out of it/them. How would I do this? I can convert the byte to a number with ord(), and it's between 0 and 255.
It's obvious that 255 is 1.0, 127 is 0.5 and 0 is 0.0, but how do I calculate the rest? Also, I think one byte is not enough to give lots of preci...
Hi all,
Im working on DotNetNuke BTBRandomImage module and this a custumization of the module to randomly change images on a timer based event.
This has been implemented using javascript. But the problem is evertime when the "src" of image is changed it requests the image again from the server. This increases the number of http requests...
I want to stroke a CGContext path using three or four images, but randomly cycle through the images as I'm drawing the path. I want to draw the images INSTEAD!! of drawing the CGContext I am now. I have this code so far
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPo...
Hi folks,
I'm trying to make an extension method that allows me to create a random time between Now and some user requested historical time point in the form of a TimeSpan.
For example : a random time between now and 1 hour ago.
So, I came up with the following Random(..) extension method.
I thought to make the random seed NOT static...
random.shuffle(lst_shuffle, random.random)
I know the latter part is an optional argument. But what does it do exactly. I don't understand what this mean.
This is from the docs.
random.random()¶
Return the next random floating point
number in the range [0.0, 1.0).
I also see this, is this what this range 0,0, 1,0 means?
...
Hello,
I am thinking of giving one or more set of introductory lectures to introduce people in my department with Python and related scientific tools as I did once in the last summer py4science @ UND.
To make the meetings more interesting and catch more attention I had given two Python learning materials to one of the lucky audience v...
I have been doing a little recreational holiday computing. My mini-project was a simulation of the Italian game of "tomboli". A key building block was a simulation of the following process;
The game is controlled by a man with a bag of 90 marbles, numbered 1 to 90. He draws marbles one by one randomly from the bag, each time calling out...
If I have an enum like this:
public enum Letter {
A,
B,
C,
//...
}
What is the best way to pick one randomly? It doesn't need to be production quality bulletproof, but a fairly even distribution would be nice.
I could do something like this
private Letter randomLetter() {
int pick = new Random().nextInt(Letter.va...
I created a jQuery plugin but I have a problem, I use the following code:
Math.floor(Math.random()*500)
I add the result to a element,
but bizarrely the result is every time the same.
If I add a alert() to the line after the random-number-generation,
I get random values, why?
I want to get without the alert() random integers. But how...
I am coding an application where i need to assign random date between two fixed timestamps
how i can achieve this using php i've searched first but only found the answer for Java not php
for example :
$string = randomdate(1262055681,1262055681);
...
I have an id in the url. So normally it will be an auto number and so it will be 1,2,3,4,5,.....
I don't want visitors to figure out the sequence and so i want to let the number be kinda of random. So i want 1 to be converted to 174891 and 2 to 817482 and so on. But i want this to be in a specique range like 1 to 1,000,000.
I f...
I need to random some elements from an array. I'm doing that by randomizing the index $array[int(rand(100))]. I want some of the elements to appear more often. How do I do it?
I thought of a stupid solution of having those elements duplicated several times in the array, but I'm sure you guys can do better.
...
From this Wikipedia article:
http://en.wikipedia.org/wiki/Hamiltonian_path_problem
A randomized algorithm for Hamiltonian
path that is fast on most graphs is
the following: Start from a random
vertex, and continue if there is a
neighbor not visited. If there are no
more unvisited neighbors, and the path
formed isn't Hami...
I need to display some random data (1 row) from MySQL table and performance is very important for me. It doesn't necessarily has to be absolutely unique and super random data, so I have two options:
1) Query the database (my table has > 500 000 rows);
2) Automatically once a week create a flat text file (or php file with an array) from...
Note: For brevity's sake, the following will not discern between randomness and pseudo-randomness. Also, in this context, 'constrained' means 'between given min and max values')
The System.Random class provides random generation of integers, doubles and byte arrays.
Using Random.Next, one can easily generate random constrained values o...
OK I have this query which gives me DISTINCT product_series, plus all the other fields in the table:
SELECT pi.*
FROM (
SELECT DISTINCT product_series
FROM cart_product
) pd
JOIN cart_product pi
ON pi.product_id =
(
SELECT product_id
FROM cart_product po
WHER...
Looking to shuffle four variables (trying to change the order they appear in on a multiple choice list).
I've been poking around for a while but I can't quite get my head around the logic, and looking up random shuffles in past questions gives super-detailed algorithms that are beyond my newbie skills (and the needs of this program I'm ...
I have a list[] of items from which I'd like to display one randomly, but the displayed item must not repeat more than once in last x requests.
list1 = item1, item2, item3, item4,
item5, item6, item7, item8, item9,
item 10
Display a random selection
from the list above
list2 = store the last displayed item in list2 which should only...
Hi All,
I have an ArrayList, and I need to be able to click a button and then randomly pick out a string from that list and display it in a messagebox.
How would I go about doing this? Any help at all is greatly appreciated.
Thank you
Bael
...