Example #1
0
def pdf1d(d, imp, bins, smooth, color):

    from scipy import ndimage

    pylab.xlim([bins[0], bins[-1]])

    # Bin the data in 1D, return histogram h(x):
    h, x = numpy.histogram(d,
                           weights=imp,
                           bins=bins,
                           range=[bins[0], bins[-1]])
    norm = numpy.sum(h)
    h = h / norm

    # Report some statistics:
    median, errplus, errminus = pappy.compress_histogram(h, x, ci=68)
    result = pappy.format_point_estimate(median, errplus, errminus)

    # Smooth and normalise the histogram into a PDF:
    p = ndimage.gaussian_filter1d(h, smooth)
    norm = numpy.sum(p)
    p = p / norm

    # Plot:
    pylab.plot(x[:-1], p, drawstyle='line', color=color)

    return p.max(), result
Example #2
0
def pdf1d(d,imp,bins,smooth,color):

  from scipy import ndimage

  pylab.xlim([bins[0],bins[-1]])

  # Bin the data in 1D, return histogram h(x):
  h,x = numpy.histogram(d,weights=imp,bins=bins,range=[bins[0],bins[-1]])
  norm = numpy.sum(h)
  h = h/norm

  # Report some statistics:
  median,errplus,errminus = pappy.compress_histogram(h,x,ci=68)
  result = pappy.format_point_estimate(median,errplus,errminus)

  # Smooth and normalise the histogram into a PDF:
  p = ndimage.gaussian_filter1d(h,smooth)
  norm = numpy.sum(p)
  p = p/norm

  # Plot:
  pylab.plot(x[:-1],p,drawstyle='line',color=color)

  return p.max(),result
Example #3
0
    mean,stdev,Neff,N95 = pappy.meansd(d,wht=wht)
    
    if histogram:
      dylimits = numpy.zeros([2])
      dylimits[0] = mean - 10*stdev
      dylimits[1] = mean + 10*stdev
      nbins = 161
      bins = numpy.linspace(dylimits[0],dylimits[1],nbins)
      h,x = numpy.histogram(d,weights=wht,bins=bins,range=[bins[0],bins[-1]])
      norm = numpy.sum(h)
      h = h/norm      
      median,errplus,errminus = pappy.compress_histogram(h,x,ci=cred)
    else:
      median,errplus,errminus = pappy.compress_samples(d,wht=wht,ci=cred)

    estimate = pappy.format_point_estimate(median,errplus,errminus)
    if longwinded: 
      print "  Par no.",col+1,":",labels[col].strip(),"=",estimate
    else:
      print estimate

    if vb: 
      print "  Par no.",col+1," mean,stdev,Neff,N95 = ",mean,stdev,Neff,N95

# --------------------------------------------------------------------

  return

# ======================================================================

if __name__ == '__main__':