randnt.c

来自「交叉熵实现多元高斯混合模型优化的源代码」· C语言 代码 · 共 61 行

C
61
字号
/*  
    Truncated Gaussian numbers generator


    Usage
	-----

   
    y = randnt(m , sigma  , [left] , [right] , [n1] , ... , [np]);


    Inputs
	------


    m                   Mean values (v1 x v2 x ...x vl) or scalar if randnt if called with more than 4 arguments
	sigma               Variance values (v1 x v2 x ...x vl) or scalar if randnt if called with more than 4 arguments
	left                Left boundaries (v1 x v2 x ...x vl) or scalar if randnt if called with more than 4 arguments
    Right               Right boundaries (v1 x v2 x ...x vl) or scalar if randnt if called with more than 4 arguments
 
    ni                  Size of dimension i



    Outputs
	------

    y                  Truncated independant samples (v1 x v2 x ... x vl) or (n1 x n2 x .... x np)
  

    Examples
	-------

   
	y = randnt(0 , 1 , 0 , 3 , 2 , 3);

	y = randnt(0 , 1 , [] , 3 , 2 , 3 , 2);

	y = randnt(0 , 1 , [] , [] , 2 , 3 , 2); % <=> randn(2 , 3 , 2)

    y = randnt(ones(2,2,3) , ones(2,2,3) , zeros(2,2,3) , ones(2,2,3));


	 
	y = randnt(ones(2,2) , ones(2,2));  N(1 , 1)*I_{2,2}


  	To compile :
	------------
	
	
	mex -DranSHR3  -output randnt.dll randnt.c or mex -DranKISS -output randnt.dll randnt.c  (little bit slower)

    Myself, I use Intel CPP compiler as : 

    mex -DranSHR3 -f mexopts_intel10AMD.bat -output randnt.dll randnt.c

    Ver 1.0 (03/04/05)


  Author : S閎astien PARIS 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?