Mercurial > hg > nsaunier > traffic-intelligence
comparison trafficintelligence/utils.py @ 1267:ad60e5adf084
cleaned interaction categorization and added stationary category
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Wed, 29 May 2024 09:52:42 -0400 |
| parents | 77fbd0e2ba7d |
| children | bae8de98406f |
comparison
equal
deleted
inserted
replaced
| 1266:ebb18043616e | 1267:ad60e5adf084 |
|---|---|
| 136 k = round(norm.ppf(0.5+percentConfidence/200., 0, 1), 2) | 136 k = round(norm.ppf(0.5+percentConfidence/200., 0, 1), 2) |
| 137 else: # use Student | 137 else: # use Student |
| 138 k = round(t.ppf(0.5+percentConfidence/200., nSamples-1), 2) | 138 k = round(t.ppf(0.5+percentConfidence/200., nSamples-1), 2) |
| 139 e = k*stdev/sqrt(nSamples) | 139 e = k*stdev/sqrt(nSamples) |
| 140 if printLatex: | 140 if printLatex: |
| 141 print('${0} \pm {1}\\frac{{{2}}}{{\sqrt{{{3}}}}}$'.format(mean, k, stdev, nSamples)) | 141 print('${0} \\pm {1}\\frac{{{2}}}{{\\sqrt{{{3}}}}}$'.format(mean, k, stdev, nSamples)) |
| 142 return mean-e, mean+e | 142 return mean-e, mean+e |
| 143 | 143 |
| 144 def computeChi2(expected, observed): | 144 def computeChi2(expected, observed): |
| 145 '''Returns the Chi2 statistics''' | 145 '''Returns the Chi2 statistics''' |
| 146 return sum([((e-o)*(e-o))/float(e) for e, o in zip(expected, observed)]) | 146 return sum([((e-o)*(e-o))/float(e) for e, o in zip(expected, observed)]) |
