Matlab is a commonly used software for us. Friends who do random processes or probability often use some random numbers. But how are these data generated? The following introduces some common random numbers in matlab.
Methods that matlab can use to generate random numbers:
1. Uniform distribution:
■ unifrnd (a, b, m, n)
Generate m*n order [a, b] uniform distribution
■ unifrnd (a,b )
Generate a uniform random number [a,b]
Recommended study "Introduction to Programming"
Example:
2. rand (m, n);
produces m*n order [0, 1] uniformly Distributed random number matrix
■ rand(n);
Generate n*n order [0,1] uniformly distributed random numbers
Example:
##3、binornd(n,p,[M,N,P,...])
The generated numbers are random numbers that obey the binomial distribution. The parameters of the binomial distribution are: n and p.Consider a target shooting example. Each shot The hit rate is p, and a total of N guns are fired, then the total number of hits obeys the binomial distribution with parameters (N, p). Note that p must be less than or equal to 1 and non-negative, and N must be an integer. ■ binornd(n,p,[M,N,P,...])
The generated random numbers obey the binomial distribution with parameters (N, p) , these random numbers are arranged into an M*N*P... order matrix. If only M is written, an M*M matrix will be generated;Example:
4, unidrnd(N, m,n)
Generate an m*n order discrete uniformly distributed random number matrix; generate an mm*nn matrix with a value between 1-NExample:
5, exprnd (mu ,m, n)
Produces m*n order expected value A random number matrix of exponential distribution for muExample:
PHP Chinese website!
The above is the detailed content of How to generate random numbers in matlab. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),