当前位置:网站首页>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)
边栏推荐
猜你喜欢

Docker安装canal、mysql进行简单测试与实现redis和mysql缓存一致性

2022-2028 global aluminum beverage can coating industry research and trend analysis report

MySQL advanced (Advanced) SQL statement (II)

MMSegmentation系列之训练与推理自己的数据集(三)

2022-2028 global wood vacuum coating machine industry research and trend analysis report

GB/T-2423.xx 环境试验文件,整理包括了最新的文件里面

C reflection practice

Verilog 过程连续赋值

命名块 verilog

Design details of SAP e-commerce cloud footernavigationcomponent
随机推荐
Grpc quick practice
Verilog 避免 Latch
Verilog wire type
Design details of SAP e-commerce cloud footernavigationcomponent
2022-2028 global wood vacuum coating machine 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 REG 寄存器、向量、整数、实数、时间寄存器
Tupu software has passed CMMI5 certification| High authority and high-level certification in the international software field
/silicosis/geo/GSE184854_scRNA-seq_mouse_lung_ccr2/GSE184854_RAW/GSM5598265_matrix_inflection_demult
Start a business
JDBC details
Learn PWN from CTF wiki - ret2shellcode
C#联合halcon脱离halcon环境以及各种报错解决经历
GSE104154_scRNA-seq_fibrotic MC_bleomycin/normalized AM3
2022 hoisting machinery command examination paper and summary of hoisting machinery command examination
Spark Tuning
Render header usage of El table
JS <2>
只需简单几步 - 开始玩耍微信小程序
2022-2028 global human internal visualization system industry research and trend analysis report