This is a static copy of a profile report

Home

norminv (Calls: 135, Time: 0.007 sec)
Generated 28-May-2016 14:58:47 using performance time.
function in file /home/johs/MATLAB/R2015b/toolbox/stats/stats/norminv.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
Optimizer_cpu>Optimizer_cpu.scoreclass method135
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
59
x0 = -sqrt(2).*erfcinv(2*p);
1350.002 s28.0%
61
x = sigma.*x0 + mu;
1350.002 s24.4%
56
sigma(sigma <= 0) = NaN;
1350.001 s19.5%
57
p(p < 0 | 1 < p) = NaN;
1350.001 s7.0%
67
if nargout>=2
1350.000 s2.8%
All other lines  0.001 s18.4%
Totals  0.007 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function76
Non-code lines (comments, blank lines)36
Code lines (lines that can run)40
Code lines that did run10
Code lines that did not run30
Coverage (did run/can run)25.00 %
Function listing
time 
Calls 
 line
   1 
function [x,xlo,xup] = norminv(p,mu,sigma,pcov,alpha)
   2 
%NORMINV Inverse of the normal cumulative distribution function (cdf).
   3 
%   X = NORMINV(P,MU,SIGMA) returns the inverse cdf for the normal
   4 
%   distribution with mean MU and standard deviation SIGMA, evaluated at
   5 
%   the values in P.  The size of X is the common size of the input
   6 
%   arguments.  A scalar input functions as a constant matrix of the same
   7 
%   size as the other inputs.
   8 
%
   9 
%   Default values for MU and SIGMA are 0 and 1, respectively.
  10 
%
  11 
%   [X,XLO,XUP] = NORMINV(P,MU,SIGMA,PCOV,ALPHA) produces confidence bounds
  12 
%   for X when the input parameters MU and SIGMA are estimates.  PCOV is a
  13 
%   2-by-2 matrix containing the covariance matrix of the estimated parameters.
  14 
%   ALPHA has a default value of 0.05, and specifies 100*(1-ALPHA)% confidence
  15 
%   bounds.  XLO and XUP are arrays of the same size as X containing the lower
  16 
%   and upper confidence bounds.
  17 
%
  18 
%   See also ERFINV, ERFCINV, NORMCDF, NORMFIT, NORMLIKE, NORMPDF,
  19 
%            NORMRND, NORMSTAT.
  20 

  21 
%   References:
  22 
%      [1] Abramowitz, M. and Stegun, I.A. (1964) Handbook of Mathematical
  23 
%          Functions, Dover, New York, 1046pp., sections 7.1, 26.2.
  24 
%      [2] Evans, M., Hastings, N., and Peacock, B. (1993) Statistical
  25 
%          Distributions, 2nd ed., Wiley, 170pp.
  26 

  27 
%   Copyright 1993-2011 The MathWorks, Inc. 
  28 

  29 

< 0.01 
    135 
  30 
if nargin<1 
  31 
    error(message('stats:norminv:TooFewInputsP'));
  32 
end
< 0.01 
    135 
  33 
if nargin < 2 
  34 
    mu = 0;
  35 
end
< 0.01 
    135 
  36 
if nargin < 3 
  37 
    sigma = 1;
  38 
end
  39 

  40 
% More checking if we need to compute confidence bounds.
< 0.01 
    135 
  41 
if nargout>2 
  42 
   if nargin<4
  43 
      error(message('stats:norminv:TooFewInputsCovariance'));
  44 
   end
  45 
   if ~isequal(size(pcov),[2 2])
  46 
      error(message('stats:norminv:BadCovarianceSize'));
  47 
   end
  48 
   if nargin<5
  49 
      alpha = 0.05;
  50 
   elseif ~isnumeric(alpha) || numel(alpha)~=1 || alpha<=0 || alpha>=1
  51 
      error(message('stats:norminv:BadAlpha'));
  52 
   end
  53 
end
  54 

  55 
% Return NaN for out of range parameters or probabilities.
< 0.01 
    135 
  56 
sigma(sigma <= 0) = NaN; 
< 0.01 
    135 
  57 
p(p < 0 | 1 < p) = NaN; 
  58 

< 0.01 
    135 
  59 
x0 = -sqrt(2).*erfcinv(2*p); 
< 0.01 
    135 
  60 
try 
< 0.01 
    135 
  61 
    x = sigma.*x0 + mu; 
  62 
catch
  63 
    error(message('stats:norminv:InputSizeMismatch'));
  64 
end
  65 

  66 
% Compute confidence bounds if requested.
< 0.01 
    135 
  67 
if nargout>=2 
  68 
   xvar = pcov(1,1) + 2*pcov(1,2)*x0 + pcov(2,2)*x0.^2;
  69 
   if any(xvar<0)
  70 
      error(message('stats:norminv:BadCovarianceSymPos'));
  71 
   end
  72 
   normz = -norminv(alpha/2);
  73 
   halfwidth = normz * sqrt(xvar);
  74 
   xlo = x - halfwidth;
  75 
   xup = x + halfwidth;
  76 
end