nanbinerr.m 332 B

1234567891011121314
  1. function y=nanbinerr(x)
  2. % y=nanbinerr(x)
  3. % returns the binomial error bars for a vector of 1/0
  4. nnx=x(~isnan(x));
  5. p=mean(nnx);
  6. n=numel(nnx);
  7. y=(1/(1+1.96/n))*(p+1.96/(2*n)+1.96*sqrt(p*(1-p)/n + 1.96/(4*n^2)))-p;
  8. % This is the Wilson Score Interval, from wikipedia
  9. % this is the bad version
  10. % y=1.96*sqrt(mux*(1-mux)/numel(nnx));