OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Pure Python implementation of the Mann-Whitney U test. | 5 """Pure Python implementation of the Mann-Whitney U test. |
6 | 6 |
7 This code is adapted from SciPy: | 7 This code is adapted from SciPy: |
8 https://github.com/scipy/scipy/blob/master/scipy/stats/stats.py | 8 https://github.com/scipy/scipy/blob/master/scipy/stats/stats.py |
9 Which is provided under a BSD-style license. | 9 Which is provided under a BSD-style license. |
10 | 10 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 size = len(arr) | 81 size = len(arr) |
82 if size < 2: | 82 if size < 2: |
83 return 1.0 | 83 return 1.0 |
84 else: | 84 else: |
85 return 1.0 - sum(x**3 - x for x in cnt) / float(size**3 - size) | 85 return 1.0 - sum(x**3 - x for x in cnt) / float(size**3 - size) |
86 | 86 |
87 | 87 |
88 def _NormSf(x): | 88 def _NormSf(x): |
89 """Survival function of the standard normal distribution. (1 - cdf)""" | 89 """Survival function of the standard normal distribution. (1 - cdf)""" |
90 return (1 - math.erf(x/math.sqrt(2))) / 2 | 90 return (1 - math.erf(x/math.sqrt(2))) / 2 |
OLD | NEW |