Search 5,000,000+ questions and answers.

Frequently Asked Questions

How do I generate a random integer from 1 to N?

comp.lang.javascript FAQ - 9.91 - 2008-01-19
Method Math.random() returns a value R such that 0 <= R < 1.0 ; therefore function Random(x) { return Math.floor(x*Math.random()) } gives an evenly distributed random integer in the range from 0 to x-1 inclusive; use Random(N)+1 for 1 to N.
Related Questions

How to generate values from a normally distributed random variable?

FAQ 5
There are several ways in which to do this. You may use the spreadsheet formulas to fill a variable with random values from a normal distribution with a given mean and standard deviation. This is accomplished by using the inverse function for the normal distribution (vnormal(x)).
Related Questions

How can I generate a random number?

Allegro - Documentation - Frequently asked questions
Call srand(time(NULL)) at the beginning of your program, and then use rand()%limit to obtain a pseudo-random number between 0 and limit-1. There is no need. The linker will only include the parts of the library that you actually use, so if you don't call any of, say, the texture mapping or FLIC playing functions, they will be left out of your executable.
Related Questions

How do I generate random numbers in Python?

Python Library and Extension FAQ
The standard module random implements a random number generator. Usage is simple: import random random.random()
Related Questions

How can I generate random numbers?

A common mistake is to just plug the time of day into a simple PRNG. Those random number generators are fine for doing numerical simulations, but not for cryptography. You need to use a hardware RNG, or use unpredictable data like mouse movements, or use suitable system calls such as to a /dev/random driver, or something similar. For more discussion, see: http://www.cs.berkeley.edu/~daw/rnd/
Related Questions

Why would I generate a random graph?

Frequently Asked Questions
This is a quick way for a visitor to get a live sample of what the web site has to offer. When a visitor clicks the generate a random graph button, WebGraphing.com returns a complete graph of a randomly generated polynomial function up to degree 3 along with descriptive answers in The Analyzer that explain the mathematics needed to produce the graph by hand.
Related Questions

DO YOU HAVE SYSTEMS OR 3 N 1 JACKETS?

Frequently Asked Questions
No...a simple answer to a complex question. We certainly understand the concept and the interest but we simply feel that in the long run, a simple layering approach gives you more flexibility. We learned a long time ago that anything that snaps off or on...or zips in and out...can a.) become unsnapped or unzipped and be lost or left behind or somehow misplaced. b.) the attachment mechanism can become worn or damaged and no longer function..
Related Questions

Can I dynamically allocate a 2-byte integer array of size n?

F.A.Q.: HicEst - Fortran incremental compiler and interprete...
Yes. Size is only limited by virtual memory. ALLOCATE a string of length 2*n. (Partial) conversion to 8-byte floating point (as used by HicEst for all numerics) is via READ and WRITE with the binary format "ib2". Or have the array as a file on disk. If the array has e.g. 23 columns, OPEN(File=arrayname,binary,Format="23ib2") and access with arrayname(row,column) for read and write. Yes, computers with a COM port can be linked like any other instrument with a RS232 interface.
Related Questions

How To Generate Random Numbers with the RAND() Function?

SQL Server DBA FAQs and Tips - 400 Questions/Tutorials &laqu...
A collection of 14 FAQs on Transact-SQL language character string and binary string operations. Clear answers are provided with tutorial exercises on concatenating character/binary strings; converting Unicode character strings; converting binary strings; inserting new line characters; locating and taking substrings; bitwise operations.
Related Questions

Is there a function in verilog to generate random numbers?

EE271/272 Verilog FAQ
Yes. It is $random(seed). The seed is optional. The random number sequence for a given seed (or no seed) will always be the same. This means that in hooking together your verilog modules you did something wrong. On one of your connections, the number of bits that your module expects on a certain port does not match the number of bits of the thing that you hooked it up to.
Related Questions

How do I convert a real number (e.g. 1.0) to an integer (1) format?

ECLiPSe Programming FAQ
Often you'll want to round the real number appropriately first (round/2, floor/2, ceiling/2) rather than relying on fix's truncation. See the documentation for is/2 and fix/2.
Related Questions

Is the "Divide-by-N" feature in selectable in single integer steps? What is the range?

BNC | FAQ | Model 400/500/555 | Frequently Asked Questions (...
Yes, you can input any integer( i.e. input 512 as N to get 1/512 the frequency). The range is 1-50,000. Clock Out, when enabled, provides a TTL 10 MHz clock that is phase locked to the internal 10 MHz clock. Push FUNCTION and MODE twice to get to the clock menu. Clock in, when enabled, accepts a TTL 10 MHz clock that will be used as the internal 10 MHz reference clock. This allows the internal clock to be phase locked to an external source. Thus removing the jitter and drift between the two.
Related Questions

How do you decide which integer type to use?

Infrequently Asked Questions in comp.lang.c
Use ''short'' when you need to avoid values over 32,767, ''int'' when you want to store integers, ''long'' for long numbers (more than 6 digits), and ''float'' for numbers over 4 billion.
Related Questions

How can I generate a random position of a cell in a matrix?

The BUGS Project - FAQ Lists
Suppose the matrix is 3 rows by 4 columns, and you sample CELL using dcat and get a number between 1 and 12, which you want to convert to a row and a column. There are two solutions:
Related Questions

How can I generate random numbers with a normal or Gaussian distribution?

Frequently Asked Questions: C Language (abridged)
Some semistandard functions have been renamed or replaced over the years; see the full list for details. I'm still getting errors due to library functions being undefined, even though I'm requesting the right libraries.
Related Questions

Was there any meaning to Random's "quotes" and what tool was used to generate them?

Project Mu : FAQ
Credit goes to SpaceBass for clarifying that character and finding a neat hook for him. We were writing the first hacker convo, and I had to leave to go to rehearsal. When I came back, he had Random spouting gibberish in all-caps, and I thought, "Random's a kook, man." Various tools and tweaking were used to generate his content. Some of the players at the Unfiction forums found many of the source pages.
Related Questions

How to generate number of exclusive random number in a range?

FAQ on C/C++/Unix by Roseanne Zhang
I learned it from a Chinese forum. int* getExclusiveRandom(int min, int max, int num) { int range = max-min; if (num > range) return NULL; int nn[range]; int i, t; for (i = 0; i < range; i++) { nn[i] = i + min; } int* out = (int*)malloc(sizeof(int)*num); long tt; srand((unsigned)time(&tt)); for (i = 0; i < num; i++) { t = rand() % range; out[i] = nn[t]; nn[t] = nn[--range]; } return out; }
Related Questions

Does Magsbot have a way to generate random numbers?

Magsbot Help
Yes, there is a random number operator, #, that you can use in numeric expressions. The operator works like a die roll, with the first number being the number of dice and the second number being the type of die. So example, a random number similar to a roll of 3 six-sided dice (or "3d6" in role-playing game terminology) would be expressed as 3#6. More simply, a random number from 1 to 100 would be 1#100. A number from 3 to 7 would be 1#5+2.
Related Questions

How is it possible for a computer to generate non-deterministic or True random numbers?

ComScire - The Random Number Generator Company.
The PCQNG uses a noise component or jitter produced by Phased Locked Loop circuits in the PC which can be precisely determined.? This jitter is the source of true entropy which is extracted to produce a sequence of true random numbers.? See Design Principles and Testing of the PCQNG 2.0 Device for a detailed technical explanation.
Related Questions

What is redundancy (n+1) power supply?

FSP (GB) Ltd. of FSP GROUP
Redundancy (n+1) power supply connected in parallel operation so that if one fail the other will continue delivered enough current to supply the maximum load. This method suits in the applications where power supply failure cannot be tolerated.
Related Questions

Is it possible to simulate [N 1 1] growth direction?

FAQ
Yes, but don't confuse the axes-possible specifier with the Miller indices. Change these to [N 1 1] for other directions. The specifier axes-possible is only applicable to the growth direction which must be x, y or z as indicated. However, you can choose [3 1 1] to be the Miller x axis and then choose x axis as growth direction which will then be [3 1 1].
Related Questions

Why is the Show so Random?

FAQs
All shows on the Adult Swim Lineup are very random and ATHF is no exception to the randomness. Turner Broadcasting relies on those who find shows like ATHF very funny because of its randomness. I am one of them. ATHF's randomness compared to other Adult Swim shows. I would probably rate it in the middle. It is much more random than Family Guy but no where near the Randomness of Harvey Birdman, Attorney at Law. top
Related Questions

What is [n]etiquette?

The OpenVMS Frequently Asked Questions (FAQ)
Before posting or emailing a question, please use the available local resources, such as the OpenVMS manuals, the HELP, and the resources and information in and referenced by this FAQ. See Section 1.1, for instance. Please (try to) use these first. When posting, please consider the etiquette/netiquette suggestions that are available in RFC 1855, a document available at various sites including: http://www.ietf.org/rfc/rfc1855.txt . Rather, please report these problems directly to HP.
Related Questions

Why does the random number seed stay the same? Can you not generate a new seed automatically?

Frequently Asked Questions
The random number seed allows one to reproduce an analysis. By default, it is set to 1234567. However, if one uses the default seed for every analysis, then the same sequence of permutations are generated. This is not always desirable. It would appear that generating a seed randomly using the clock or some such mechanism without bothering the user for input might be better. Not necessarily.
Related Questions

Got A Question? Ask Our Community!


More Questions >>

© Copyright 2007-2008 QueryCAT
About • Webmasters • Contact