Mercurial Hosting > traffic-intelligence
comparison python/utils.py @ 876:c7e72d758049
minor update to avoid integer issue
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 08 Mar 2017 17:05:29 -0500 |
parents | a8de3c93f6b7 |
children | d8ab183a7351 |
comparison
equal
deleted
inserted
replaced
875:45384b45e35a | 876:c7e72d758049 |
---|---|
80 print('${0} \pm {1}\\frac{{{2}}}{{\sqrt{{{3}}}}}$'.format(mean, k, stdev, nSamples)) | 80 print('${0} \pm {1}\\frac{{{2}}}{{\sqrt{{{3}}}}}$'.format(mean, k, stdev, nSamples)) |
81 return mean-e, mean+e | 81 return mean-e, mean+e |
82 | 82 |
83 def computeChi2(expected, observed): | 83 def computeChi2(expected, observed): |
84 '''Returns the Chi2 statistics''' | 84 '''Returns the Chi2 statistics''' |
85 result = 0. | 85 return sum([((e-o)*(e-o))/float(e) for e, o in zip(expected, observed)]) |
86 for e, o in zip(expected, observed): | |
87 result += ((e-o)*(e-o))/e | |
88 return result | |
89 | 86 |
90 class DistributionSample(object): | 87 class DistributionSample(object): |
91 def nSamples(self): | 88 def nSamples(self): |
92 return sum(self.counts) | 89 return sum(self.counts) |
93 | 90 |