Linear congruence algorithm of pseudo-random generation

Source: Internet
Author: User
Tags generator
Defined:

Pseudo-random number: A numerical sequence produced by a mathematical formula or algorithm. Although pseudo-random numbers are not random in mathematical sense, they can be used as true random numbers if they can be statistically verified. algorithm:

The most basic idea of pseudo-random number generation is the uniform distribution (of course, this is not the only idea). Generally speaking, the random number function used in the mainstream programming language is basically using this idea of uniform distribution, and the most commonly used algorithm is "linear with congruential". The pseudo-random number generator is as follows:

xn= (axn−1+b) mod (m)
The a,b,m are constants set by the generator, with a period of M.

High performance linear congruence algorithm parameter values:
(1) multiplier a satisfies a=4p+1, and Delta B satisfies b=2q+1. Where p,q are positive integers.
(2) The M-value is preferably larger, the M-value directly affects the period of the pseudo-random number sequence.
(3) The greater the value of a and B, the more evenly the pseudo-random number is generated.
(4) A and M coprime, the resulting random number effect is less coprime good.

Resources:
Http://www.cnblogs.com/forget406/p/5294143.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.