I already know there's answers for this kind of thing, but I don't really know how to implement them in my code. Also, I would like to refrain from using any more functions unless neccessary.
Here's my code:
int main()
{
unsigned seed;
seed = 1;
srand(seed);
std::string starFox[8];
int x[8];
starFox[0] = "Do a barrel roll!";
sta...
I read that the random number generator dev/random on Mac and Solaris includes 160 bits of entropy. What can I do, if I need more entropy, for example, 200 bits? Thanks in advance
...
Hey,
Here's my basic problem. Let's say I have 50 employees working on a certain day, and I want my program to randomly distribute them to a "position" (I.e.: front desk, phones, etc) based on what they have been trained on. The program already knows what each employee has been trained on. What is the best method pragmatically to go thro...
I am trying to get a random object within linq. Here is how I did.
//get all the answers
var Answers = q.Skip(1).Take(int.MaxValue);
//get the random number by the number of answers
int intRandomAnswer = r.Next(1, Answers.Count());
int count = 0;
//locate the ans...
I want to create a game with a level structure similar to iCopter or Canabalt, where each level has a randomized floor (and roof), but the height of the floor is never impossible to reach from the previous one. I am also unsure on how to continually increase difficulty. I have searched far and wide for a tutorial or something like that, ...
I am working on Problem 14 on Project Euler, and my code seems to freeze at random intervals for no apparent reason.
static void Main()
{
int maxNum = 0;
int maxLength = 0;
for (int x = 2; x < 1000000; ++x)
{
int num = x;
int length = 0;
while (num != 1)
{
if (num % 2 == 0)
...
Is it possible to get random items inside the same day?
For example:
+----+---------------------+
| id | md |
+----+---------------------+
| 1 | 2010-06-27 11:26:01 |
| 2 | 2010-06-27 11:28:20 |
| 3 | 2010-06-27 11:29:46 |
| 4 | 2010-06-27 11:30:50 |
| 5 | 2010-06-27 12:20:56 |
| 6 | 2010-06-...
Possible Duplicate:
System.Random keeps on returning the same value
I'm refactoring and expanding a small C# agent-based model to help some biology professors predict the spread of a disease. Each year of the simulation each individual agent randomly travels to a nearby population node, possibly spreading the disease. I'm br...
I know there is this question that is very similar, but I wanted to add my specific situation and see if the answer is different.
I've read that you can simply do ORDER BY RAND() but that that is a bad idea for large tables. However, I can limit my rows to a max of about 160 with the WHERE clause. So the question is, is the WHERE clause...
I want a random number generator with non-uniform distribution, ie:
// prints 0 with 0.1 probability, and 1 with 0.9 probability
echo probRandom(array(10, 90));
This is what I have right now:
/**
* method to generated a *not uniformly* random index
*
* @param array $probs int array with weights
* @return int a random index in $p...
I'm trying to use shingleprinting to measure document similarity. The process involves the following steps:
Create a 5-shingling of the two documents D1, D2
Hash each shingle with a 64-bit hash
Pick a random permutation of the numbers from 0 to 2^64-1 and apply to shingle hashes
For each document find the smallest of the resulting valu...
I have a table with user_ids that we've gathered from a streaming datasource of active accounts. Now I'm looking to go through and fill in the information about the user_ids that don't do much of anything.
Is there a SQL (postgres if it matters) way to have a query return random numbers not present in the table?
Eg something like this:...
is there a way to show a certain amount of random records from a database table, but heavily influenced by the date and time of creation.
for example:
showing 10 records at random, but
showing latest with more frequency than the earliest
say there are 100 entries in the news table
latest (by date time) record would have an almost 100%...
I'm working on Pong in C# w/ XNA.
I want to use a random number (within a range) to determine things such as whether or not the ball rebounds straight, or at an angle, and how fast the ball moves when it hits a paddle.
I want to know how to implement it.
...
What is the most elegant way to grab unique random numbers I ponder?
At the moment I need random unique numbers, I check to see if it's not unique by using a while loop to see if I've used the random number before.
So It looks like:
int n = getRandomNumber % [Array Size];
for each ( Previously used n in list)
Check if I've used n...
Can anyone recommend a good math library for use with F#?
I am looking for the moment for something with statistical distributions, but obviously as needs grow, a fuller library will be useful. Something not unlike Numpy for Python for example.
I searched and came across the Math.Net project.. They have a new library math.net which see...
What is the most efficient way to generate a large (~ 300k vertices) random planar graph ("random" here means uniformly distrbuted)?
...
Hi,
I am looking to create a function that gets me a random item from a mySQL table, but let's me keep the returned as the "item of the day". In other words, the item that was "the item of the day" yesterday should not be shown again until all other items have been shown as item of the day.
Any suggestions on how to do this in an eleg...
I used to ask a similar question once. Now I'll be more specific. The purpose is to learn a Haskell idiom to write iterative algorithms with monadic results. In particular, this might be useful for implementing all kinds of randomized algorithms, such as genetic algorithms and a like.
I wrote an example program that manifests my problem...
I'm using procedural techniques to generate graphics for a game I am writing.
To generate some woods I would like to scatter trees randomly within a regular hexagonal area centred at <0,0>.
What is the best way to generate these points in a uniform way?
...