⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 func_restricted_sampling.m

📁 This software is a Matlab implementation of restricted sampling from Gaussian distribution, and samp
💻 M
字号:
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;

⌨️ 快捷键说明

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