Attachment 'tp.py'

Download

   1 #!/usr/bin/python
   2 import numpy as np
   3 import scipy.stats,math
   4 # Time series of JJA rainfall anomalies in magenta box in La Nina years. 
   5 # Units are 0.1 mm
   6 # area fraction of box, compared to whole domain: f=0.048
   7 d=[1520.95864484, -1358.54014118, -609.558987003, -1181.48614309, -496.757418015,
   8  -1019.90448597, 85.1424898604, -239.607945636, 30.852401201, 137.252540747,
   9  136.709073591, -519.553083375, -838.162447148, -236.213575834, 295.318167041]
  10 da=np.array(d)
  11 n=da.shape[0]
  12 tval=math.sqrt(1.*n)*da.mean(0)/np.sqrt(da.var(0))
  13 print 'n=',n
  14 print 'my t-value:',tval
  15 scipytvalue,scipypvalue=scipy.stats.ttest_1samp(da,0.)
  16 print 'scipytvalue',scipytvalue
  17 print 'scipypvalue',scipypvalue,'(this is 2*p)'
  18 print 'Note discrepancy in t-values, I must be doing something wrong :('
  19 # approximately confirms at: http://danielsoper.com/statcalc3/calc.aspx?id=8
  20 

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.