当前位置:网站首页>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)
边栏推荐
- Share the basic knowledge of a common Hongmeng application
- GSE104154_ scRNA-seq_ fibrotic MC_ bleomycin/normalized AM3
- Common means of modeling: aggregation
- About DNS
- 32, 64, 128 bit system
- 2022-2028 global wood vacuum coating machine industry research and trend analysis report
- Discussion on related configuration of thread pool
- 表单自定义校验规则
- MongoDB非關系型數據庫
- Global and Chinese markets for electronic laryngoscope systems 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢

JS <2>

数据传输中的成帧

2022-2028 global manual dental cleaning equipment industry research and trend analysis report

Design details of SAP e-commerce cloud footernavigationcomponent
![Find duplicates [Abstract binary / fast and slow pointer / binary enumeration]](/img/9b/3c001c3b86ca3f8622daa7f7687cdb.png)
Find duplicates [Abstract binary / fast and slow pointer / binary enumeration]

buu_ re_ crackMe

MongoDB非關系型數據庫

Mmsegmentation series training and reasoning their own data set (3)

Named block Verilog

Xiaomi, a young engineer, was just going to make soy sauce
随机推荐
Just a few simple steps - start playing wechat applet
Verilog 状态机
Retrofit's callback hell is really vulnerable in kotlin synergy mode
小米青年工程师,本来只是去打个酱油
2022-2028 global nano abrasive industry research and trend analysis report
In depth interpretation of pytest official documents (26) customized pytest assertion error information
Docker安装canal、mysql进行简单测试与实现redis和mysql缓存一致性
MongoDB非关系型数据库
终日乾乾,夕惕若厉
Use blocking or non blocking for streamline
Baohong industry | 6 financial management models at different stages of life
IPhone 6 plus is listed in Apple's "retro products" list
创业了...
Verilog 避免 Latch
Form custom verification rules
Global and Chinese markets for infant care equipment, 2022-2028: Research Report on technology, participants, trends, market size and share
[C Advanced] brother Peng takes you to play with strings and memory functions
[HCIA continuous update] overview of dynamic routing protocol
Verilog 过程赋值 区别 详解
Baohong industry | what misunderstandings should we pay attention to when diversifying investment