mynorminv.m
来自「麻省理工学院的人工智能工具箱,很珍贵,希望对大家有用!」· M 代码 · 共 60 行
M
60 行
function x = norminv(p,mu,sigma);%NORMINV Inverse of the normal cumulative distribution function (cdf).% X = NORMINV(P,MU,SIGMA) finds the inverse of the normal cdf with% mean, MU, and standard deviation, SIGMA.%% The size of X is the common size of the input arguments. A scalar input % functions as a constant matrix of the same size as the other inputs. %% Default values for MU and SIGMA are 0 and 1 respectively.% References:% [1] M. Abramowitz and I. A. Stegun, "Handbook of Mathematical% Functions", Government Printing Office, 1964, 7.1.1 and 26.2.2% Copyright (c) 1993-98 by The MathWorks, Inc.% $Revision: 2.6 $ $Date: 1997/11/29 01:46:15 $if nargin < 3, sigma = 1;endif nargin < 2; mu = 0;end[errorcode p mu sigma] = distchck(3,p,mu,sigma);if errorcode > 0 error('Requires non-scalar arguments to match in size.');end% Allocate space for x.x = zeros(size(p));% Return NaN if the arguments are outside their respective limits.k = find(sigma <= 0 | p < 0 | p > 1);if any(k) tmp = NaN; x(k) = tmp(ones(size(k))); end% Put in the correct values when P is either 0 or 1.k = find(p == 0);if any(k) tmp = Inf; x(k) = -tmp(ones(size(k)));endk = find(p == 1);if any(k) tmp = Inf; x(k) = tmp(ones(size(k))); end% Compute the inverse function for the intermediate values.k = find(p > 0 & p < 1 & sigma > 0);if any(k), x(k) = sqrt(2) * sigma(k) .* erfinv(2 * p(k) - 1) + mu(k);end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?