?? func_restricted_sampling.m
字號(hào):
function x= func_restricted_sampling(x_mu, x_var, x_min, x_max);
% Matlab implementation of restricted sampling from Gaussian distribution
%
% Objective: sample x (column vector) from N(x_mu, x_var), restricted in
% x_min<=x<=x_max.
%
% input: x_mu, x_var: the parameter of the pdf of x
% x_min, x_max: the range of x
% output: x: the sample
%
% Acknowledge
% Peter J. Acklam's toolbox for the inverse normal cumulative distribution function
% http://home.online.no/~pjacklam/notes/invnorm/index.html
%
%
% Jing Tian
% Contact me : scuteejtian@hotmail.com
% This program is written in Oct.2004 during my postgraduate studying in
% NTU, Singapore.
r = rand(size(x_mu, 1), 1);
y_min = (x_min - x_mu) ./ sqrt(x_var);
y_max = (x_max - x_mu) ./ sqrt(x_var);
nerfcMin = ltpnorm(y_min);
nerfcMax = ltpnorm(y_max);
temp = nerfcMin + (nerfcMax-nerfcMin) .* r;
x = ltqnorm(temp) .* sqrt(x_var) + x_mu;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -