当前位置:网站首页>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)
边栏推荐
- [JS reverse series] analysis of a customs publicity platform
- IPhone 6 plus is listed in Apple's "retro products" list
- el-table的render-header用法
- 终日乾乾,夕惕若厉
- Special symbols in SAP ui5 data binding syntax, and detailed explanation of absolute binding and relative binding concepts
- aaaaaaaaaaaaa
- MySQL connection query and subquery
- Verilog 避免 Latch
- halcon图像矫正
- Sentry experience and architecture, a fledgling monitoring product with a market value of $100million
猜你喜欢

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

JS introduction < 1 >

MSI announced that its motherboard products will cancel all paper accessories

跟着CTF-wiki学pwn——ret2shellcode

Pointer array & array pointer

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

Verilog avoid latch

Use usedeferredvalue for asynchronous rendering

Retrofit's callback hell is really vulnerable in kotlin synergy mode

verilog 并行块实现
随机推荐
Just a few simple steps - start playing wechat applet
Verilog 过程连续赋值
el-table的render-header用法
Grpc快速实践
/silicosis/geo/GSE184854_ scRNA-seq_ mouse_ lung_ ccr2/GSE184854_ RAW/GSM5598265_ matrix_ inflection_ demult
[JS reverse series] analysis of a customs publicity platform
Verilog state machine
Share the basic knowledge of a common Hongmeng application
GSE104154_scRNA-seq_fibrotic MC_bleomycin/normalized AM3
表单自定义校验规则
初出茅庐市值1亿美金的监控产品Sentry体验与架构
Addition without addition, subtraction, multiplication and division (simple difficulty)
自定义组件的 v-model
Continuous assignment of Verilog procedure
Qualcomm platform WiFi -- Native crash caused by WiFi
Global and Chinese markets for hand hygiene monitoring systems 2022-2028: Research Report on technology, participants, trends, market size and share
Download and use of the super perfect screenshot tool snipaste
On redis (II) -- cluster version
OSPF LSA message parsing (under update)
Baohong industry | 6 financial management models at different stages of life