search
HomeCommon ProblemHow to generate random numbers in matlab

How to generate random numbers in matlab

Mar 07, 2020 pm 05:09 PM
matlabrandom number

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.

How to generate 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:

How to generate random numbers in matlab

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:

How to generate random numbers in matlab

##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:

How to generate random numbers in matlab

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-N

Example:

How to generate random numbers in matlab

5, exprnd (mu ,m, n)

Produces m*n order expected value A random number matrix of exponential distribution for mu

Example:

How to generate random numbers in matlab

There are also some other random numbers, which will not be introduced here. The methods are other This is similar to

For more related programming tutorials, please pay attention to

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

mPDF

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),