English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2006-07-30 04:53:49 · 11 answers · asked by Anonymous in Science & Mathematics Mathematics

Sorry, I mean psuedo-random integers.

2006-07-30 06:40:44 · update #1

11 answers

Multiplicative Linear Congruential Generator (MLCG)

The most popular algorithm for generating random numbers on computers is the MLCG (Multplicative Linear Congruential Generator). Starting with a seed value.

float Uniform()
{
int z,k;
k = s1 / 53668;
s1 = 40014 * (s1 - k * 53668) - k * 12211;
if (s1 < 0) s1 = s1 + 2147483563;
k = s2 / 52774;
s2 = 40692 * (s2 - k * 52774) - k * 3791;
if (s2 < 0) s2 = s2 + 2147483399;
z = s1 - s2;
if (z < 1) z = z + 2147483562;
return z * 4.65661305956E-10;
}

This algorithm is quite old now, but it's very brief and reliable. This is the one to use if you're in a hurry and want random numbers that are probably far superior to the ones generated by you compiler's library routines.

http://www.google.com.sg/search?hl=en&sa=X&oi=spell&resnum=1&ct=result&cd=1&q=basic+random+number+algorithm&spell=1

2006-07-30 05:16:55 · answer #1 · answered by ideaquest 7 · 2 0

programs come with built in random number generators that generate what are called pseudo random numbers. not truly random but still good enough for most purposes. They usially give decimal values between 0 and 1. so if you want numbers between 0 and 100 you multiply by 100 and use an 'integer' function to get rid of the decimals

2006-07-30 05:06:24 · answer #2 · answered by wvl 3 · 0 0

The standard ANSI C or C++ library contains a pseudo random number generator. The one in the old C lib was not terribly random, but was good enough for some things.

There are sample programs with some explanation, in the book "Numerical Recipes" written by a few Harvard(?) professors. I think they have a web site also.

2006-07-30 06:45:49 · answer #3 · answered by Tom H 4 · 0 0

you could't write a application to generate "random" integers. Any set of guidelines you take advantage of will be deterministic and hence no longer random. you could merely generate pseudo-random numbers. Now then, there are any variety of techniques to generate random appearing numbers. maximum programming languages have some variety of random function that does this. you merely ought to finished a touch math to get numbers in the wanted determination. Shadow Wolf

2016-11-26 23:41:54 · answer #4 · answered by ? 4 · 0 0

Its not possible to generate totally random integers, although pseudo random numbers can be generated by applying feedback formulae.

2006-07-30 05:01:21 · answer #5 · answered by ag_iitkgp 7 · 0 0

If you research this online you can find programs supposedly designed to do this, but these are based on formulae and not truly random(they only appear to be). It is my understanding that a computer can not generate random numbers. Likewise, any mathmatical formulae that seems to generate random numbers can not by definition do so.

2006-07-30 04:59:46 · answer #6 · answered by RunningOnMT 5 · 0 0

You can never generate random integers computationally. It can only be done mannually.

2006-07-30 05:37:24 · answer #7 · answered by Anonymous · 0 0

maybe just calculate pi and use those numbers as integers. I think they are pretty random , 3.14159.... etc

2006-07-30 04:57:35 · answer #8 · answered by kurticus1024 7 · 0 0

Use the tool on this site:
http://www.random.org/nform.html

2006-07-30 05:00:14 · answer #9 · answered by Anonymous · 0 0

go and sleep dream thats enough

2006-07-30 04:59:04 · answer #10 · answered by Huma 2 · 0 0

fedest.com, questions and answers