Rubyのソースです

require 'statistics2'

def ci_lower_bound(pos, n, power)
  if n == 0
    return 0
  end
  z = Statistics2.pnormaldist(1-power/2)
  phat = 1.0*pos/n
   (phat + z*z/(2*n) - z * Math.sqrt((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n)
end