User Tools

Site Tools


python_cookbook

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
python_cookbook [2019/01/24 14:19]
mantis [Logging to File]
python_cookbook [2019/03/05 09:49]
mantis [Unit Tests]
Line 1779: Line 1779:
 y = numpy.array([41.621207814814809,​ 42.328298238095236,​ 45.881729878787887,​ 43.800834224999996]) y = numpy.array([41.621207814814809,​ 42.328298238095236,​ 45.881729878787887,​ 43.800834224999996])
 y_smoothed = scipy.signal.cspline1d(y) y_smoothed = scipy.signal.cspline1d(y)
 +</​code>​
 +
 +===== t-test =====
 +
 +<code python>
 +from scipy import stats
 +import numpy
 +import statistics
 +
 +# http://​www.biostathandbook.com/​onesamplettest.html
 +data = [120.6, 116.4,​117.2,​118.1,​114.1,​116.9,​113.3,​121.1,​116.9,​117.0]
 +
 +m = sum(data)/​len(data)
 +
 +null_hypothesis = 120
 +
 +t_value, p_value = stats.ttest_1samp(data,​ null_hypothesis)
 +
 +print(statistics.stdev(data))
 +print(numpy.std(data,​ ddof=1))
 +
 +print(t_value,​ p_value)
 </​code>​ </​code>​
 ====== Statistical Functions ====== ====== Statistical Functions ======
Line 1832: Line 1854:
 (found in comments [[http://​programmingpraxis.com/​2012/​05/​29/​streaming-median/​|here]] - damn I hate paywalls. I'd love to read the piglet tracking paper!) (found in comments [[http://​programmingpraxis.com/​2012/​05/​29/​streaming-median/​|here]] - damn I hate paywalls. I'd love to read the piglet tracking paper!)
  
-====== ​Unit Tests ======+====== ​Testing ​====== 
 + 
 +===== unittest ===== 
   * Python 2 https://​docs.python.org/​2.7/​library/​unittest.html   * Python 2 https://​docs.python.org/​2.7/​library/​unittest.html
   * python 3 https://​docs.python.org/​3.4/​library/​unittest.html   * python 3 https://​docs.python.org/​3.4/​library/​unittest.html
python_cookbook.txt · Last modified: 2019/03/05 09:51 by mantis