8
голосов
8ответов
21541 просмотров

How do I generate random numbers in a microcontroller efficiently?

How do I generate random numbers in a microcontroller efficiently? Are there any general guidelines or a particular fast method?

15
голосов
7ответов
20377 просмотров

Generating random number between [-1, 1] in C?

I have seen many questions on SO about this particular subject but none of them has any answer for me, so I thought of asking this question. I wanted to generate a random number between [-1, 1]. How I can do this?

0
голосов
3ответов
2247 просмотров

Random background image on DIV

I'm trying to get a randomly picked background image (from a selection of 4 images) to appear as the background image for a asp.net panel. The problem I have is that the code works when stepping through the code in debug mode. Once you run the code on the website without debugging, all the image...

15
голосов
6ответов
7291 просмотров

How different do random seeds need to be?

Consider code like this (Python): import random for i in [1, 2, 3, 4]: random.seed(i) randNumbers = [random.rand() for i in range(100)] # initialize a list with 100 random numbers doStuff(randNumbers) I want to make sure that randNumbers differ significantly from one call to anoth...

0
голосов
3ответов
2330 просмотров

Draw different shape of polygon randomly

My program draw 10 polygon triangles in random sizes (width and height). The coordinate (points) of the polygon were generated using Random generator = new Random(). Since the points of the triangle and the width and height were randomly generated, how can I control the number of sizes drawn? e.g...

6
голосов
3ответов
6774 просмотров

How do you generate cryptographically secure random numbers with PHP?

Possible Duplicate: Secure random number generation in PHP We need to generate a cryptographically random string to use as an authentication token, which will be tied to session data in the database. We are using PHP, which doesn't appear to have a suitable random number generator bui...

9
голосов
13ответов
8865 просмотров

Generate two numbers that are NOT equal in PHP

I need to generate two numbers that are NOT equal in PHP. I know that I use $random1 = (rand()%9); to generate random a number between 0-9. I need to add something to this I guess. Thanks!

2
голосов
3ответов
1581 просмотров

Selecting random in rails sqlite vs mysql

Hey guys, I'm trying to select random data from the database in Ruby on Rails. Unfortunately, sqlite and mysql use different names for the "random" function. Mysql uses rand(), sqlite use random(). I've been pretty happy using sqlite in my development environments so far, and I don't want to give...

6
голосов
7ответов
21340 просмотров

Generate random strings in vb.net

I need to generate random strings in vb.net, which must consist of (randomly chosen) letters A-Z (must be capitalized) and with random numbers interspersed. It needs to be able to generate them with a set length as well. Thanks for the help, this is driving me crazy!

1
голосов
6ответов
1548 просмотров

Obscure VBMath random numbers generator behavior

I want to repeat a random number sequence generated by a legacy software using the VBMath.Rnd and VBMath.Randomize functions in VB .NET Reading on the documentation for those functions on MSDN i found that you are supposed to "reset" the generator calling Rnd with a negative value if you want th...

5
голосов
4ответов
7330 просмотров

Simple Pseudo-Random Algorithm

I'm need a pseudo-random generator which takes a number as input and returns another number witch is reproducible and seems to be random. Each input number should match to exactly one output number and vice versa same input numbers always result in same output numbers sequential input numbers t...

6
голосов
11ответов
4111 просмотров

Crappy Random Number Generator

This may sound like an odd question, but where can I find a random number generator that works in C or C++ that is not very good? Context: I'm creating some tree graph plotting software and testing it by using multi-digit random numbers (so each digit becomes a node in the tree). The random numb...

5
голосов
8ответов
3796 просмотров

Non-Uniform Random Number Generator Implementation?

I need a random number generator that picks numbers over a specified range with a programmable mean. For example, I need to pick numbers between 2 and 14 and I need the average of the random numbers to be 5. I use random number generators a lot. Usually I just need a uniform distribution. I do...

3
голосов
1ответов
2361 просмотров

Cannot shuffle list in Python

This is my list: biglist = [ {'title':'U2','link':'u2.com'}, {'title':'beatles','link':'beatles.com'} ] print random.shuffle(biglist) that doesn't work! It returns none.

2
голосов
6ответов
5518 просмотров

TSQL Generate 5 character length string, all digits [0-9] that doesn't already exist in database

What's the best way to do this? I need to generate a 5 digit length string where all the characters are numeric. However, I need to be able to do this 'x' amount of times (user variable) and store this random strings in a database. Furthermore, I can't generate the same string twice. Old stri...

2009
голосов
35ответов
1334421 просмотров

Generating random whole numbers in JavaScript in a specific range?

How can I generate random whole numbers between two specified variables in JavaScript, e.g. x = 4 and y = 8 would output any of 4, 5, 6, 7, 8?

8
голосов
5ответов
12268 просмотров

Does anyone know a way to scramble the elements in a list?

thelist = ['a','b','c','d'] How I can to scramble them in Python?

7
голосов
8ответов
8265 просмотров

Weighted Random Number Generation in C#

Question How can I randomly generate one of two states, with the probability of 'red' being generated 10% of the time, and 'green' being generated 90% of the time? Background Every 2 second either a green or a red light will blink. This sequence will continue for 5 minutes. The total number of oc...

1
голосов
2ответов
1403 просмотров

How to generate a RNGCryptoServiceProvider-like number in TSQL

Does anyone know of a way to generate a RNGCryptoServiceProvider-like random number in T-SQL without having to register any .NET Assemblies?

235
голосов
29ответов
442542 просмотров

Random shuffling of an array

I need to randomly shuffle the following Array: int[] solutionArray = {1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1}; Is there any function to do that?

1
голосов
3ответов
1248 просмотров

Generating the same random SecretKey twice

I have a need to generate a random SecretKey, in Java, which I will be able to regenerate at some future point. The idea is that this key is unique to the machine on which it is created and isn't stored anywhere. I'm attempting something like this: KeyGenerator keyGen = KeyGenerator.getInstance(...

4
голосов
7ответов
1407 просмотров

Most Efficient Way to... Unique Random String

I need to efficently insert a 5 character RANDOM string into a database while also ensuring that it is UNIQUE. Generating the random string is not the problem, but currently what I am doing is generating the string and then checking the DB if it exists already... if it does, I start over. Is th...

0
голосов
5ответов
5772 просмотров

php rand() array

I need to be able to pull a random value out of my array, let's assume i have array with 100 values, how can i pull randomly 5 values out of this array?

25
голосов
6ответов
57507 просмотров

Random number: 0 or 1

Am I looking too far to see something as simple as pick a number: 0 or 1? Random rand = new Random(); if (rand.NextDouble() == 0) { lnkEvents.CssClass = "selected"; } else { lnkNews.CssClass = "selected"; }

2
голосов
4ответов
1224 просмотров

generating random alphabets with some alphabets having a higher frequency of occurence(vc++6.0)

basically i have a function that generates random alphabets .i have done this using the rand() function to generate numbers and them converted them to their corresponding ascii equivalents. but i want the vowels to be generated in higher numbers as compared to other alphabets.i.e if have generate...

460
голосов
54ответов
630906 просмотров

Random color generator

Given this function, I want to replace the color with a random color generator. document.overlay = GPolyline.fromEncoded({ color: "#0000FF", weight: 10, points: encoded_points, zoomFactor: 32, levels: encoded_levels, numLevels: 4 }); How can I do it?

18
голосов
7ответов
18632 просмотров

What's the best practice for getting a random DateTime between two date-times?

I'm trying to randomize the value for a simple DateTime data field. I wish to get a random date/time between two date/times (e.g. min date/time and max date/time). So lets imagine I'm after a random date/time between 1/1/2000 10:00:00am and 1/1/2000 5:00:00pm. Also, this code will be used in ...

15
голосов
14ответов
7514 просмотров

In PHP, how do I generate a big pseudo-random number?

I'm looking for a way to generate a big random number with PHP, something like: mt_rand($lower, $upper); The closer I've seen is gmp_random() however it doesn't allow me to specify the lower and upper boundaries only the number of bits per limb (which I've no idea what it is). EDIT: Axsuuls a...

26
голосов
8ответов
18669 просмотров

Generate random UTF-8 string in Python

I'd like to test the Unicode handling of my code. Is there anything I can put in random.choice() to select from the entire Unicode range, preferably not an external module? Neither Google nor StackOverflow seems to have an answer. Edit: It looks like this is more complex than expected, so I'll r...

39
голосов
12ответов
21135 просмотров

A Good and SIMPLE Measure of Randomness

What is the best algorithm to take a long sequence of integers (say 100,000 of them) and return a measurement of how random the sequence is? The function should return a single result, say 0 if the sequence is not all all random, up to, say 1 if perfectly random. It can give something in-between...