answersLogoWhite

0

There are many different ways of generating pseudo random numbers. Some of them are good. Some of them are not so good. It depends on the application. For a good read on this topic, I suggest "The Art Of Computer Programming", Donald E. Knuth, Volume 2, Seminumerical Algorithms.

One of the simpler way of generating pseudo random numbers is the linear congruential generator, wherein XN+1 = (AXN + B) mod C. Of course, the choice of A, B, and C is crucial to a successful implementation. Knuth has a lot to say about this generator, including the fact that it is sequentially correlated and, thus, not well suited for some applications. Nevertheless, many random number generators use this method, and they use some techniques for minimizing correlation and maximizing period. The technique used in one of the Microsoft Visual Studio runtime libraries has A=0x343FD, B=0x269EC3, and C=0x100000000, however, the return value is the value of X right shifted 16 places and AND'ed with 0x7FFF, forcing a return value between 0 and 32767, but a period much larger than that.

int rand(unsigned *seed) { /* assumes unsigned is 32 bits */

*seed = *seed * 0x343FD + 0x269EC3;

return (*seed >> 16) & 32767;

}

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

Why it is called as logic function generator?

this generator operates using logical function thats why is called as logic function generator


What operator raises a number to a power?

Exponent (its the following symbol when programming ^ ) page 46 Programming Logic and Design by Tony Gladdis


What has the author James H Andrews written?

James H. Andrews has written: 'Logic Programming' -- subject(s): Automatic theorem proving, Logic programming, Programming languages (Electronic computers), Semantics 'Proof-Theoretic Characterisations of Logic Programming'


What has the author Isaac Balbin written?

Isaac Balbin has written: 'Logic programming' -- subject(s): Bibliography, Logic programming


What has the author Akikazu Takeuchi written?

Akikazu Takeuchi has written: 'Parallel logic programming' -- subject(s): Parallel logic programming


What is ladar in robotics?

Ladder logic is the programming scheme used when programming most control systems, such as robotic controllers. It's most common when programming a PLC (Programmable Logic Controller)


What has the author James Messinger written?

James Messinger has written: 'The logic and design of computer programs' -- subject(s): Logic programming, Computer programming


What has the author S -H Nienhuys-Cheng written?

S. -H Nienhuys-Cheng has written: 'Foundations of inductive logic programming' -- subject(s): Logic programming, Induction (Logic), Machine learning


What has the author A Voronkov written?

A. Voronkov has written: 'Logic Programming: First Russian Conference on Logic Programming, Irkutsk, Russia, September 14-18, 1990'


What is Advantage of logic analyzer with built in digital pattern generator over simulator?

logic analyzer advantages


What is difference between parity checker and parity generator?

A parity generator checks the data to be transmitted and outputs a 0(parity bit) if the number of logic 1's in the data is even, and a logic 0 if the number is odd. So a checker takes the transmitted data and the parity bit and will compare the two, and if they are both of the same logic then the you can conclude that the data was recieved succesfully(i.e no bits were lost during transmission). Parity checker/generator use the exact same devices, but with one comparing instead of generating.


Programming logic and design review questions?

anjum