Matlab Rand Randn Randint

Source: Internet
Author: User

The RAND function in 1.0matlab produces a random distribution of 0 to 1
The RANDN function in 2.0matlab produces a standard normal distribution
3.0randint is the generation of integer random numbers, default 0 and 1
1.0rand

%%%%%%%%%%%rand%%%%%%%%%%%%%%%%
RAND uniformly distributedrandomnumbers. Random numbers for standardized distributions
RAND (N) Isan n-by-n matrix with random entries, chosen from a uniformdistribution on the interval (0.0,1.0). RAND (n) randomly generates an N-dimensional random matrix between "0,1".
Rand (M,N) and Rand ([M,n]) is m-by-n matrices with randomentries. Randomly generates a 0,1-dimensional random matrix between "M,n".
Rand (M,n,p,...) or rand ([m,n,p,...]) generate random arrays.
RAND with noarguments are a scalar whose value changes each Timeit is referenced. RAND (SIZE (A)) is the same sizeas A.

Randproduces pseudo-random numbers.  The sequence ofnumbers generated is determined by the state ofthe generator. Since MATLAB resets the state at start-up, the sequence of numbers Generatedwill is the same unless the state ischanged. The random number algorithm of MATLAB is introduced by a "seed", and the seed is the same at the beginning of the program.
S =rand (' state ') is a 35-element vector containing the currentstate of the uniform generator. RAND (' state ', s) resets the state to S.
RAND (' state ', 0) resets the generator to its initial states. Restore the initial state, just run matlab
RAND (' state ', j), for integer J, resets the generator to its j-thstate. Arrange the seed to produce the first J state
RAND (' state ', sum (100*clock)) resets it-a different state eachtime. Generate different random numbers based on time
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

2.0randn

%%%%%%%%%%%%%%%%%%randn%%%%%%%%%%%

(1) Randn The syntax for generating a normal distribution number:
Randn (N): The matrix that produces the NXN, whose elements are in an array of normal distributions;
RANDN (M,n) and RANDN ([M,n]): a matrix producing MXN;
RANDN (m,n,p,...) or RANDN ([m,n,p ...]) Generate random sequences;

(2) Randn generates pseudo-random number syntax:
The state of the generator determines the number of the generated numbers.
S = Randn (' state ') is a two-element vector that includes the status of the standard generator;
RANDN (' state ', s): Sets the status of the generator to S (i.e. standard state);
RANDN (' state ', 0): Sets the initial status of the generator;
RANDN (' state ', J): J is an integer that sets the generator to the J-order status;

(3) MATlAB 4.X applies a single seed to generate random numbers:
RANDN (' seed ', 0) andrandn (' Seed ', j) acts like Randn (' state ', 0) and Randn (' state ', j), but uses the matlab4.x random number generator.
RANDN (' seed '): Returns the current seed of the Matlab 4.X generator.

%%%%%%%%%%%%%%%%%%randn%%%%%%%%%%%

Matlab Rand Randn Randint

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.