pro p1e,bins,x,h,xx,mi=mi,ma=ma,hcopy=hcopy,simple=simple,noplot=noplot

;sheet2 - problem 1e  

x=[  79,  89,  77,  83,  76,  91,  87,  89,  84,  68,$
     77,  73,  71,  77,  76,  77,  64,  82,  65,  46,$
     21,  77,  66,  72,  74,  65,  70,  70,  73,  76,$
     37,  63,  63,  50,  68,  64,  73,  44,  46,  33,$
     69,  61,  65,  54,  52,  77,  60,  65,  61,  26,$
     64,  49,  62,  53,  55,  62,  43,  50,  51,  54,$
     24,  37,  30,  41,  34,  31,  49,  43,  39,  48,$
     89,  33,  23,  35,  35,  14,  21,  30,  33,  26]   

;print,x(sort(x))

if n_elements(mi) eq 0 then mi=min(x)
if n_elements(ma) eq 0 then ma=max(x)

if keyword_set(hcopy) then begin
  fn='a'
  print,'input file_name'
  read,fn
  set_plot,'ps'
  device,file=fn 
endif

if not keyword_set(noplot) then begin
   my_histogram,bins,x,h,xx,mi=mi,ma=ma,/plot
endif else begin
   my_histogram,bins,x,h,xx,mi=mi,ma=ma
endelse

if keyword_set(simple) then goto, end1

nx=n_elements(x)

meanhist=total(h*xx)/float(nx)
print,'mean   (binned) = ',meanhist
plots,[meanhist,meanhist],[0,20],lines=1

sigma_n=sqrt(total(h*(xx-meanhist)^2)/float(nx))
print,'sigma_N   (binned) = ',sigma_n
plots,[meanhist-2.*sigma_n,meanhist-2.*sigma_n],[0,20],lines=2
plots,[meanhist+2.*sigma_n,meanhist+2.*sigma_n],[0,20],lines=2

gam1=total(h*(xx-meanhist)^3)/float(nx)/sigma_n^3
print,'gamma_1(N)   (binned) = ',gam1

end1:
if keyword_set(hcopy) then begin
  device,/close
  set_plot,'x'
endif

return
end
