当前位置:网站首页>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)
边栏推荐
- 小米青年工程师,本来只是去打个酱油
- QT environment generates dump to solve abnormal crash
- OSPF LSA message parsing (under update)
- In depth interpretation of pytest official documents (26) customized pytest assertion error information
- Redis cluster
- Special symbols in SAP ui5 data binding syntax, and detailed explanation of absolute binding and relative binding concepts
- [JVM] detailed description of the process of creating objects
- GB/T-2423. XX environmental test documents, including the latest documents
- Baohong industry | 6 financial management models at different stages of life
- Pointer array & array pointer
猜你喜欢
JS <2>
Named block Verilog
使用 useDeferredValue 进行异步渲染
[JS reverse series] analysis of a customs publicity platform
Detailed explanation of the difference between Verilog process assignment
[staff] diacritical mark (ascending sign | descending sign B | double ascending sign x | double descending sign BB)
Common means of modeling: aggregation
2022-2028 global manual dental cleaning equipment industry research and trend analysis report
West digital decided to raise the price of flash memory products immediately after the factory was polluted by materials
创业了...
随机推荐
Verilog 避免 Latch
Global and Chinese markets for electronic laryngoscope systems 2022-2028: Research Report on technology, participants, trends, market size and share
aaaaaaaaaaaaa
Mmsegmentation series training and reasoning their own data set (3)
Gradle 笔记
What is the binding path of SAP ui5
GB/T-2423.xx 环境试验文件,整理包括了最新的文件里面
QT environment generates dump to solve abnormal crash
How to create an instance of the control defined in SAP ui5 XML view at runtime?
OSPF LSA message parsing (under update)
Global and Chinese market of X-ray detectors 2022-2028: Research Report on technology, participants, trends, market size and share
2022-2028 global aluminum beverage can coating industry research and trend analysis report
Download and use of the super perfect screenshot tool snipaste
Global and Chinese market of bone adhesives 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
Use blocking or non blocking for streamline
【JVM】创建对象的流程详解
Form custom verification rules
tarjan2