当前位置:网站首页>Generate random numbers that obey normal distribution
Generate random numbers that obey normal distribution
2022-07-02 03:18:00 【RS&Hydrology】
1.matlab in normrnd function
function : Generating random numbers that obey normal distribution
grammar :
R=normrnd(MU,SIGMA)
R=normrnd(MU,SIGMA,m)
R=normrnd(MU,SIGMA,m,n)
say bright :
- R=normrnd(MU,SIGMA): The generation follows a normal distribution (MU The parameter represents the mean value ,SIGMA The parameter represents the standard deviation ) The random number . Input vector or matrix MU and SIGMA Must be in the same form , Output R Also in the same form as them . The scalar input will be expanded into a matrix with the same dimension as other inputs .
- R=norrmrnd(MU,SIGMA,m): The generation follows a normal distribution (MU The parameter represents the mean value ,SIGMA The parameter represents the standard deviation ) Of
Random number matrix , The form of the matrix is determined by m Definition .m It's a 1×2 vector , Two of these elements represent the return value R The dimension of rows and columns in . - R=normrnd(MU,SIGMA,m,n): Generate m×n A matrix of random numbers in the form of normal distribution .

2.python in np.random.multivariate_normal
Definition :def multivariate_normal(mean, cov, size=None, check_valid=None, tol=None)
mean: Dimension of multivariate normal distribution ;n Mean value of dimensional distribution ;
cov: Covariance matrix of multivariate normal distribution , Be careful : The covariance matrix must be symmetric and positive semidefinite ( Shape is (N,N) Two dimensional array of );
size: Specify the dimension of the generated normal distribution matrix ( example : if size=(1, 1, 2), Then... Of the output matrix shape That is, the shape is
1X1X2XN(N by mean The length of )).check_valid: This parameter is used to determine when cov That is, the processing method of the program when the covariance matrix is not a positive semi definite matrix , It has three values :warn,raise as well as ignore(igore: Ignore the problem that the covariance matrix is not a positive semidefinite matrix , Generating arrays .warn: Output warning , But the array will still be generated .raise: Application error , And will not generate an array ).
tol: Tolerance when checking singular value of covariance matrix ,float type .
import numpy as np
x = np.random.multivariate_normal(10, 2, (2, 3), 'raise')
3.python Create normal distribution number
(1) Generate an array of random normal distributions
np.random.normal(loc =0.0 , scale= 1.0,size = (5,4))
- loc:float type , Represents the mean value of this normal distribution ( Corresponding to the whole distribution center );
- scale:float type , Represents the standard deviation of this normal distribution ( Corresponding to the density of the distribution ,scale The bigger, the fatter , The more scattered the data ;scale Smaller, thinner and taller , More centralized data )
- size: Output shape,size=(k,m,n)
Indicative output k dimension ,m That's ok ,n Number of columns , The default is None, Output only one value ,size=100, Indicative output 100 It's worth
(2) Generate an array of standard normal distributions
np.random.standard_normal(size = (5,4)) # Returns an array of standard normal distributions of a specified shape
The following is the equivalent statement :
python in :
print(np.random.normal(loc =0.0 , scale= 1.0,size = (2,1)))
print(np.random.standard_normal(size = (2,1)))
matlab in :normrnd(0,1,2,1)
边栏推荐
- tarjan2
- Named block Verilog
- Mathematical calculation in real mode addressing
- 2022-2028 global encryption software industry research and trend analysis report
- Global and Chinese market of handheld ultrasonic scanners 2022-2028: Research Report on technology, participants, trends, market size and share
- Force deduction daily question 540 A single element in an ordered array
- GSE104154_ scRNA-seq_ fibrotic MC_ bleomycin/normalized AM3
- What is the binding path of SAP ui5
- Find duplicates [Abstract binary / fast and slow pointer / binary enumeration]
- halcon图像矫正
猜你喜欢

West digital decided to raise the price of flash memory products immediately after the factory was polluted by materials
![Find duplicates [Abstract binary / fast and slow pointer / binary enumeration]](/img/9b/3c001c3b86ca3f8622daa7f7687cdb.png)
Find duplicates [Abstract binary / fast and slow pointer / binary enumeration]

A list of job levels and salaries in common Internet companies. Those who have conditions must enter big factories. The salary is really high

GB/T-2423. XX environmental test documents, including the latest documents

Render header usage of El table

Verilog parallel block implementation
![[staff] diacritical mark (ascending sign | descending sign B | double ascending sign x | double descending sign BB)](/img/96/8c4baa1dd8e35e2cab67461e7c447b.jpg)
[staff] diacritical mark (ascending sign | descending sign B | double ascending sign x | double descending sign BB)

How to develop digital collections? How to develop your own digital collections

2022-2028 global human internal visualization system industry research and trend analysis report

2022-2028 global encryption software industry research and trend analysis report
随机推荐
小米青年工程师,本来只是去打个酱油
Rotating frame target detection mmrotate v0.3.1 learning model
/silicosis/geo/GSE184854_ scRNA-seq_ mouse_ lung_ ccr2/GSE184854_ RAW/GSM5598265_ matrix_ inflection_ demult
MSI announced that its motherboard products will cancel all paper accessories
命名块 verilog
2022-2028 global human internal visualization system industry research and trend analysis report
el-table的render-header用法
PHP array processing
In depth interpretation of pytest official documents (26) customized pytest assertion error information
[staff] diacritical mark (ascending sign | descending sign B | double ascending sign x | double descending sign BB)
[HCIA continuous update] overview of dynamic routing protocol
数据传输中的成帧
Design details of SAP e-commerce cloud footernavigationcomponent
2022-2028 global encryption software industry research and trend analysis report
跟着CTF-wiki学pwn——ret2shellcode
Qualcomm platform WiFi -- P2P issue (2)
spark调优
[JS reverse series] analysis of a customs publicity platform
Detailed explanation of the difference between Verilog process assignment
Stdref and stdcref