This is a static copy of a profile report

Home

Function details for stats\private\binodevianceThis is a static copy of a profile report

Home

stats\private\binodeviance (Calls: 8, Time: 0.010 s)
Generated 03-Jul-2019 20:30:06 using performance time.
function in file C:\Program Files\MATLAB\R2019a\toolbox\stats\stats\private\binodeviance.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
binopdffunction8
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
15
bd0=zeros(size(x),'like',inter...
80.002 s17.4%
39
bd0(k)= x(k).*log(x(k)./np(k))...
80.001 s14.4%
20
s = (x(k)-np(k)).*(x(k)-np(k))...
80.001 s12.7%
27
ej(ok) = ej(ok).*v(ok).*v(ok);
600.001 s9.3%
21
v = (x(k)-np(k))./(x(k)+np(k))...
80.001 s8.1%
All other lines  0.004 s38.0%
Totals  0.010 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
dominantTypefunction80.001 s7.8%
Self time (built-ins, overhead, etc.)  0.009 s92.2%
Totals  0.010 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function42
Non-code lines (comments, blank lines)19
Code lines (lines that can run)23
Code lines that did run23
Code lines that did not run0
Coverage (did run/can run)100.00 %
Function listing
time 
Calls 
 line
   1 
function bd0 = binodeviance(x,np)
   2 
%BINODEVIANCE Deviance term for binomial and Poisson probability calculation.
   3 
%    BD0=BINODEVIANCE(X,NP) calculates the deviance as defined in equation
   4 
%    5.2 in C. Loader, "Fast and Accurate Calculations of Binomial
   5 
%    Probabilities", July 9, 2000. X and NP must be of the same size.
   6 
%
   7 
%    For "x/np" not close to 1:
   8 
%        bd0(x,np) = np*f(x/np) where f(e)=e*log(e)+1-e
   9 
%    For "x/np" close to 1: 
  10 
%         The function is calculated using the formula in Equation 5.2. 
  11 

  12 
%   Copyright 2010-2014 The MathWorks, Inc.
  13 

  14 

  0.002 
      8 
  15
bd0=zeros(size(x),'like',internal.stats.dominantType(x,np)); 
  16 

  17 
% If "x/np" is close to 1:
< 0.001 
      8 
  18
k = abs(x-np)<0.1*(x+np); 
< 0.001 
      8 
  19
if any(k(:)) 
  0.001 
      8 
  20
    s = (x(k)-np(k)).*(x(k)-np(k))./(x(k)+np(k)); 
< 0.001 
      8 
  21
    v = (x(k)-np(k))./(x(k)+np(k)); 
< 0.001 
      8 
  22
    ej = 2.*x(k).*v; 
< 0.001 
      8 
  23
    s1 = zeros(size(s),'like',s); 
< 0.001 
      8 
  24
    ok = true(size(s)); 
< 0.001 
      8 
  25
    j = 0; 
< 0.001 
      8 
  26
    while any(ok(:)) 
< 0.001 
     60 
  27
        ej(ok) = ej(ok).*v(ok).*v(ok); 
< 0.001 
     60 
  28
        j = j+1; 
< 0.001 
     60 
  29
        s1(ok) = s(ok) + ej(ok)./(2*j+1); 
< 0.001 
     60 
  30
        ok = ok & s1~=s; 
< 0.001 
     60 
  31
        s(ok) = s1(ok); 
< 0.001 
     60 
  32
    end 
< 0.001 
      8 
  33
    bd0(k) = s; 
< 0.001 
      8 
  34
end 
  35 

  36 
% If "x/np" is not close to 1:
< 0.001 
      8 
  37
k = ~k; 
< 0.001 
      8 
  38
if any(k(:)) 
  0.001 
      8 
  39
    bd0(k)= x(k).*log(x(k)./np(k))+np(k)-x(k); 
< 0.001 
      8 
  40
end 
  41 

< 0.001 
      8 
  42
end 

Other subfunctions in this file are not included in this listing.